Jump to content

Bobbycarver

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Bobbycarver

  1. solved. i wasnt reading the database correct. i created a new html page to print all my database and it was actually updating lol
  2. 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); } ?>
  3. Hi. im new to the site and i need a bit of help. im coding a website for my coursework and ive created a log in script. the script works but once the user has logged in i want to get a message saying welcome "firstname" instead of welcome "username" i have managed to get it to say welcome and there username but its not very formal i would like there name they use when they register. here is the code ive got so far. any help would be greatly appriciated. <?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); $username = $_POST["username"]; $password = $_POST["password"]; echo"$password"; echo"$username"; if ($db_found) { $result =mysql_query("SELECT 1 FROM staff WHERE username= '$username' and password= '$password'"); if ($result && mysql_num_rows($result) == 1) { $sqlq = mysql_query("SELECT firstname FROM staff WHERE username = '$username'"); $_SESSION['name']=$sqlq; session_register("username"); header("location:homelogged.php"); } else { Echo "Username or Password is incorrect. Click <a href='home.php'>Here</a> to be taken back to the home page."; } } else { print "Database NOT Found."; mysql_close($db_handle); } ?> and on my home page i have : <?php echo "Welcome " . $_SESSION["name"] . "<br>"; echo "last logged in at " . date("l, F d, h:i" ,time())."<br>"; ?> this works but i get welcome and 0 instead of welcome and a name
×
×
  • 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.