riceje7 Posted November 10, 2009 Share Posted November 10, 2009 can't figure out why it seems to not be passing data through post method. i'm going from login.hml, the first bit of code, to processlogin.php, the second bit if code. any help woud be great. thanks <html> <head> <title>Login Page</title> </head> <body> <br> <p><fieldset><legend align="center"><font face="helvetica" size="+2">Login</font></legend> <form action="processlogin.php" method="post" enctype="text/plain" name="login"> <center> Username: <input type="text" name="username" size="25" ><br><br> Password: <input type="password" name="password" size="25"><br> <input type="submit" name="submitlogin" value="Login"> </center> </form> </fieldset> </p> </body> </html> <?php $username = $_POST['username']; $password = $_POST['password']; $password = md5($password); $db = ""; $dbuser = ""; $dbpass = ""; $host = ""; $connect = mysql_connect($host, $dbuser, $dbpass) or die('Cannot connect to server'); mysql_select_db($db); ?> <html> <head> <title>Process Login</title> </head> <body> </body> </html> Link to comment https://forums.phpfreaks.com/topic/180999-solved-getting-undefined-index-notice/ Share on other sites More sharing options...
mrMarcus Posted November 10, 2009 Share Posted November 10, 2009 post the error .. we're not psychics. Link to comment https://forums.phpfreaks.com/topic/180999-solved-getting-undefined-index-notice/#findComment-954938 Share on other sites More sharing options...
mrMarcus Posted November 10, 2009 Share Posted November 10, 2009 and lose the enctype from the <form>, will solve your problem .. and while i'm at it, lose the <font> tags as they are deprecated. use proper closing on your <br /> and <input />. to shorten things up, just do: $password = md5 ($_POST['password']); and use mysql_real_escape_string() on your $_POST variables going to database: <?php $username = mysql_real_escape_string ($_POST['username']); $password = md5 ($_POST['password']); //etc... ?> Link to comment https://forums.phpfreaks.com/topic/180999-solved-getting-undefined-index-notice/#findComment-954941 Share on other sites More sharing options...
riceje7 Posted November 10, 2009 Author Share Posted November 10, 2009 here are the errors: Notice: Undefined index: username in /Volumes/coho/Users/ricej/Sites/nmd102/bio_project/processlogin.php on line 2 Notice: Undefined index: password in /Volumes/coho/Users/ricej/Sites/nmd102/bio_project/processlogin.php on line 3 Link to comment https://forums.phpfreaks.com/topic/180999-solved-getting-undefined-index-notice/#findComment-954943 Share on other sites More sharing options...
riceje7 Posted November 10, 2009 Author Share Posted November 10, 2009 thanks mrMarcus, seemed to work after i removed the enctype Link to comment https://forums.phpfreaks.com/topic/180999-solved-getting-undefined-index-notice/#findComment-954949 Share on other sites More sharing options...
mrMarcus Posted November 10, 2009 Share Posted November 10, 2009 and lose the enctype from the <form> ^it's not allowing you pass the $_POST variables. make this change to your processlogin.php script: <?php if (isset ($_POST['submitlogin'])): $username = mysql_real_escape_string ($_POST['username']); $password = md5 ($_POST['password']); $db = ""; $dbuser = ""; $dbpass = ""; $host = ""; $connect = mysql_connect($host, $dbuser, $dbpass) or die('Cannot connect to server'); mysql_select_db($db); ?> <html> <head> <title>Process Login</title> </head> <body> </body> </html> <?php endif; ?> Link to comment https://forums.phpfreaks.com/topic/180999-solved-getting-undefined-index-notice/#findComment-954950 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.