exit; } if (md5($pwdInput . "sdshare") != $pwdNow) { return 'bad.原密码错误'; exit; } $pwdNew = md5($pwdNew . "sdshare"); $sql = "UPDATE `sd_users` SET `pwd` = '{$pwdNew}' WHERE `uid` = {$userId}"; mysqli_query($con, $sql); return 'ok.密码修改成功'; } switch ($action) { case 'login': print_r(userLogin($_POST['username'], $_POST['password'], $con)); break; case 'register': print_r(userReg($_POST['username-reg'], $_POST['password-reg'], $con)); break; case 'delshare': print_r(delShare($_POST['key'], $con, $userInfo['uid'])); break; case 'delshares': print_r(delShareS($_POST['key'], $con, $userInfo['uid'])); break; case 'changepwd': print_r(changePwd($_POST['pwd'], $con, $userInfo['pwd'], $_POST['pwdnow'], $userInfo['uid'])); break; default: # code... break; }
if (!$email) { header('Location: /vues/vue_lost-password.php?Error=emptyMail'); exit; } if ($action == 'Submit') { if ($id && $email) { try { $stmt = getAccountByIdAndMail($id, $email); } catch (PDOException $e) { header('Location: /vues/vue_lost-password.php?error=db'); exit; } if (!$stmt->rowCount()) { header('Location: /vues/vue_lost-password.php?error=noaccount'); exit; } try { $newPwd = randomPwd($id); $stmt = changePwd($id, $newPwd); } catch (PDOException $e) { header('Location: /vues/vue_lost-password.php?error=db'); exit; } $message = 'Voici votre nouveau mot de passe :' . "\n"; $message .= 'Nouveau mot de passe :' . $newPwd; $subject = 'Changement mot de passe ' . $id; mail($email, $subject, $message); header('Location: ../vues/vue_new-password-send.php?envoi=Success'); exit; } }
<?php require_once 'include.php'; $act = $_REQUEST['act']; //@$id=$_REQUEST['id']; @($recipients_id = $_REQUEST['recipients_id']); @($user_id = $_REQUEST['user_id']); if ($act == "register") { $mes = register(); } elseif ($act == "login") { $mes = login(); } elseif ($act == "userOut") { $mes = userOut(); } elseif ($act == "changePwd") { $mes = changePwd(); } elseif ($act == "addPackage") { $mes = addPackage(); } elseif ($act == "addRecipients") { $mes = addRecipients(); } elseif ($act == "delRecipients") { $mes = delRecipients($recipients_id, $user_id); } elseif ($act == "addOrder") { $mes = addOrder(); } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Welcome</title>
try { $id = $_SESSION['login']; $stmt = getPwdMail($id); $result = $stmt->fetch(PDO::FETCH_OBJ); if ($result !== false) { $email = $result->email; $passwordbd = $result->password; } else { header('Location: /vues/vue_change-password.php?error=db'); exit; } } catch (PDOException $e) { header('Location: /vues/vue_change-password.php?error=db'); exit; } if ($pwd !== $passwordbd) { header('Location: /vues/vue_change-password.php?error=incorrectpwd'); exit; } try { changePwd($id, $newpwd); } catch (PDOException $e) { header('Location: /vues/vue_change-password.php?error=db'); exit; } $message = 'Votre mot de passe à bien été changé' . "\n"; $subject = 'Changement mot de passe ' . $id; mail($email, $subject, $message); header('Location: ../vues/vue_new-password-send.php?envoi=Success'); exit; }