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

Problems with the Windows version of XAMPP, questions, comments, and anything related.

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

Postby creacon » 31. August 2009 21:10

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?
Last edited by creacon on 01. September 2009 00:47, edited 1 time in total.
creacon
 
Posts: 36
Joined: 21. August 2009 19:14

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

Postby sili » 31. August 2009 22:30

It's $_POST, not $_Post ;)
sili
 
Posts: 54
Joined: 15. March 2003 16:05
XAMPP version: dfg
Operating System: dfg

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

Postby creacon » 01. September 2009 00:45

Sorry! Yes they ARE $ signs in my program (and that IS one also). Apparently the font used here makes $ look like S.
creacon
 
Posts: 36
Joined: 21. August 2009 19:14

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

Postby Wiedmann » 01. September 2009 01:52

Yes they ARE $ signs in my program

We know. But you don't know that variable names are case-sensitive...
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

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

Postby creacon » 01. September 2009 14:13

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
creacon
 
Posts: 36
Joined: 21. August 2009 19:14


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 137 guests