Jump to content

SQL database not updating?


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
https://forums.phpfreaks.com/topic/275762-sql-database-not-updating/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.