0

I wanna save on my server a text file and so I'm using the file_put_contents with some flags. I also have to import a value from an <input type="text" name="loaded"> field that contains some people's names.

<input type="text" name="loaded">
 //other html code
<form method="post" action="scriptf.php">
<input type="submit" value="Go!" />
</form>

This script saves on foldera/file.txt only "Lucas Smith (lsmith334) +" but it is missing the ex (which contains the text in that input).

<?php
$file = 'foldera/file.txt';
$ex = $_POST['loaded'];
$person = "Lucas Smith (lsmith334) + ".$ex;
file_put_contents($file, $person, FILE_APPEND | LOCK_EX);
?>

What am I doing wrong?

Alberto Rossi
  • 1,800
  • 4
  • 36
  • 58

1 Answers1

0

your input isn't inside the form

<form method="post" action="scriptf.php">
<input type="text" name="loaded">
<input type="submit" value="Go!" />
</form>

should work, all of the inputs need to be inside the form tags

Nesting forms is a bad idea, and should be completely avoided, I can't think of a good reason to nest them

its actually agaist the standard too Can you nest html forms?

multiple forms is no problem, nested forms is

Community
  • 1
  • 1
exussum
  • 18,275
  • 8
  • 32
  • 65