Jump to content

simple login script but form wont post data :(


Recommended Posts

ok..ive done this a million times..i have a working example here and i copied it and amended it for this new project but for some reason i cant get a form to post data to another page.


this is the error message i get


Notice: Undefined index: username in C:\wamp\www\uni\fyp\site\mobile\login.php on line 16


Notice: Undefined index: password in C:\wamp\www\uni\fyp\site\mobile\login.php on line 17


here is my form code:


                    <form method="post" action="login.php">
                        <table align="center" cellpadding="0" cellspacing="0">
                            <td style="vertical-align:top;">Username:  </td><td><input type="text" name="username" value="" /></td>
                            <td style="vertical-align:top;">Password:  </td><td><input type="password" name="password" value="" /><br /><input type="submit" id="submit" value="Login" /></td>


and here is the code within the login.php where the form should post to


	$username = $_POST['username'];
$password = $_POST['password'];

// Help protect against MySQL injection
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);

// Selecting data from database where correct username and password are found
$sql="SELECT * FROM customer WHERE username='$username' and password='$password'";
$result=mysql_query($sql) or die(mysql_error());


i cant see anything wrong..been looking for hours...please please help me

Link to comment
Share on other sites

ive already tried that...it just produces the same error.


ive just stumbled upon something very strange.


i have 1 record in my database with the data in the username field as "kevin" and the data in the password field as "busby".


when i try to login by typing a bunch of randum letters...those values go to login.php and i can echo them out.


but if i type in the correct username and password...it doesnt post through to login.php


any suggestions?

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.