Jump to content

Help with MySQLi


Tom8001

Recommended Posts


// execute query
$count= $con->query("SELECT * FROM $tbl_name WHERE username='$username' AND password='$password'");

// check to make sure query did execute. If it did not then trigger error use mysqli::error to see why it failed
if(!$count)
{
trigger_error('Query error: ', $con->error);
}
else
{
// get result from query
$row = $count->fetch_array();

// output contents of $row
printf('<pre>%s</pre>', print_r($row, 1));

$_SESSION['loggedIn'] == true;

header("index.php");
}

//Admin user level
if($row['user_level'] == 1) {

$_SESSION['user_level'] == 1;

//Location admin
header("Location: admin.php");

exit();

} else if($row['user_level'] == -1) {

$_SESSION['user_level'] == -1;

$_SESSION['username'] == trim($_POST['username']);

//Location banned
header("Location: banned.php");

exit();
} if($_SESSION['loggedIn'] == true) {

//Location default user home page
header("index.php");
}

//Set default user
$_SESSION['loggedIn'] == true;
$_SESSION['user_level'] == 1;
$_SESSION['username'] == trim($_POST['username']);
header("Location: index.php");
exit();

//Kill unwanted session
} if(isset($_POST['killsession'])) {

session_start();
session_destroy();
echo "Session Destroyed.";
exit();
}
?>
Link to comment
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.