Reply
Change password script
Old 09-23-2004, 07:32 PM
Average Talker

Posts: 16
You might discover you have a possible problem with this piece of your code...

PHP Code:
if($newpassword=$confirmnewpassword
you need to use 2 ='s when testing validity, using 1 will always result in a true

ie
PHP Code:
$var1 "yes";
$var2 "no";

if (
$var1 $var2// says "make $var1 equal to $var2" and will result in $var1 now being "no"

if ($var1 == $var2// says "is $var1 equal to $var2?"  this would result in FALSE 
clear?

Lite...
litebearer is offline
Reply With Quote
View Public Profile
 
Old 09-25-2007, 05:45 AM Re: Change password script
Junior Talker

Posts: 2
Name: Tharanga
Quote:
Originally Posted by rungss View Post
I think this should work

<?php
$connection=mysql_connect("localhost","USERNAME"," PASSWORD");
$db=mysql_select_db("DATABASENAME",$connection);
$result = mysql_query("select password from passwordtable where username=$_POST['username']");
if(!$result)
{
echo "oops! The Username you entered does not exist";
}
else
if($_POST['password']!= mysql_result($result, 0))
{
echo "You entered an incorrect password";
}
else if($_POST['newpassword']!=$_POST['confirmnewpasssword'])
{
echo "The new password and confirm new password fields must be the same";
}
else
$sql=mysql_query(UPDATE passwordtable SET password=$_POST['newpassword'] where username=$_POST['username']);
if($sql)
{
echo "Congratulations You have successfully changed your password";
}
?>
Dude yor Script was ok but there are some systax error.
1. $result = mysql_query("select password from auth_users where username='$_POST[username]'");

2. $sql=mysql_query("UPDATE auth_users SET password='$_POST[newpassword]' where username='$_POST[username]'");


thats it.... Then this code will work..100% working
tharangasp is offline
Reply With Quote
View Public Profile
 
Old 09-25-2007, 05:45 AM Re: Change password script
Junior Talker

Posts: 2
Name: Tharanga
Quote:
Originally Posted by rungss View Post
I think this should work

<?php
$connection=mysql_connect("localhost","USERNAME"," PASSWORD");
$db=mysql_select_db("DATABASENAME",$connection);
$result = mysql_query("select password from passwordtable where username=$_POST['username']");
if(!$result)
{
echo "oops! The Username you entered does not exist";
}
else
if($_POST['password']!= mysql_result($result, 0))
{
echo "You entered an incorrect password";
}
else if($_POST['newpassword']!=$_POST['confirmnewpasssword'])
{
echo "The new password and confirm new password fields must be the same";
}
else
$sql=mysql_query(UPDATE passwordtable SET password=$_POST['newpassword'] where username=$_POST['username']);
if($sql)
{
echo "Congratulations You have successfully changed your password";
}
?>
Dude your Script was ok but there are some systax errors.
1. $result = mysql_query("select password from auth_users where username='$_POST[username]'");

2. $sql=mysql_query("UPDATE auth_users SET password='$_POST[newpassword]' where username='$_POST[username]'");


thats it.... Then this code will work..100% working
tharangasp is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Change password script

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13023 seconds with 12 queries