- Code: Select all
<?php
SESSION_START();
//WAMP Login Details
$host = "localhost";
$username="root";
$password="";
$db_name="database";
$tbl_name="members";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("Database doesn't exist.");
//When a user logs in on the login page it sets the session for Username
$username=$_SESSION['myusername'];
//This grabs the data from the form on the settings page and updates
$sql="UPDATE $tbl_name SET status='$status' WHERE username='$username'";
$result=mysql_query($sql);
//if true then redirect else echo error
if($result){
header("location:me.php");
}
else {
echo "ERROR";
}
?>
Now it seems to work fine the only problem is, is that it updates the field with an empty variable. Am I doing something wrong here? The column name is "status".

