dean012 Posted November 28, 2013 Share Posted November 28, 2013 Notice: Undefined index: username in C:\Users\User\l\htdocs\register.php on line 12Notice: Undefined index: password in C:\Users\User\l\htdocs\register.php on line 13 <html> <body> <?php $connect=mysql_connect("localhost","root",""); $db_selected = mysql_select_db("users", $connect); if(isset($_POST['register'])){ $username= $_POST['username']; $password= $_POST['password']; if(!$username || !$password){ echo "One of the fields are empty"; }else{ $find_multiple=" SELECT username FROM registerion WHERE Username='$username' "; $run_multiple = mysql_query($find_multiple) or die (mysql_error()); $num_multiple= mysql_num_rows($run_multiple); if($num_multiple < 1){ $password= md5($password); mysql_query( "INSERT INTO `register` (`username`, `password`) VALUES ('".$username."', '".$password."')" ) or die(mysql_error()); echo "You have succesfully registered!"; }else{ echo "That username has already beed used" ; } } # endelse: empty password or username } # endif: registered ?> <head> <h1>Register</h1> <form action='' method='post'> username: <input type='text' name='username'/></br> password: <input type='password' name='password'/></br> <input type='submit' value='Register'name='register'/> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/284354-error-on-line-1213/ Share on other sites More sharing options...
Ch0cu3r Posted November 28, 2013 Share Posted November 28, 2013 That code looks ok to me. What is the output of printf('<pre>%s</pre>', print_r($_POST, true)); Quote Link to comment https://forums.phpfreaks.com/topic/284354-error-on-line-1213/#findComment-1460503 Share on other sites More sharing options...
jcbones Posted November 28, 2013 Share Posted November 28, 2013 Undefined = doesn't exist Index = array key Quote Link to comment https://forums.phpfreaks.com/topic/284354-error-on-line-1213/#findComment-1460520 Share on other sites More sharing options...
cyberRobot Posted November 28, 2013 Share Posted November 28, 2013 This probably isn't causing the issue, but the <head> and <body> tags are mixed up. Have you tried breaking the code down to the essentials to get the form working? For example, does the following work: <?php //REPORT ALL PHP ERRORS error_reporting(E_ALL); ini_set('display_errors', 1); if(isset($_POST['register'])){ printf('<pre>%s</pre>', print_r($_POST, true)); } ?> <html> <head> <title>Page Title Here</title> </head> <body> <h1>Register</h1> <form action='' method='post'> username: <input type='text' name='username'/></br> password: <input type='password' name='password'/></br> <input type='submit' value='Register'name='register'/> </form> </body> </html> If so, you can slowly add the other features until everything works. Quote Link to comment https://forums.phpfreaks.com/topic/284354-error-on-line-1213/#findComment-1460526 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.