Jump to content


Photo

Problem with update *SOLVED*


  • Please log in to reply
3 replies to this topic

#1 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 14 September 2006 - 02:53 PM

Hi guys, please check this script, if it won't take u long and tell me what am I doing wrong?
Actually, I want the password to be updated... Script gives NO error just doesn't update db. any help will be greatly appreciated. Thank you.

<?php
require ("config.php");
$query = "SELECT * FROM sec";
$result = mysql_query($query) or die("Error: " . mysql_error());
while($row = mysql_fetch_array($result))
$db_pass = $row['pass']; // password from db
?>
<?php
$pass = $_POST['pass']; // old password
$pass2 = $_POST['pass2']; // new pass 1
$pass3 = $_POST['pass3']; // new pass2 - confirm
if($pass != $db_pass){
  echo "Old Password is incorrect";
  exit();
  }
else if($pass2 != $pass3){
  echo "New Passwords didn't match";
  exit();
  }
else if(empty($pass2)){
  echo "Please enter the new password";
  exit();
  }
else{
$update = "UPDATE sec SET pass = '$pass2'";
if(!$update){
  die('Could not update: '.mysql_error());
  }
header ('location: edit_pass.php');
}
?>

I don't need your script, I'll try to write it myself

#2 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 14 September 2006 - 02:59 PM

Try:

<?php
require ("config.php");
$query = "SELECT * FROM sec";
$result = mysql_query($query) or die("Error: " . mysql_error());
while($row = mysql_fetch_array($result))
$db_pass = $row['pass']; // password from db
?>
<?php
$pass = $_POST['pass']; // old password
$pass2 = $_POST['pass2']; // new pass 1
$pass3 = $_POST['pass3']; // new pass2 - confirm
if($pass != $db_pass){
  echo "Old Password is incorrect";
  exit();
  }
else if($pass2 != $pass3){
  echo "New Passwords didn't match";
  exit();
  }
else if(empty($pass2)){
  echo "Please enter the new password";
  exit();
  }
else{
$update = "UPDATE sec SET pass = '$pass2'";
$result = mysql_query($update);
if(!$result){
  die('Could not update: '.mysql_error());
  } else {
header ('location: edit_pass.php');
}
}
?>


#3 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 14 September 2006 - 03:03 PM

GOD, that query is killing me! Hostfreak, Thanks freind  :)
I don't need your script, I'll try to write it myself

#4 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 14 September 2006 - 03:04 PM

No problem buddy, glad I could help.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users