Every time I use this PHP script to change my password, all it does is change my password to nothing (blank). What is wrong with my PHP? Thank you very much for the help.
<?php
session_start();
if(!isset($_SESSION['username']) ||
(trim($_SESSION['username'])=='')) {
header("location: members_only_area.php");
exit();
}
?>
<?php
$dbhost = ""; //I erased these on purpose. These 4 things are correct
$dbname = "";
$dbuser = "";
$dbpass = "";
mysql_connect ($dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$username = $_SESSION['username'];
$password = $_POST['password'];
$newpassword = $_POST['newpassword'];
$confirmnewpassword = $_POST['confirmnewpassword'];
$result = mysql_query("SELECT password FROM members WHERE username='$username'");
if($password!=mysql_result($result, 0))
{
echo "The password you entered was incorrect.";
include "my_account.php";
}
if($newpassword==$confirmnewpassword)
$sql=mysql_query("UPDATE members SET password='$newpassword' where username='$username'");
if($sql)
{
echo "You have successfully changed your password.";
include "my_account.php";
}
else
{
echo "Your new password and new password confirmation values were different.";
include "my_account.php";
}
?>