Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php include("salt.php")?>
- <?php
- $username = "xxxxxxxx";
- $password = "xxxxxxxx";
- $hostname = "xxxxxxxx";
- // Connect to the database
- $connect = mysql_connect($hostname, $username, $password)
- or die("Sorry, the connection could not be established <br /> Please report this problem to the administrator if this continues");
- // Select a database
- $selected = mysql_select_db("xxxxxxxxxxxxxxxxxxxxx",$connect)
- or die("Sorry, the database could not be selected <br /> Please report this problem to the administrator if this continues");
- if(get_magic_quotes_gpc()) {
- $previousemail = stripslashes($_POST['previousemai']);
- $newemail = stripslashes($_POST['newemail']);
- $confirmemail = stripslashes($_POST['confirmemail']);
- $previouspassword = stripslashes($_POST['previouspassword']);
- $newpassword = stripslashes($_POST['newpassword']);
- $confirmpassword = stripslashes($_POST['confirmpassword']);
- } else {
- $previousemail = $_POST['previousemail'];
- $newemail = $_POST['newemail'];
- $confirmemail = $_POST['confirmemail'];
- $previouspassword = $_POST['previouspassword'];
- $newpassword = $_POST['newpassword'];
- $confirmpassword = $_POST['confirmpassword'];
- }
- $_POST['previousemail'] = mysql_real_escape_string($previousemail, $connect);
- $_POST['newemail'] = mysql_real_escape_string($newemail, $connect);
- $_POST['confirmemail'] = mysql_real_escape_string($confirmemail, $connect);
- $_POST['previouspassword'] = mysql_real_escape_string($peviouspassword, $connect);
- $_POST['newpassword'] = mysql_real_escape_string($newpassword, $connect);
- $_POST['confirmpassword'] = mysql_real_escape_string($confirmpassword, $connect);
- // Change email function
- function changeemail()
- {
- // Select query
- $emailquery = mysql_query("SELECT AES_DECRYPT('email','".SALT."') AS email FROM adminaccounts WHERE email='$previousemail'");
- $checkselect = mysql_num_rows($emailquery);
- // Check email matches records in MYSQL database
- if (!$checkselect) {
- die("Sorry the email you have entered does not match any records");
- }
- // Check if fields are empty and if emails match
- if ($_POST['previousemail']==NULL || $_POST['newemail']==NULL || $_POST['confirmemail']==NULL)
- {
- die("Sorry but you have not completed all of the email fields, please go back and make sure all fields are completed.");
- }
- elseif ($_POST['newemail']!=$_POST['confirmemail'])
- {
- die("Sorry but your emails do not match, please go back and make sure they match.");
- }
- else{
- // Update query
- $updatequery = mysql_query("UPDATE adminaccounts SET email=AES_ENCRYPT('$confirmemail','".SALT."') WHERE email='$previousemail'");
- }
- $num_rows = mysql_num_rows($updatequery);
- if(!updatequery) {
- die("Sorry but your email has not been changed, please go back to try again. If this problem continues please contact the administrator");
- }
- }
- // Change password function
- function changepassword()
- {
- $passwordquery = mysql_query("SELECT AES_DECRYPT('password','".SALT."') AS password FROM adminaccounts WHERE password='$previouspassword'");
- $checkselect = mysql_num_rows($passwordquery);
- // Check password matches records in MYSQL database
- if (!$checkselect) {
- die("Sorry the password you have entered does not match any records");
- }
- // Check if fields are empty and if passwords match
- if ($_POST['previouspassword']==NULL || $_POST['newpassword']==NULL || $_POST['confirmpassword']==NULL)
- {
- die("Sorry but you have not completed all of the password fields, please go back and make sure all fields are completed.");
- }
- elseif ($_POST['newpassword']!=$_POST['confirmpassword'])
- {
- die("Sorry but your passwords do not match, please go back and make sure they match.");
- }
- else{
- // Update query
- $passwordquery = mysql_query("UPDATE adminaccounts SET password=AES_ENCRYPT('$confirmpassword','".SALT."') WHERE password='$previouspassword'");
- }
- $num_rows = mysql_num_rows($passwordquery);
- if(!passwordquery) {
- die("Sorry but your password has not been changed, please go back to try again. If this problem continues please contact the administrator");
- }
- }
- // If changeemail button is pressed then call the changeemail function
- if (isset($_POST['changeemail'])) {
- changeemail();
- }
- // If changepassword button is pressed then call the changepassword function
- if (isset($_POST['changepassword'])) {
- changepassword();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement