<body class="bg-dark"> <div class="container"> <div class="card card-login mx-auto mt-5"> <div class="card-header">Change Password</div> <div class="card-body"> <form method="post" action="change-password.php"> <div class="form-group"> <label for="username">Username</label> <input class="form-control" id="username" type="text" name="username" aria-describedby="nameHelp" placeholder="Enter username" required> </div> <div class="form-group"> <label for="New Password">New Password</label> <input class="form-control" id="newpass" type="text" name="newpass" placeholder="Enter new password" required> </div> <div class="form-group"> <label for="Confirm Password">Confirm Password</label> <input class="form-control" id="confpass" type="text" name="confpass" placeholder="Enter confirm password" required> </div> <div class="form-group"> <div class="form-check"> <label class="form-check-label"> <input class="form-check-input" type="checkbox"> Remember Password</label> </div> </div> <div class="form-group"> <button type="submit" name="submit" class="btn">Submit</button> <br> </div> </form> <div class="text-center"> <a class="d-block small mt-3" href="login.php">Login</a> </div> </div> </div> </div> <?php
$con=mysqli_connect("localhost","root","","goods_management_system") or die(mysqli_error());
$db=mysqli_select_db($con, 'goods_management_system' ) or die(mysqli_error());
if(isset($_POST['submit'])){
$username=$_POST['username'];
$newpass = $_POST['newpass'];
$confpass = $_POST['confpass'];
$query = "SELECT username FROM user_details WHERE username='$username'";
$run = mysqli_query($con, $query);
$row = mysqli_fetch_row($run);
if($row['username']==$username)// UNDEFINED. WHY IS THAT SO ?
{
if($newpass == confpass)
{
$update_query = "UPDATE user_details SET password='$newpass' WHERE username='$username'";
if($update_query)
{
echo "<script>alert('Password change successfully')</script>";
}
else
{
"<script>alert('Password change failed')</script>";
}
}
else
{
echo "<script>alert('password doesnt match')</script>";
}
}
}
?>
Subashan 0 Newbie Poster
rproffitt 2,662 "Nothing to see here." Moderator
xrjf 213 Posting Whiz
alan.davies 185 What's this?
afaaro 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.