Author Topic: Mysql update information problem!  (Read 1375 times)

0 Members and 1 Guest are viewing this topic.

Offline benflaTopic starter

  • Irregular
  • Posts: 1
    • View Profile
    • http://www.cruddycartoons.com
Mysql update information problem!
« on: May 17, 2003, 07:22:35 PM »
hi, I read the mysql tutorial on how to make it so you can have members on your site, but the password was randomly made and given to you so I decided to make a form so you can change your password the only problem is when I submit it it doesnt give me any errors, but it also doesnt update the information
heres the code I\'m using now:
Code: [Select]
<?php

include \'db.php\';

if(!$yourusername){

  echo "user name is a required field. Please enter it below.<br />";

}

if(!$newpassword){

  echo "new password is a required field. Please enter it below.<br />";

}

if(!$currentpass){

  echo "current password is a required field. Please enter it below.<br/>";

}

include \'newpassword.html\';

exit();



if ($newpassword = $checkpassword){

} else {

echo \'Your new password does not match!\';

exit();

}

$encodedcurrentpass = md5($currentpass);

$encodednewpassword = md5($newpassword);

($sql = mysql_query("UPDATE users SET password=\'$encodednewpassword\' WHERE username=\'$yourusername\' AND password=\'$encodedcurrentpass\'"));

if (!$sql) {

echo \'Your password hasnt been changed! there was an error changing your password\';

} else {

echo \'Your password has been changed!\';

}

?>

Im sorta new to this so i dont know whats wrong
if you could help me I would really appreciate it.                    
The mighty cow Says "MOO"

Offline biopv

  • Enthusiast
  • Posts: 267
    • View Profile
    • http://palle.retrosearch.dk
Mysql update information problem!
« Reply #1 on: May 19, 2003, 03:32:50 AM »
Try...

Code: [Select]

$command = "UPDATE users SET password=\'$encodednewpassword\' WHERE username=\'$yourusername\' AND password=\'$encodedcurrentpass\';";



echo $command;

$sql = mysql_query($command);



if (!$sql....)



P.                    
Palle Villesen, www.birc.dkBioinformatics Research Center