PHP not parsing forms

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Here is the code that I used to test my server, very simple, right?
But when I click on submit, nothing.. I've also tried similar things
with php and mysql and all it did was create empty fields in the table.
 What am I doing wrong?  Please help, Ultimatly I want to parse a form
into a mysql database, but if I can't get the php engine to pass data
from the forms correctly then it's no use to go any further.


if ($submit == "click"){
  echo "Hello, $UserName";
  echo '

  <form method="post" action="form.php">

  Enter Your Name
  <input type="text" name="UserName"></input><br>

  <input type="submit" name="submit" value="click"></input>




Re: PHP not parsing forms wrote:
Quoted text here. Click to load it

You probably have register_globals turned off (and you should).
Put this in the beginning of your script:

$UserName = $_POST['UserName'];
$click = $_POST['click'];


Re: PHP not parsing forms wrote:

Quoted text here. Click to load it

Your code doesn't work because register globals have been disabled. This is
easily fixed by retrieving the post data explicitly.

Add this to the top of your PHP code:

    $submit = $_POST['submit'];

More info here: <

phil [dot] ronan @ virgin [dot] net /

[FAQ] PHP not parsing forms (was: PHP not parsing forms) wrote:
Quoted text here. Click to load it

Since 4.2.0 register_globals [1] is off by default due to security
reasons [2]. One should use super globals (introduced in 4.1.0) instead
to get to user supplied data [3]. So either fix:

-fix your code [4]:
  if(isset($_POST['submit']) && $_POST['submit']=="click")
   echo 'Hello, '.$_POST['UserName'];
-quick&dirty hack:
 in the global scope.
-enable register_globals

4: $_POST['UserName'] should offcourse be escaped properly (with
   htmlspecialchars in this particular case).

Site Timeline