Page 1 of 1

Undefined Index in $_POST

Posted: Fri Dec 24, 2010 4:39 am
by specialK83
Hi All,

I've just started learning PHP and have written a simple login form to link to a MySQL database. The database is configured and I am able to pull data back and display it to a webpage. However, when trying to capture the contents of the $_POST variable in order to get the username and password data posted from the form, I'm getting an "undefined index" error. No data is being passed through into the $_POST variable.

Having searched on hundreds of pages through Google, there are many offers of fixes for this however none of those suggested work for me.

The code which fails is...

Code: Select all

$username = $_POST['username'];
$password = $_POST['password'];
The target system is Windows XP SP3 running Apache Server 2.2, PHP5.3.4 with MySQL 5.5

If any more code is needed (of which there is not much) then please let me know. There is only two input boxes and a submit button.

Thanks in advance for your help,
K

Re: Undefined Index in $_POST

Posted: Fri Dec 24, 2010 8:32 am
by Darhazer
Please post the HTML code of the form. it have to be configured with method POST and the names of the field should be the same as in the PHP code (note - they are case sensitive)

Re: Undefined Index in $_POST

Posted: Fri Dec 24, 2010 9:01 am
by specialK83
Thanks for your reply.

The form already uses the POST method and the $_POST vars are the same name as the form input fields.

Will post some code when I get on my development machine.

K