0% found this document useful (0 votes)
112 views10 pages

Change Log in

The document contains code for a password change form and script. The form allows a user to enter their current password, new password, and confirm new password. The script validates the passwords and, if valid, updates the user's password in the database. It redirects to a success page on success or displays an error on failure.

Uploaded by

Christine Bacud
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views10 pages

Change Log in

The document contains code for a password change form and script. The form allows a user to enter their current password, new password, and confirm new password. The script validates the passwords and, if valid, updates the user's password in the database. It redirects to a success page on success or displays an error on failure.

Uploaded by

Christine Bacud
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 10

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.

0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Password Changed Successfully</title>
</head>

<body>
<h1>Password Changes Successfully</h1>
<p>Your password has been changed successfully.</p>

</body>
</html>
success

<!DOCTYPE html >


<html><head>
<title>Transaction</title>
</head>

<style>
.form1 button {
position: inherit;
background: #0025ff;
z-index: 1;
max-width: 100%;
padding: 10px;
outline: 0;
border: 0;
width: 100%;
width-margin: 5px;
align-items: left;
justify-content: left;
}
.form1 a{
font-family: Poppins Bold;
outline: 0;
width: 100%;
border: 0;
margin: 0 0 15px;
padding: 5px;
box-sizing: border-box;
font-size: 24px;
color:#FFFFFF;
text-align:left;
}
.form1 label{
font-family: Poppins Bold;
outline: 0;
width: 100%;
border: 0;
margin: 0 0 15px;
padding: 15px;
box-sizing: border-box;
font-size: 24px;
}
.style2 {
font-size: 24px;
font-family: Georgia, "Times New Roman", Times, serif;
color: #FFFFFF;
}
.table {
position: fixed;
background: #00CCFF;
z-index: 1;
padding: 10px;
outline: 0;
border: 0;
margin: 5px;
}
.table a{
font-size: 24px;
font-family: Georgia, "Times New Roman", Times, serif;
color: black;
outline: 0;
width: 100%;
border: 0;
margin: 0 0 15px;
padding-top: 10px;
padding-bottom: 10px;
box-sizing: border-box;
text-align:left;
}
.style3 {
color: black;
}
body {
background-image: linear-gradient(rgba(255, 255, 255, 0.7), rgba(255, 255, 255,
0.7)), url("background.jpg");
background-repeat:no-repeat;
background-attachment: fixed;
background-position: center;
background-size:cover;
font-family: "Roboto", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
</style>
<body>
<div class="transaction-page">
<div class="form1">
<form method="post" action="dashboard_exec.php">
<button>
<div align="left">
<a href="transaction.php">Transactions</a>
<label><u><a href="dashboard.html">Reports</a></u></label>
<a href="#">Help</a>
<a href="#">Logout</a>
<label>Welcome!</label>
</button>
</div><br>
<div class="table">
<table width=520 height="50" border="0" cellspacing="0">
<tr>
<td>
<div align="left"><span class="style2">
<a href="#">Enrolled Subjects</a><br>
<a href="#">Class Absences</a><br><br>
<a href="#">Quarter Grades (Match Curriculum)</a><br>
<a href="#">Final Grades (Match Curriculum</a><br>
<a href="#">General Weighted Average (Match Curriculum)</a><br><br>
<a href="#">Quarter Grades (Ignore Curriculum)</a><br>
<a href="#">Final Grades (Ignore Curriculum</a><br>
<a href="#">General Weighted Average (Ignore Curriculum)</a>
</span> </div></td>
</tr>
</table>
</div>

</form></div>

</body>
</html>
reports

<?php
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve the form data
$currentPassword = $_POST["current_password"];
$newPassword = $_POST["new_password"];
$confirmPassword = $_POST["confirm_password"];

// Validate the form data (you can add more validation as per your
requirements)
if (empty($currentPassword) || empty($newPassword) || empty($confirmPassword))
{
$error = "Please fill in all fields.";
} elseif ($newPassword != $confirmPassword) {
$error = "New password and confirm password do not match.";
} else {
// Perform the password change logic here (e.g., update the users password
in the database)
// You can replace this with your own code to handle the password change
process

// Assuming you have a database connection, you can use something like:
try {
$pdo = new PDO("mysql:host=localhost; dbname=dbthoburn", "root",
" ");
$pdo->setAttribute(PDO::ATTR_EERMODE, PDO::ERRMODE_EXCEPTION);

session_start();
$loginId = $_SESSION["login_id"]; // Assuming you have a user ID
stored in session

// Check if he current password matches the one stored in the


database
$stmt = $pdo->prepare("SELECT * FROM tblstudents_login WHERE id =
:id");
$stmt->bindParam(":id", $loginId);
$stmt->execute();
$user = $stmt->fetch();

if ($user && password_verify($currentPassword,


$user['password'])) {
// Current password is correct, proceed with updating the
new password

// Hash the new password


$hashedNewPassword = password_hash($newPassword,
PASSWORD_DEFAULT);

// Update the user's password in the database


$sql = "UPDATE tblstudents_login SET password = :password WHERE login_id
= :id";
$stmt->bindParam(":password", $hashedNewPassword);
$stmt->bindParam(":id", $loginId);

if ($stmt->execute()) {
// Password changed successfully
header("Location: success.php");
exit;
} else {
// Error occurred while changing the password
$error = "An error occurred while changing your password. Please try
again later.";
}
} else {
// Current password is incorrect
$error = "Current password is incorrect.";
}
} catch (PDOException $e) {
echo "Database connection failed: " . $e->getMessage();
}
}
}
?>

eme-exec

<!DOCTYPE html >


<html><head>
<title>Dashboard</title>
</head>

<style>
.form1 button {
position: inherit;
background: #0025ff;
z-index: 1;
max-width: 100%;
padding: 10px;
outline: 0;
border: 0;
width: 100%;
width-margin: 5px;
align-items: left;
justify-content: left;
}
.form1 a{
font-family: Poppins Bold;
outline: 0;
width: 100%;
border: 0;
margin: 0 0 15px;
padding: 5px;
box-sizing: border-box;
font-size: 18px;
color:#FFFFFF;
text-align:left;
}
.style2 {
font-size: 24px;
font-family: Georgia, "Times New Roman", Times, serif;
color: #FFFFFF;
}
.table {
position: fixed;
background: #45c4fa;
z-index: 1;
padding: 10px;
outline: 0;
border: 0;
margin: 5px;
}
.style3 {
font-color: black;
}
</style>
<body>
<div class="transaction-page">
<div class="form1">
<form method="post" action="dashboard_exec.php">
<button>
<div align="left">
<a href="#" class="style3">Transactions</a>
<a href="#">Reports</a>
<a href="#">Help</a>
<a href="#">Logout</a>
<label>Welcome!</label>
</button>
</div><br>
<div class="table">
<table width=250 height="50" border="0" cellspacing="0">
<tr>
<td>
<div align="center"><span class="style2"><a href="#">Change
Password</a><br>
<a href="#">Student Profile</a></span> </div></td>
</tr>
</table>
</div>

</form></div>

</body>
</html>
eme.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../Grade_Viewer/dashboard.css" type="text/css" rel="stylesheet"/>
<title>Dashboard</title>
</head>

<body>
<div class="form1">
<form method="post" action="dashboard_exec.php">
<button>
<a href="transaction.php">Transactions</a>
<a href="#">Reports</a>
<a href="#">Help</a>
<a href="#">Logout</a>
<label>Welcome!</label>
</form>
</body>
</html>
dashboard

<?php
$conn_db = mysql_connect("localhost", "root", "") or die();
$sel_db = msyql_select_db("dbthoburn",$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 tblstudents_login where id='1'");
$chg_pwd1=msql_fech_array($chg_pwd);
$data_pwd=$chg_pwd1['password'];
if($data_pwd==$old_pass){
if($new_pass==$re_pass){
$updae_pwd=mysql_query("update users set password='$new_pass' where id='1'");
echo "<script>alert('Update Sucessfull');
window.loccation='dashboard.php'</script>";
}
else{
echo "<script>alert('Your new and Retype Password is not match');
window.location='dashboard.php'</script>";
}
}
else{
echo "<script>alert('Your Old Password is wrong');
window.location='dashboard.php'</script>";
}
}
?>
change password exec

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Change Password</title>
<link href="../Grade_Viewer/change_password.css" type="text/css" rel="stylesheet"/>
</head>

<body>
<?php
$conn_db = mysqli_connect("localhost", "root", "") or die(mysqli_connect_error());
$sel_db = mysqli_select_db($conn_db, "dbthoburn") or die(mysqli_error($conn_db));

if(isset($_POST['re_password']))
{
$old_pass = $_POST['old_pass'];
$new_pass = $_POST['new_pass'];
$re_pass = $_POST['re_pass'];
$chg_pwd = mysqli_query($conn_db, "SELECT * FROM tblstudents_login WHERE
loginId");

if($chg_pwd === false)


{
die("Error in SELECT query: " . mysqli_error($conn_db));
}

$chg_pwd1 = mysqli_fetch_array($chg_pwd);

if($chg_pwd1 === false)


{
die("No data found for the given ID.");
}

$data_pwd = $chg_pwd1['password'];

if($data_pwd == $old_pass)
{
if($new_pass == $re_pass)
{
$update_pwd = mysqli_query($conn_db, "UPDATE tblstudents_login SET
password='$new_pass' WHERE loginId");

if($update_pwd === false)


{
die("Error in UPDATE query: " . mysqli_error($conn_db));
}

echo "<script>alert('Update Successful');


window.location='dashboard.php'</script>";
}
else
{
echo "<script>alert('Your new and Retype Passwords do not match');
window.location='change_password.php'</script>";
}
}
else
{
echo "<script>alert('Your Old Password is wrong');
window.location='change_password.php'</script>";
}
}
?>

<!-- Rest of your HTML code -->


<div class="change-page">
<div class="form">
<form method="post">
<h2>Change Password</h2>
<label for="old_pass">Old Password</label>
<input name="old_pass" type="password" id="old_pass" required /><br
/><br />

<label for="new_pass">New Password</label>


<input name="new_pass" type="password" id="new_pass" required /><br
/><br />

<label for="re_pass">Confirm Password</label>


<input name="re_pass" type="password" id="re_pass" required /><br /><br
/>

<input type="submit" name="re_password" />


</form>
</div>
</div>
</body>
</html>
change pass .php

.change-page {
width: 360px;
padding: 0;
margin: auto;
}
.form {
position: relative;
z-index: 1;
background: #00CCFF;
max-width: 500px;
margin: 5 auto 100px;
margin-top: 50px;
padding: 20px;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
}
.form h2 {
text-align: center;
}
.form input{
font-family: "Roboto", sans-serif;
outline: 0;
background: #ffffff;
width: 100%;
border: 0;
margin: 0 0 15px;
padding: 15px;
box-sizing: border-box;
font-size: 14px;
}
.form button {
font-family: "Roboto", sans-serif;
text-transform: uppercase;
outline: 0;
background: #0025ff;
width: 100%;
border: 0;
padding: 15px;
color: #FFFFFF;
font-size: 14px;
-webkit-transition: all 0.3 ease;
transition: all 0.3 ease;
cursor: pointer;
}
.form label{
font-family: Poppins Bold;
outline: 0;
width: 100%;
border: 0;
margin: 0 0 15px;
padding: 15px;
box-sizing: border-box;
font-size: 18px;
color:black;
text-align:left;
}
.form button:hover,.form button:active,.form button:focus {
background: #00CCFF;
}
.form .message {
margin: 15px 0 0;
color: #E5D3B3;
font-size: 12px;
}
.form .message a {
color: #4B371C;
text-decoration: none;
}
.form .register-form {
display: none;
}
.container {
position: relative;
z-index: 1;
max-width: 300px;
margin: 0 auto;
}
.container:before, .container:after {
content: "";
display: block;
clear: both;
}
.container .info {
margin: 50px auto;
text-align: center;
}
.container .info h1 {
margin: 0 0 15px;
padding: 0;
font-size: 36px;
font-weight: 300;
color: #1a1a1a;
}
.container .info span {
color: #4d4d4d;
font-size: 12px;
}
.container .info span a {
color: #000000;
text-decoration: none;
}
.container .info span .fa {
color: #EF3B3A;
}

body {
background-image: linear-gradient(rgba(255, 255, 255, 0.8), rgba(255, 255, 255,
0.8)), url("background.jpg");
background-repeat:no-repeat;
background-attachment: fixed;
background-position: center;
background-size:cover;
font-family: "Roboto", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

change pass css

You might also like