homepage Welcome to WebmasterWorld Guest from 54.197.110.151
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
ethan89



 
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.

<?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

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