chris_rulez001 Posted June 14, 2007 Share Posted June 14, 2007 i have made my own add user script and i need some help with the password bit, i want to be able to check if confirm password is the same as password, and i would also like to check if the email has a @ symbol in it. my code: <?php $email = $_POST['email'] ; $first = $_POST['nameFirst'] ; $last = $_POST['nameLast'] ; $username = $_POST['username'] ; $password = $_POST['password'] ; $cpassword = $_POST['cpassword'] ; $age = $_POST['age'] ; $gender = $_POST['gender'] ; $ip=$_SERVER['REMOTE_ADDR']; if ($first == "") { echo "Error: You havent entered your first name<br/><br/>"; } elseif ($last == "") { echo "Error: You havent entered your last name<br/><br/>"; } elseif ($username == "") { echo "Error: You havent entered your username<br/><br/>"; } elseif ($password == "") { echo "Error: You havent entered your password<br/><br/>"; } elseif ($cpassword == $password") { echo "Error: You havent confirmed your password properly<br/><br/>"; } elseif ($email == "") { echo "Error: You havent entered your email<br/><br/>"; } elseif ($age == "" || $age < 13) { echo "Error: You must be 13 or over to join<br/><br/>"; } elseif ($age == "Age (e.g. 14)") { echo "Error: You havent entered your age<br/><br/>"; } elseif ($gender == "" || $gender != "Male" || $gender != "male" || $gender != "female" || $gender != "Female" ) { echo "Error: You havent entered your gender<br/><br/>"; } else { include ('includes/mysql_connect_users'); $mysqlinsert="INSERT INTO users(username, password, email, firstname, lastname, age, gender, ip)VALUES('$username', '$password', '$email', '$first', '$last', '$age', '$gender', '$ip')"; $result2=mysql_query($mysqlinsert); if($result2){ echo "<div align='center'><h4><strong><u>Write This Information Down</u></strong></h4><br/><br/>"; echo "<u><strong>Your Login Information</strong></u><br/><br/>"; echo "Your Registered Username:".$username."<br/><br/>"; echo "Your Registered Password:".$password."<br/><br/><br/>"; echo "<u><strong>Other Information</strong></u><br/><br/>"; echo "Your Registered Name Is:".$first. $last."<br/><br/>"; echo "Your Registered Email:".$email."<br/><br/>"; echo "Your Registered Age:".$age."<br/><br/>"; echo "Your Registered Gender:".$gender."<br/><br/><br/><br/>"; echo "You Are Successfully Registered,"; echo "Click <a href='index.php'>Here</a>"; echo "To Return To The Homepage"; } } ?> can someone help? Quote Link to comment https://forums.phpfreaks.com/topic/55564-help-with-add-user/ Share on other sites More sharing options...
joshi_v Posted June 14, 2007 Share Posted June 14, 2007 For password and confirm password checking u can use password===confirmpassword. For email checking you have to use some regular expression with the characters that u are expecting in email. Regards, Joshi Quote Link to comment https://forums.phpfreaks.com/topic/55564-help-with-add-user/#findComment-274517 Share on other sites More sharing options...
chris_rulez001 Posted June 14, 2007 Author Share Posted June 14, 2007 im sorry but i dont quite understand what you mean Quote Link to comment https://forums.phpfreaks.com/topic/55564-help-with-add-user/#findComment-274520 Share on other sites More sharing options...
Nhoj Posted June 14, 2007 Share Posted June 14, 2007 if (strpos($email, "@") === FALSE || strpos($email, ".") === FALSE) { echo 'Sorry, but you must enter a valid e-mail.'; } Quote Link to comment https://forums.phpfreaks.com/topic/55564-help-with-add-user/#findComment-274524 Share on other sites More sharing options...
chris_rulez001 Posted June 14, 2007 Author Share Posted June 14, 2007 thanks, what about the password bit? can you help me on that bit? Quote Link to comment https://forums.phpfreaks.com/topic/55564-help-with-add-user/#findComment-274530 Share on other sites More sharing options...
aniesh82 Posted June 14, 2007 Share Posted June 14, 2007 Please try with this line elseif ($cpassword != $password) print your error message Quote Link to comment https://forums.phpfreaks.com/topic/55564-help-with-add-user/#findComment-274539 Share on other sites More sharing options...
swoyercmk Posted June 14, 2007 Share Posted June 14, 2007 if you take note of your syntax highlighting in the code you posted above you'll probably notice something that could be part of the problem... You are missing a quotation mark - just to kind of help you find it easier. See what you find from there good luck Quote Link to comment https://forums.phpfreaks.com/topic/55564-help-with-add-user/#findComment-274543 Share on other sites More sharing options...
chris_rulez001 Posted June 14, 2007 Author Share Posted June 14, 2007 ok, thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/55564-help-with-add-user/#findComment-274549 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.