Hello, i have a problem with changing the randomly generated password i made, i made a form and a script, and i had made a success login page, but i can't seem to figure out why it won't UPDATE the password, i tried lots of things, my script says it was successful, but it doesn't change it in the database... Yes there is connection and Yes sessions work...:
Login_success:
<?
session_start();
$_SESSION['members'] = "yes";
$_SESSION['username'];
$_SESSION['password'] = $password;
echo "<img src='dowsmallwhite.png'><br><img src='logo1.png'><br><img src='loggedin.png'><br>Welcome ". $_SESSION['name'] ."!
You have successfully logged on!<br /><br />";
echo "You can now go to the <a href='memberpage.php'>member page</a>!<br>Go<a href='javascript:history.go(-1)'> Back!</a> <br />";
echo "<br /><a href='changepw.php'>Change Password</a><br><a href='logout.php'>Logout</a>";
?>
Changepw.php (the form itself)
<?
session_start();
$_SESSION['password'];
$_SESSION['username'];
?>
<HTML>
<HEAD>
<TITLE>Login</TITLE>
</HEAD>
<BODY>
<p><img src="dowsmallwhite.png" width="300" height="100"></p>
<p><img src="changepass.png" width="250" height="100"> </p>
<FORM METHOD="post" ACTION="changepass.php">
<P><STRONG>New Password:</STRONG><BR>
<INPUT NAME="new_pass" TYPE="text" id="new_pass" SIZE=25 MAXLENGTH=25></p>
<P><STRONG>Confirm New Password:</STRONG><BR>
<INPUT NAME="conf_new_pass" TYPE="password" id="conf_new_pass" SIZE=25 MAXLENGTH=25>
</p>
<P><INPUT TYPE="SUBMIT" NAME="submit" VALUE="Change password!"></P>
</FORM>
<a href="forgotpass.htm">Forgot your password?</a><br>
<a href="show_adduser.html"><img src="registersmall.png" width="200" height="70" border="0"></a>
</BODY>
</HTML>
Heres the script to Changepw, ChangePAss.php
<?
session_start();
include 'db.php';
$new1 = $new_pass;
$conf = $conf_new_pass;
$usernam = $_SESSION['username'];
if($new1==$conf){
$sql = "UPDATE users SET password='$new1' WHERE username='$usernam'";
$result = @mysql_query($sql,$connection) or die("Couldn't execute query!");
echo"Your password has been changed successfully! Click <a href='memberpage.php'>here</a> to go to memberspage!";
} else {
echo "Passwords don't match:";
include 'changepw.php';
}
?>
The problem i think lies in the query stuff... the sql data and the
if statement that makes the UPDATE to mysql
Thanks for your time, please reply ASAP!🙂