supergrame Posted March 15, 2009 Share Posted March 15, 2009 here is login.php <?php require_once("db_connect.php"); $username = $_POST['username']; $password = $_POST['password']; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT * FROM users WHERE username='$username' and password='$password'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ session_register("username"); session_register("password"); header('Location: http://www.google.com'); } else {$login_error="Wrong Username or Password"; } ?> <html> <link href="css/style.css" rel="stylesheet" type="text/css" /> <head> <title>Login.php</title> </head> <body> <div id="login"> <form method="post" action=""> <table> <tr> <td colspan="2" align="center"><?php echo "$login_error";?><br>Login or Register!</td> <td></td> </tr> <tr> <td><label for="username">Username:</label></td> <td><input type="text" name="username"/></td> </tr> <tr> <td><label for="password">Password:</label></td> <td><input type="password" name="password"/></td> </tr> <tr> <td><input type="submit" id="submit" value="Login" name="submit" /></td> </tr> </table> </form> </div> </body> </html> Here is the error's Notice: Undefined index: username in C:\wamp\www\public\includes\login.php on line 7 Notice: Undefined index: password in C:\wamp\www\public\includes\login.php on line 8 Link to comment https://forums.phpfreaks.com/topic/149473-solved-getting-var-unset-error-i-think-its-becuase-the-form-action-is-itsself-help/ Share on other sites More sharing options...
.josh Posted March 15, 2009 Share Posted March 15, 2009 Wrap the top part of your code in an if($_POST) {...} Link to comment https://forums.phpfreaks.com/topic/149473-solved-getting-var-unset-error-i-think-its-becuase-the-form-action-is-itsself-help/#findComment-784994 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.