We have the form of sending data to a file

<input name="name" > <textarea name="info"></textarea> <button name="read">ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚ΡŒ</button> 

And its handler:

 <?php if(isset($_POST['read'])) { $info = $_POST['info']; $f = fopen('send.txt','a+'); fputs($f,$info); fclose($f); ?> 

it works like this, but how do you pass the second name parameter to $ info?

and what to do if you need to add another $_POST parameters?

  • $_POST['name'] doesn't it work? - Kosta B.
  • @KostaB. works but if you specify two or more then the error - Just Chen
  • $info = ($_POST['info']); ($_POST['name']); This is how the name gets poisoned, but info is not - Just Chen
  • $info .= $_POST['name'] adds $info - Kosta B.
  • @KostaB. I did not understand ... - Just Chen

1 answer 1

.= - concatenation Read more here

 $info = $_POST['info']; $info .= $_POST['name']; // Π”ΠΎΠ±Π°Π²ΠΈΡ‚ ΠΊ содСрТимому $info содСрТимоС $_POST['name']; 

UPD :

 <?php if(isset($_POST['read'])) { $info = $_POST['info']; $info .= " " . $_POST['name']; // Π”ΠΎΠ±Π°Π²Π»Π΅Π½ ΠΏΡ€ΠΎΠ±Π΅Π» ΠΌΠ΅ΠΆΠ΄Ρƒ $info ΠΈ $_POST['name'] $f = fopen('send.txt','a+'); fputs($f,$info); fclose($f); } 
  • Where is the name duplicated? (You can mark as accepted answer if it helped you) - Kosta B.
  • See other places where you work with input fields. - Kosta B.
  • Besides the fact that you have missing if closing bracket, everything works without repetitions. - Kosta B.