Im relativly new to php and mysql...(2weeks to be exact), Im not even sure my code is the right way to be doing this, but im trying to make sure that the username and email entered on a diffrent form come from th same line in the database:
<?php
if ($_COOKIE["GLOBAL_ADMIN"] == "1") {
$display_block = "<p>You are the overall administrator.</p>";
} else {
//redirect back to login form if not authorized
echo "You don't appear to have permission to be here and are being redirected!";
sleep(10);//seconds to wait.
header("Location: gadmin.php");
exit;
}
$mysqli = mysqli_connect("host", "user", "pass", "db");
$rows = "SELECT * FROM users WHERE username = '$user' AND email = '$email'";
$result2 = mysqli_query($mysqli, $rows);
$user = $_POST["uname"];
$email = $_POST["email"];
if(mysqli_num_rows($result2) == 1 { <-----error here
if($_POST["permission"] == "User") {
$permission = 3;
$update = "UPDATE users SET user_lvl = '$permission' WHERE username = '$user' AND email = '$email'";
$result = mysqli_query($mysqli, $update);
$display = "'$user' is now a basic user!";
}else if($_POST["permission"] == "Site Admin") {
$permission = 2;
$update = "UPDATE users SET user_lvl = '$permission' WHERE username = '$user' AND email = '$email'";
$result = mysqli_query($mysqli, $update);
$display = "'$user' now has Site Administrator privileges!";
}else if($_POST["permission"] == "Global Admin") {
$permission = 1;
$update = "UPDATE users SET user_lvl = '$permission' WHERE username = '$user' AND email = '$email'";
$result = mysqli_query($mysqli, $update);
$display = "'$user' now has Global Administrator privileges!";
}else {
$display = "Please select a Permission's option.";
sleep(10);//seconds to wait..
header("Location: gadmin.php");
}
}else {
$display = "The username and e-mail address entered do not match!<br/>
Please make sure the username and e-mail address are correct and try again.";
}
?>
Above is the code minus the html. Iv highlighted where the error occurs, it started as a "Can't use function return value in write context" error but is now a parse error, can anyone help me please?
Thanks