homepage Welcome to WebmasterWorld Guest from 54.242.233.11
register, login, search, subscribe, help, library, PubCon, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library : Charter : Moderators: coopster & eelixduppy & jatar k

PHP Server Side Scripting Forum

    
I can't get my change password PHP to work
ethan89




msg:4193644
 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.

<?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";
}
?>

 

rocknbil




msg:4193809
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
WebmasterWorld ® and PubCon ® are a Registered Trademarks of Pubcon Inc.
© Pubcon Inc. 1996-2012 all rights reserved