Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once "/Configuration/config.php";
- if (isset($_SESSION['username'])) {
- header('Location: home.php');
- }
- /*Here you go you filthy old bandit! A small, simple yet functional password/email change script.*/
- if(isset($_POST['p_submit'])) {
- $password = $_POST['p_password']; // The Member's Current Password.
- $repassword = $_POST['p_repassword']; // The Member Must Confirm His Password.
- $nepassword = $_POST['p_nepassword']; // The Member's New Password.
- if(!empty($password) && !empty($repassword) && !empty($nepassword)) {
- if($password !== $repassword) {
- mysql_query("UPDATE users SET password='".md5($nepassword)."' WHERE id='".$_SESSION['username']."' ")
- echo "Password successfuly changed."
- } else { echo "The passwords don't match. Please try again!"; }
- } else { echo "Please fill in <b>all</b> fields."; }
- }
- if($_POST['e_submit']) {
- $epassword = $_POST['e_password'];
- $erepassword = $_POST['e_repassword'];
- $email = $_POST['email'];
- if(!empty($password) && !empty($repassword) && !empty($nepassword)) {
- if($password !== $repassword) {
- if(mysql_num_rows(mysql_query("SELECT * FROM users WHERE email='".$email."'")) > 0) {
- mysql_query("UPDATE users WHERE id='".$_SESSION['username']."'");
- echo "Email successfuly updated."
- } else { echo "Email is already being used. Please try with another one!"; }
- } else { echo "Passwords doesn't match. Please try again!"; }
- } else { echo "Please fill in <b>all</b> fields."; }
- }
- ?>
- <html>
- <body>
- <u>Password change.</u>
- <form action="settings.php" method="POST">
- <input type="text" name="password" placeholder="Your current password">
- <input type="text" name="repassword" placeholder="Retype your current password">
- <input type="text" name="nepassword" placeholder="Insert new password">
- <input type="submit" name="p_submit" value="Change password">
- </form><hr/>
- <u>Update email.</u>
- <form action="settings.php" method="POST">
- <input type="text" name="e_password" placeholder="Your current password">
- <input type="text" name="e_repassword" placeholder="Retype your current password">
- <input type="text" name="email" placeholder="Insert your new password">
- <input type="submit" name="e_submit" value="Change email">
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment