Kingy Posted January 31, 2008 Share Posted January 31, 2008 This is confusing the hell out of me... sorry for the long code <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); if($_POST['submit']) { $username = $_POST['username']; $password = $_POST['password']; $confirmpw = $_POST['confirmpw']; $firstname = $_POST['first']; $lastname = $_POST['last']; $email = $_POST['email']; $username = stripslashes($username); $password = stripslashes($password); $confirmpw = stripslashes($confirmpw); $firstname = stripslashes($firstname); $lastname = stripslashes($lastname); $email = stripslashes($email); if((!$username) || (!$password) || (!$confirmpw) || (!$email)) { echo "You didn't fill in all the correct fields. Please try again<BR />"; echo "Redirecting..."; exit(); } if($confirmpw != $password) { echo "Your passwords did not match. Please try again<BR />"; echo "Redirecting..."; exit(); } $emailcheck = mysql_query("SELECT email FROM users WHERE email='$email'"); $check = mysql_num_rows($emailcheck); if($emailcheck > 0) { echo "That email is already recorded as been in the database. Please try again<BR />"; echo "Redirecting..."; exit(); } $password = md5($password); $fullname = $firstname . ' ' . $lastname; $query = mysql_query("INSERT INTO users (username, password, fullname, email) VALUES ('$username', '$password', '$fullname', '$email')") or die(mysql_error()); if(!$query) { echo "There was a problem creating your account, please contact an Admin about this problem."; } else { echo "Your account creation was sucessful. You may now login."; echo "Redirecting..."; } } else { ?> <form method="POST" action="<?php echo $phpself; ?>"> Username: <input type='text' name='username'><BR /> Password: <input type='password' name='password'><BR /> Confirm Password: <input type='password' name='confirmpw'><BR /><BR /> First Name: <input type='text' name='first'><BR /> Last Name: <input type='text' name='last'><BR /> Email: <input type='text' name='email'><BR /> <input type='submit' value='submit' name='submit'> </form> <?php } ?> The error is... Notice: Undefined index: submit in C:\Inetpub\wwwroot\users\register.php on line 6 Quote Link to comment https://forums.phpfreaks.com/topic/88691-solved-undefined-index/ Share on other sites More sharing options...
rajivgonsalves Posted January 31, 2008 Share Posted January 31, 2008 this if($_POST['submit']) { should be if(isset($_POST['submit'])) { the error comes up because the first time the page shows up the $_POST['submit'] is not defined. Quote Link to comment https://forums.phpfreaks.com/topic/88691-solved-undefined-index/#findComment-454179 Share on other sites More sharing options...
Kingy Posted January 31, 2008 Author Share Posted January 31, 2008 ok that sorted that error cheers, im now getting the same error about the phpself ?? Quote Link to comment https://forums.phpfreaks.com/topic/88691-solved-undefined-index/#findComment-454180 Share on other sites More sharing options...
rajivgonsalves Posted January 31, 2008 Share Posted January 31, 2008 $phpself should be $_SERVER['PHP_SELF'] Quote Link to comment https://forums.phpfreaks.com/topic/88691-solved-undefined-index/#findComment-454184 Share on other sites More sharing options...
Kingy Posted January 31, 2008 Author Share Posted January 31, 2008 Thankyou Quote Link to comment https://forums.phpfreaks.com/topic/88691-solved-undefined-index/#findComment-454186 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.