I'm trying to pull a three-character string from an SQL database and store it as a session, but it isn't working correctly.
Here is where I request the SQL query and set the session
$verified_query = mysql_query("SELECT verified FROM `members` WHERE username = '$myusername'");
$verified = mysql_result($verified_query, 0); // 0 is the index of the field, not the row
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
$_SESSION["myusername"] = $myusername;
$_SESSION["mypassword"] = $mypassword;
$_SESSION["verified"] = $verified;
header("location:index.php");
}
else {
echo "Wrong Username or Password";
}
?>
And here is where I try to get the session:
<?php
session_start();
if(!$_SESSION["myusername"]){
include("./assets/inc/nli-home.inc.php");
}
else {
include("./assets/inc/connect.inc.php");
include("./assets/inc/header.inc.php");
if ($_SESSION["verified"] == "no") {
include("./assets/inc/settings.inc.php");
}
else {
}
if ($_SESSION["verified"] == "yes") {
include("./assets/inc/settings-admin.inc.php");
}
else {}
include("./assets/inc/header2.inc.php");
include("./assets/inc/footer.inc.php");
}
?>
<script>console.log("<?php echo $_SESSION['verified'] ?>");</script>