Im trying to creat a password varification system where the user enters there password twice while making a user account but everytime the user enters there password it is telling them
'sorry, passwords dont match'

Im trying to say if there are two input boxes in the first one they enter the password in the seccond one they reenter there password... if they are the same it inputs the user name + password in the mysql database(i dont have the database code in the example) this is the statement I am using to test if the password varification is working... and this code always says that the passwords dont add up xD.

if($password == $repassword) {
						header('Location: login.php');
			  			exit;
				} else {
						$errorMessage = 'sorry, passwords dont match';
				}

try this:

if($password == $repassword) {
header('Location: login.php');
} else {
echo 'sorry, passwords dont match';
}

or could you post your whole code for better understanding.

the code for inputing the user into the database hasnt been added yet

<?php
session_start();
	
	$errorMessage = '';
	if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {
	   	$host=""; 
		$username="; 
		$password=""; 
		$db_name=""; 
		$tbl_name="";
		
		mysql_connect("$host", "$username", "$password")or die("cannot connect");
		mysql_select_db("$db_name")or die("cannot select DB");
	
	   	$userId = $_POST['txtUserId'];
	   	$password = $_POST['txtPassword'];
		$repassword = $_POST['txtRePassword'];
	
	   	$sql = "SELECT user_id FROM $tbl_name WHERE user_id = '$userId'";
	
	   	$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
	
		if (mysql_num_rows($result) == 1) {
			  	$errorMessage = 'Sorry, username already used' & $password & $repassword;
		} else {
			  	if($password != $repassword) {
						$errorMessage = 'sorry, passwords dont match';
				} else {
						header('Location: login.php');
			  			exit;	
				}
		}
	}
	mysql_close();
?>
<html >
<head>
</head>
<body>
	<?php
    		if($errorMessage !='') {
  	?>
    		<p align="center"><strong><font color="#FF0000"><?php echo $errorMessage; ?></font></strong></p>
    	<?php
    		}
    	?>
    	<form method="post" name="frmLogin" id="frmLogin">
    		<table width="600" border="0" align="center" cellpadding="2" cellspacing="0">
        		<tr>
            			<td width="150">User Id</td>
                		<td><input name="txtUserId" type="text" id="txtUserId"></td>
            		</tr>
            		<tr>
            			<td width="150">Password</td>
                		<td><input name="txtPassword" type="text" id="txtPassword"></td>
            		</tr>
	    		<tr>
				<td width="150">re-enter password</td>
				<td><input name="txtRePassword" type="text" id="txtRePassword"></td>
	    		</tr>
            		<tr>
            			<td width="150">&nbsp;</td>
                		<td><input name="cmdDone" type="image" src="images/Button/done button.gif"></td>
            		</tr>
        	</table>
    	</form>
</body>
</html>

hope this helps helping me this is my 4th day doing web design

please can u post the program tht works i mean the same program with ur additions

This question has already been answered. Start a new discussion instead.