I have this code running on a XAMPP server, which connects to a database in db.php
.
<?php
require 'db.php';
session_start();
$first_name = $_SESSION['first_name'];
$last_name = $_SESSION['last_name'];
$email = $_SESSION['email'];
$active = $_SESSION['active'];
if(isset($_GET['email']) && !empty($_GET['email']) AND isset($_GET['hash']) && !empty($_GET['hash']))
{
$email = $mysqli->escape_string($_GET['email']);
$hash = $mysqli->escape_string($_GET['hash']);
$mysqli->query("SELECT * FROM users WHERE email='$email' AND hash='$hash' AND active='1'");
if (@@ROWCOUNT <> 1) {
$_SESSION['message'] = "Account has already been activated";
echo '<script type="text/javascript">
window.location = "/html/rtl/profile.php"
</script>';
}
}
I'm trying to use an if-statement in PHP to see whether my MySQL search returns results, but it's not working. How would I do this?
try this:
$query = $mysqli->query("SELECT * FROM users WHERE email='$email' AND hash='$hash' AND active='1'");
if($query->num_rows<>1) {
//Rest of the code
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.