Page 1 of 1

Can't get data from HTML form with $_Post/$_Get

PostPosted: 31. August 2009 21:10
by creacon
I'm having trouble getting data into my php program via $_Post. I'm using XAMPP localhost to test with.
I have the following code (the HTML is copied from a book - "Beginning PHP and MySQL):

<?php

// This is just simple code to test getting data via the $_Post
$name = $_Post['name'];
echo ("The name is $name");
echo $_Post['name']

?>

The above is stored in the file "subscribe.php" in the xampp's htdocs folder.

<form action="subscribe.php" method="post" />
<p>

Name:<br />
<input type="text" id="name" name="name" size="20" maxlength="40" />
</p>
<p>
Email Address:<br />
<input type="text" id="email" name="email" size="20" maxlength="40" />
</p>
<input type="submit" id="submit" name="submit" value="Go!" />
</form>

When the above html is executed, the php module gets called as it should, but the $_Post superGlobal is empty. Al that diaplays from the first "echo" is "The name is", and nothing displays from the second one. Can anyone please tell me what I'm doing wrong?

Re: Can't get data from HTML form with $_Post/$_Get

PostPosted: 31. August 2009 22:30
by sili
It's $_POST, not $_Post ;)

Re: Can't get data from HTML form with $_Post/$_Get

PostPosted: 01. September 2009 00:45
by creacon
Sorry! Yes they ARE $ signs in my program (and that IS one also). Apparently the font used here makes $ look like S.

Re: Can't get data from HTML form with $_Post/$_Get

PostPosted: 01. September 2009 01:52
by Wiedmann
Yes they ARE $ signs in my program

We know. But you don't know that variable names are case-sensitive...

Re: Can't get data from HTML form with $_Post/$_Get

PostPosted: 01. September 2009 14:13
by creacon
Thank you, thank you, thank you. It's supposed to be $_POST, and NOT $_Post. I've spent over a week trying to find out what was causing this, and VOILA! that's all it was. That certainly was an object lesson in paying attention to the book. Thanks again for your help