Janvier, I could really use some php help from you.
I could use a password changing script that asks to verify username, email address, and password.
I have this script that asks for username and pw, but I keep getting an error on it.
Code:
//Connection Infos
$account_odbc = odbc_connect($db_account,$db_sa,$db_sa_pw);
//Get Infos of existing Acc
$strSql="select * from Tbl_user where user_id='$pusername'";
$user_result=odbc_do($account_odbc,$strSql);
$result_query=odbc_fetch_row($user_result);
$pwdsql="select user_pwd from user_profile where user_id='$pusername'";
$pwd_result=odbc_do($account_odbc,$pwdsql);
$pwd_result_query=odbc_fetch_row($pwd_result);
if (odbc_result($pwd_result,2)=="$oldpw")
{
//Chicking for forbidden signs
if(!preg_match("/^[0-9a-zA-Z]{6,12}$/i", $_POST[newpw])) $errors[]="Your new password mustn't consist of other characters than 1-9 or A-Z!";
//Checkig Password-Characters
if(preg_match("/^[0-9]{6,12}$/i",$_POST[newpw])) $errors[]="Your new password must have at least one character form A-Z in it";
//Checking Password-length
if(strlen($_POST[newpw])<6) $errors[] = "Your password must have at least 6 characters";
if(strlen($_POST[newpw])>12) $errors[] = "Your password cannot have more than 12 characters";
//Checking if Passwords match to each other
if($_POST[newpw2]!=$_POST[newpw]) $errors[] = "Your new passwords aren't the same!";
//Errors
if(sizeof($errors)>0)
{
$errorStr .= "<br><font>";
$errorStr .= "Mistakes:";
foreach($errors as $error)
$errorStr .= "<li>$error</li>";
$errorStr .= "</font><br><br>";
}
else
{
$password=md5($_POST[newpw]);
$repasswd_query="UPDATE user_profile SET user_pwd='$password' WHERE user_id='$pusername'";
$repasswd_query2="UPDATE Tbl_user SET user_pwd='$pnewpwd2' WHERE user_id='$pusername'";
$dk_account_result=odbc_do($account_odbc,$repasswd_query);
$dk_account_result=odbc_do($account_odbc,$repasswd_query2);
odbc_close($account_odbc);
}
return $errorStr;
}
echo "$errorStr";
echo "<form action='index.php' method='post'><input type='submit' name='change' value='Back'></form>";
echo "<form action='index.php' method='post'><input type='submit' value='To Startpage'></form>";
?>