<style type="text/css"> fieldset { width:500px; border:5px dashed #CCCCCC; margin:0 auto; border-radius:5px; } legend { color: blue; font-size: 25px; } dl { float: right; width: 390px; } dt { width: 180px; color: brown; font-size: 19px; } dd { width:200px; float:left; } dd input { width: 200px; border: 2px dashed #DDD; font-size: 15px; text-indent: 5px; height: 28px; } .btn { color: #fff; background-color: dimgrey; height: 38px; border: 2px solid #CCC; border-radius: 10px; float: right; } </style>
<fieldset> <form method="post"> <dl> <dt> Old Password </dt> <dd> <input type="password" name="old_pass" placeholder="Old Password..." value="" required /> </dd> </dl> <dl> <dt> New Password </dt> <dd> <input type="password" name="new_pass" placeholder="New Password..." value="" required /> </dd> </dl> <dl> <dt> Retype New Password </dt> <dd> <input type="password" name="re_pass" placeholder="Retype New Password..." value="" required /> </dd> </dl> <p align="center"> <input type="submit" class="btn" value="Reset Password" name="re_password" /> </p> </form> </fieldset>
<?php { $old_pass=$_POST['old_pass']; $new_pass=$_POST['new_pass']; $re_pass=$_POST['re_pass']; $data_pwd=$chg_pwd1['password']; if($data_pwd==$old_pass){ if($new_pass==$re_pass){ echo "<script>alert('Update Sucessfully'); window.location='index.php'</script>"; } else{ echo "<script>alert('Your new and Retype Password is not match'); window.location='index.php'</script>"; } } else { echo "<script>alert('Your old password is wrong'); window.location='index.php'</script>"; }} ?>
<!DOCTYPE html> <html> <head> <style type="text/css"> fieldset { width:500px; border:5px dashed #CCCCCC; margin:0 auto; border-radius:5px; } legend { color: blue; font-size: 25px; } dl { float: right; width: 390px; } dt { width: 180px; color: brown; font-size: 19px; } dd { width:200px; float:left; } dd input { width: 200px; border: 2px dashed #DDD; font-size: 15px; text-indent: 5px; height: 28px; } .btn { color: #fff; background-color: dimgrey; height: 38px; border: 2px solid #CCC; border-radius: 10px; float: right; } </style> </head> <body> <fieldset> <?php $conn_db = mysql_connect("localhost","root","") or die(); $sel_db = mysql_select_db("change_password",$conn_db) or die(); if(isset($_POST['re_password'])) { $old_pass=$_POST['old_pass']; $new_pass=$_POST['new_pass']; $re_pass=$_POST['re_pass']; $chg_pwd=mysql_query("select * from users where id='1'"); $chg_pwd1=mysql_fetch_array($chg_pwd); $data_pwd=$chg_pwd1['password']; if($data_pwd==$old_pass){ if($new_pass==$re_pass){ $update_pwd=mysql_query("update users set password='$new_pass' where id='1'"); echo "<script>alert('Update Sucessfully'); window.location='index.php'</script>"; } else{ } } else { }} ?> <form method="post"> <dl> <dt> Old Password </dt> <dd> <input type="password" name="old_pass" placeholder="Old Password..." value="" required /> </dd> </dl> <dl> <dt> New Password </dt> <dd> <input type="password" name="new_pass" placeholder="New Password..." value="" required /> </dd> </dl> <dl> <dt> Retype New Password </dt> <dd> <input type="password" name="re_pass" placeholder="Retype New Password..." value="" required /> </dd> </dl> <p align="center"> <input type="submit" class="btn" value="Reset Password" name="re_password" /> </p> </form> </fieldset> </body> </html>
Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.