<?php
$host="****SECRET*****"; // Host name
$username="****SECRET****"; // Mysql username
$password="****SECRET****"; // Mysql password
$db_name="****SECRET*****"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
//take the username and prevent SQL injections
$username = mysql_real_escape_string($username);
//variables for new/old passess
$newpass = $_POST['newpass'];
$confirmpass = $_POST['confirmpass'];
$id = $POST['id'];
//sure proof denies
$count = 0;
//Checks for the cookie
if (isset($_COOKIE["mycookie"])) {
$count = 1;
} else {
$count = 0;
}
// If result matched $myusername and $mypassword, table row must be 1 row
if ($count==1) {
setcookie('mycookie', 'Test mycookie', time()+3600*24);
//display all users
$display = mysql_query("SELECT * FROM members ORDER BY ID");
//begin the query
$sql = mysql_query("SELECT * FROM $tbl_name WHERE username = '".$username."' LIMIT 1");
//acutal shit
if (isset($_POST['password']))
{
//Prevent SQL injections
$username = mysql_real_escape_string($_POST['username']);
//Get MD5 hash of password
$password = sha256(md5(sha1(sha512(mysql_real_escape_string($_POST['password'])))));
//Check to see if username exists
$sql = ("SELECT * FROM $tbl_name WHERE password = '".$password."' ");
$result = mysql_query($sql);
if (mysql_num_rows($result) < 1) {
echo "That is not your current password";
} else {
if ($confirmpass==$newpass) {
$querynew = ("UPDATE $tbl_name SET password='$newpass' WHERE id='$session[id]'");
$resultnew = mysql_query($querynew) or die(mysql_error());
echo "Password changed!";
} else {
echo "Passwords Do not match!";
}
}
} else {
echo "Change your password";
}
echo "`
<html></html>
<a href='index.php'>Go Back</a>
<center>
<table>
<form action='change.php' method='post'>
<tr><td>Current Password:</td><td><input name='password' type='text' /></tr></td><br />
<tr><td>New Password:</td><td><input name='newpass' type='text' /></td></tr><br />
<tr><td>Confirm Password:</td><td><input name='confirmpass' type='text' /></td></tr><br />
<tr><td><input type='submit' value='Change Password' /></td></tr>
</table>
</form>
</center>
";
//html for display all users
echo "<center><table border='1'>
<tr>
<th>UserName</th>
<th>ID</th>
</tr>";
while($row = mysql_fetch_array($display))
{
echo "<tr>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['id'] . "</td>";
echo "</tr>";
}
echo "</table></center>";
} else {
echo "You do not have permissions on this page!";
}
?>
<?php
$host="******"; // Host name
$username="*****"; // Mysql username
$password="*****"; // Mysql password
$db_name="****"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
//take the username and prevent SQL injections
$username = mysql_real_escape_string($username);
//variables for new/old passess
$newpass = $_POST['newpass'];
$confirmpass = $_POST['confirmpass'];
//this is the password that will be changed!
$finalpass = sha1(md5(sha1(sha1($newpass))));
//sure proof denies unless has cookie
$count = 0;
//Checks for the cookie, or deny access
if (isset($_COOKIE["mycookie"])) {
$count = 1;
} else {
$count = 0;
}
//select id from table
$select = mysql_query("SELECT id FROM $tbl_name WHERE username = '.$username.' ");
//start session
session_start();
$_SESSION['id'] = $select['id']; //store the resulting id as a session variable
// If result matched $myusername and $mypassword, table row must be 1 row
// sets cookie if cookie is found
if ($count==1) {
setcookie('mycookie', 'Test mycookie', time()+3600*24);
echo "You may only change your password!";
//display all users
$display = mysql_query("SELECT * FROM members ORDER BY ID");
//begin the query
$sql = mysql_query("SELECT * FROM $tbl_name WHERE username = '".$username."' LIMIT 1");
//If password is set then check if correct
if (isset($_POST['password']))
{
//Prevent SQL injections
$username = mysql_real_escape_string($_POST['username']);
// UPDATE NEW PASSWORD with the same encryption as the database
$password = sha1(md5(sha1(sha1(mysql_real_escape_string($_POST['password'])))));
//Check to see if username exists
$sql = ("SELECT * FROM $tbl_name WHERE password = '".$password."' ");
$result = mysql_query($sql);
if (mysql_num_rows($result) < 1) {
echo "That is not your current password";
} else {
if ($confirmpass==$newpass) {
session_start();
$querynew = mysql_query("UPDATE $tbl_name SET password = '".$finalpass."' WHERE username = '".$username."' LIMIT 1"); // run the update query
echo "Password changed!";
} else {
echo "Passwords Do not match!";
}
}
} else {
echo "Change your password";
}
echo "
<a href='index.php'>Go Back</a>
<center>
<table>
<form action='change.php' method='post'>
<tr><td>Your Username:</td><td><input name='username' type='text' /></tr></td><br />
<tr><td>Current Password:</td><td><input name='password' type='text' /></tr></td><br />
<tr><td>New Password:</td><td><input name='newpass' type='text' /></td></tr><br />
<tr><td>Confirm Password:</td><td><input name='confirmpass' type='text' /></td></tr><br />
<tr><td><input type='submit' value='Change Password' /></td></tr>
</table>
</form>
</center>
";
//html for display all users
echo "<center><table border='1'>
<tr>
<th>UserName</th>
<th>ID</th>
</tr>";
while($row = mysql_fetch_array($display))
{
echo "<tr>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['id'] . "</td>";
echo "</tr>";
}
echo "</table></center>";
} else {
echo "You do not have permissions on this page!";
}
?>
if $username==$loggedinuser
{
password changed!
}
else
{
Cannot change another users password!
}
<?php
$host="******"; // Host name
$username="*****"; // Mysql username
$password="*****"; // Mysql password
$db_name="****"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
//take the username and prevent SQL injections
$username = mysql_real_escape_string($username);
//variables for new/old passess
$newpass = $_POST['newpass'];
$confirmpass = $_POST['confirmpass'];
//this is the password that will be changed!
$finalpass = sha1(md5(sha1(sha1($newpass))));
//sure proof denies unless has cookie
$count = 0;
//Checks for the cookie, or deny access
if (isset($_COOKIE["mycookie"])) {
$count = 1;
} else {
$count = 0;
}
//select id from table
$select = mysql_query("SELECT id FROM $tbl_name WHERE username = '.$username.' ");
//start session
session_start();
$_SESSION['id'] = $select['id']; //store the resulting id as a session variable
// If result matched $myusername and $mypassword, table row must be 1 row
// sets cookie if cookie is found
if ($count==1) {
setcookie('mycookie', 'Test mycookie', time()+3600*24);
echo "You may only change your password!";
//display all users
$display = mysql_query("SELECT * FROM members ORDER BY ID");
//begin the query
$sql = mysql_query("SELECT * FROM $tbl_name WHERE username = '".$username."' LIMIT 1");
//If password is set then check if correct
if (isset($_POST['password']))
{
//Prevent SQL injections
$username = mysql_real_escape_string($_POST['username']);
// UPDATE NEW PASSWORD with the same encryption as the database
$password = sha1(md5(sha1(sha1(mysql_real_escape_string($_POST['password'])))));
//Check to see if username exists
$sql = ("SELECT * FROM $tbl_name WHERE password = '".$password."' ");
$result = mysql_query($sql);
if (mysql_num_rows($result) < 1) {
echo "That is not your current password";
} else {
if ($confirmpass==$newpass) {
session_start();
$querynew = mysql_query("UPDATE $tbl_name SET password = '".$finalpass."' WHERE username = '".$username."' LIMIT 1"); // run the update query
echo "Password changed!";
} else {
echo "Passwords Do not match!";
}
}
} else {
echo "Change your password";
}
echo "
<a href='https://www.nextgenupdate.com/forums/'>Go Back</a>
<center>
<table>
<form action='change.php' method='post'>
<tr><td>Your Username:</td><td><input name='username' type='text' /></tr></td><br />
<tr><td>Current Password:</td><td><input name='password' type='text' /></tr></td><br />
<tr><td>New Password:</td><td><input name='newpass' type='text' /></td></tr><br />
<tr><td>Confirm Password:</td><td><input name='confirmpass' type='text' /></td></tr><br />
<tr><td><input type='submit' value='Change Password' /></td></tr>
</table>
</form>
</center>
";
//html for display all users
echo "<center><table border='1'>
<tr>
<th>UserName</th>
<th>ID</th>
</tr>";
while($row = mysql_fetch_array($display))
{
echo "<tr>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['id'] . "</td>";
echo "</tr>";
}
echo "</table></center>";
} else {
echo "You do not have permissions on this page!";
}
?>
if $username==$loggedinuser
{
password changed!
}
else
{
Cannot change another users password!
}
<?php
session_start();
// checks if either the username or user_id values are NOT set
if (!isset($_SESSION['username']) || !isset($_SESSION['user_id']))
{
header('Location: login_form.php'
; // redirect to login form
die(); // kill the script
}
else
{
// the following query will verify whether or not the username is also legitimate
$query = mysql_query('SELECT username FROM users WHERE user_id = ' . mysql_real_escape_string($_SESSION['user_id']));
if (mysql_num_rows($query) > 1 || mysql_num_rows($query) <= 0) // check if more than one, or less than one user exists
{
die('There has been an error, please return to the log in form'
;
}
else
{
$result = mysql_fetch_assoc($query);
if ($result['username'] != $_SESSION['username']) // check if the usernames match
{
die('There has been an error, please return to the log in form'
;
}
}
}
?>
<html>
<head>
<title>Change Your Password</title>
</head>
<body>
<form action="changepassword.php" method="post">
<label for="originalpassword">Current password:</label><input type="password" id="orginalpassword" name="originalpassword" />
<br />
<label for="newpassword">New password:</label><input type="password" id="newpassword" name="newpassword" />
<br />
<label for="confirmpassword">Confirm password:</label><input type="password" id="confirmpassword" name="confirmpassword" />
<br />
<input type="submit" name="submit" value="Change Password" />
</form>
</body>
</html>
<?php
session_start();
// first confirm whether or not the two passwords match
if ($_POST['newpassword'] != $_POST['confirmpassword'])
{
echo 'The passwords you entered don\'t match! Go back and try again!<meta http-equiv="refresh" content="3; url=newpasswordform.php">';
die();
}
// next, determine if the old password is correct
// note that you'll also need to apply whatever hashing functions you used to store the password originally, apply those functions in the line of code below:
$old_password = mysql_real_escape_string($_POST['originalpassword']);
// we'll then proceed to query the database, we'll select the password field from the users table where the user_id (stored in the session variable) matches
$query = mysql_query("SELECT password FROM users WHERE user_id=$_SESSION['user_id']");
// fetch the results of the query as an associative array:
$result = mysql_fetch_assoc($query);
// after that, compare the two passwords:
if ($old_password != $result['password'])
{
echo 'Your original password was incorrect! Go back and try again!<meta http-equiv="refresh" content="3; url=newpasswordform.php" />';
die();
}
// finally, we'll get to the point of actually making the change
// first, we'll prepare our new password, again, be sure to apply all proper hashing functions to the line of code below:
$new_password = mysql_real_escape_string($_POST['newpassword']);
// second, we will query: we update the users table to set the password equal to the new password, we'll only do this where the user_ids match, and we'll limit this to one update
$query = mysql_query("UPDATE users SET password='" . $new_password . "' WHERE user_id = " . $_SESSION['user_id'] . " LIMIT 1");
if ($query) // if the update is a success
{
echo 'Password successfully updated! You\'re now being redirected back to the index page!<meta http-equiv="refresh" content="3; url=index.php" />';
}
else // if the update fails
{
echo 'Failed to update!';
}
?>

PICHU.
mysql_query("UPDATE $tbl_name SET password='$newpass' WHERE id=$_SESSION['id'] LIMIT 1");
session_start();
$query = mysql_query("SELECT user_id, username, password FROM users WHERE username='$username'"); // get the data
$result = mysql_fetch_assoc($query); // fetch the array
// check for correct username and password
if ($username == $result['username'] && $password == $result['password'])
{
session_start(); // start the session
$_SESSION['username'] == $username; // store the username
$_SESSION['user_id'] == $result['user_id']; // store the user's ID
}
// This is BA
if (isset($_COOKIE["mycookie"])) {
$count = 1;
} else {
$count = 0;
}
// This is GOO
if (isset($_COOKIE["mycookie"]))
{
$count = 1;
}
else
{
$count = 0;
}
Copyright © 2026, NextGenUpdate.
All Rights Reserved.