i had created a form ! having
three text box
Old password
New password
Confim new password!!
it is being validated by javascript with the following fuction
The form code is as follow
according to action of the form on submission the below code is executed
it get the id,old password and new password
and execute the update query
if the old password is wrong or unmatched the query does not executes and password is not changed in the data base
i want to make check that if the query is not executed or the password is not changed due to unmatched old password than it should display
old password incorrect please correct it again
else it shows password changed successfully
my code simply show password changed successfully!! on both states!
i had used if else but not working
please help me
three text box
Old password
New password
Confim new password!!
it is being validated by javascript with the following fuction
Code:
<script language="javascript">
function checkempty(obj,msg){
if(obj.value==''){
alert(msg);
obj.focus()
return false;
}
return true;
}
function confirmpass(obj,obj1,msg){
if(obj1.value!=obj.value){
alert(msg);
obj1.select()
obj1.focus()
return false;
}
return true;
}
function chkChangePass(){
if(checkempty(document.frmChangePass.oPass,"Information: Enter Old Password")==false) return false;
if(checkempty(document.frmChangePass.NPass,"Information: Enter New Password")==false) return false;
if(checkempty(document.frmChangePass.CNPass,"Information: Confirm New Password")==false) return false;
if(confirmpass(document.frmChangePass.NPass,document.frmChangePass.CNPass,"Information: New and Confirm Password should be same")==false) return false;
return true;
}
</script>
Code:
<form name="frmChangePass" method="post" action="Changepass.php?action=Confirm&id=1" onSubmit="return chkChangePass();">
<table width="100%" border="0" cellspacing="2" cellpadding="1">
<tr bordercolor="#CCCCCC">
<td width="30%">Old Password:</td>
<td width="70%" align="left" valign="middle"><input name="oPass" type="password" onfocus="this.select();" value="<?php if(isset($_REQUEST["oPass"])){print $_REQUEST["oPass"];}?>" style="BORDER-WIDTH:1;BORDER-STYLE:dashed;border-color:000000;background:eeeeee;font-size:10px;color:000000;height:20;width:150" id="oPass" size="54" /></td>
</tr>
<tr bordercolor="#CCCCCC">
<td>New Password: </td>
<td align="left" valign="middle"><input name="NPass" type="password" onfocus="this.select();" value="<?php if(isset($_REQUEST["NPass"])){print $_REQUEST["NPass"];}?>" style="BORDER-WIDTH:1;BORDER-STYLE:dashed;border-color:000000;background:eeeeee;font-size:10px;color:000000;height:20;width:150" id="NPass" size="54" /></td>
</tr>
<tr bordercolor="#CCCCCC">
<td>Confirm New Password: </td>
<td align="left" valign="middle"><input name="CNPass" type="password" onfocus="this.select();" value="<?php if(isset($_REQUEST["CNPass"])){print $_REQUEST["CNPass"];}?>" style="BORDER-WIDTH:1;BORDER-STYLE:dashed;border-color:000000;background:eeeeee;font-size:10px;color:000000;height:20;width:150" id="CNPass" size="54" /></td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="<?php echo $rClr?>">
<td align="left" valign="middle" bordercolor="#CCCCCC" bgcolor="<?php echo $rClr?>" class="welcome"> </td>
<td align="left" valign="middle" bordercolor="#CCCCCC" bgcolor="<?php echo $rClr?>" class="Vkasimp"><input type="submit" name="Submit2" value="Change Pass" style="BORDER-WIDTH:1;BORDER-STYLE:double;border-color:000000;background:eeeeee;font-size:10px;color:000000;height:20;width:150" /></td>
</tr>
</table>
</form>
according to action of the form on submission the below code is executed
it get the id,old password and new password
and execute the update query
Code:
<?php }if($action=="Confirm"){
$id=$_GET['id'];
$oldpassword=$_POST['oPass'];
$CNpassword=$_POST['CNPass'];
$update= "Update `users` Set `user_pass`='$CNpassword' Where `campus_id`=1 AND `user_pass`='$oldpassword'";
$result=mysql_query($update) or die(mysql_error());
php echo "<strong>Password successfully changed</strong>";
}
if the old password is wrong or unmatched the query does not executes and password is not changed in the data base
i want to make check that if the query is not executed or the password is not changed due to unmatched old password than it should display
old password incorrect please correct it again
else it shows password changed successfully
my code simply show password changed successfully!! on both states!
i had used if else but not working
please help me
Comment