homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

I can't get my change password PHP to work

Msg#: 4193642 posted 5:14 am on Aug 29, 2010 (gmt 0)

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.

if(!isset($_SESSION['username']) ||
(trim($_SESSION['username'])=='')) {
header("location: members_only_area.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";
$sql=mysql_query("UPDATE members SET password='$newpassword' where username='$username'");
echo "You have successfully changed your password.";
include "my_account.php";
echo "Your new password and new password confirmation values were different.";
include "my_account.php";



WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4193642 posted 7:57 pm on Aug 29, 2010 (gmt 0)

Did you echo out post?

foreach ($_POST as $key => $value) {
echo "k: $key v: $value<br>";

The only thing that could be happening is it's not in post, if it's finding your username.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved