Jump to content

Help with MySQLi


Go to solution Solved by Ch0cu3r,

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();
}
?>
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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