Schlo_50 Posted September 26, 2006 Share Posted September 26, 2006 To add some validation to my register form, i thought it would be a good idea to make the end user re-enter their chosen password in order for it to be correct. But im not sure what the line of code would be to only allow the form to be submitted if the passwords match.<?php$self=$_SERVER['PHP_SELF'];$firstname=$_POST['first_name'];$surname=$_POST['sur_name'];$username=$_POST['user_name'];$password=$_POST['password'];$rpassword=$_POST['password'];?><center><form action="blah blah" method="post">First Name: <input type="text" name="first_name"><br>Last Name: <input type="text" name="sur_name"><br>Username: <input type="text" name="user_name"><br>Password: <input type="password" name="password"><br>Re-Password: <input type="password" name="password"><br><input type="Submit"></form></center><?php { $conn = mysql_connect( "localhost","username","password" ) or die( "Err:Conn" ); $rs = mysql_select_db( "dombar0_work", $conn ) or die( "Err:Db" ); $sql = "INSERT INTO users ( first_name,sur_name,user_name,password ) VALUES ( \"$firstname\",\"$surname\",\"$username\", password(\"$password\") )"; $rs = mysql_query( $sql, $conn ); if ($rs){ echo( "Details Added Successully $username" ); }} ?>I assume i need an if statement before the '$conn' line? Could someone give me the line that will check to see if the passwords match before connecting to the database please? Thanks guys! Quote Link to comment Share on other sites More sharing options...
trq Posted September 26, 2006 Share Posted September 26, 2006 [code=php:0]if ($password == $rpassword) { // connect and do insert}[/code] Quote Link to comment Share on other sites More sharing options...
alpine Posted September 26, 2006 Share Posted September 26, 2006 $password=$_POST['password'];$rpassword=$_POST['password'];You are also using the same post on both variables, it will always match..........rename the second password-field to rpassword or whatever and post declare it Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted September 26, 2006 Author Share Posted September 26, 2006 I noticed that after i posted it, lol I still need the line of code to validate the password and the re-entering of the password though. Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted September 26, 2006 Author Share Posted September 26, 2006 Sorry. Ignore that last post. Me and my chronic blindness. :P Quote Link to comment 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.