Jump to content

SQL database not updating?


Bobbycarver
Go to solution Solved by Bobbycarver,

Recommended Posts

im trying to make a script where the user can update there details, (in this case the email) but when the script is running it comes up sucess to say its worked and updated. however when i open up my database in notepad or sql workbench the email has not changed its still the same. any ideas what it could be? or maybe im reading my database info wrong?

 

CODE:

<?php
session_start();
$user_name = "root";
$password = "";
$database = "fixandrun";
$server = "localhost";



$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);


$currentemail = $_POST['currentemail'];
$newemail = $_POST['newemail'];
$confirmnew = $_POST['confirmemail'];
$user = $_SESSION["username"];

if ($db_found)
 {

$dbemail =mysql_query("SELECT email FROM staff WHERE username= '$user'");



//echo "$currentemail";
//echo "$newemail";
//echo "$confirmnew";
//echo "$dbemail";



        if($currentemail == $dbemail || $newemail == $confirmnew)
         {
		   $query = "UPDATE staff SET email = '$confirmnew' WHERE username = '$user'";
		
             
			 
			 if(mysql_query($query)){
              echo "updated";}
              else{
              echo "fail";}
		   
            
          }
         else
        {
         echo" some of your details are incorrect please try again. check that your current email is entered correctly and the new email matches.";
         }
 }
 else
{
print "Database NOT Found.";
mysql_close($db_handle);
}

?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.