0

I cannot figure out why this isn't working. Every time I run it, it automatically assigns to verified. Any ideas?

$verify = "SELECT verification_status 
    FROM users 
    WHERE username = '$username' ";
$result2 = $conn->query($verify);

if ($result2 == 'verified') {
    $_SESSION['verifiedstatus'] = 'verified';
} elseif ($result2 == 'pending') {
    $_SESSION['verifiedstatus'] = 'pending';
} elseif ($result2 == 'unverified') {
    $_SESSION['verifiedstatus'] = 'unverified';
}
SaidbakR
  • 13,303
  • 20
  • 101
  • 195
Blake Connally
  • 689
  • 1
  • 4
  • 16

1 Answers1

3

@Fred-ii- Please post your responses a an answer, they helped me get it fixed. It is working properly now after making some adjustments to iterate the query. Thank you. – Blake Connally

As OP's request.

You haven't iterated over the query.

A loop is required to do this, such as a while loop and checking if a row equals something.

You also seem to be learning (MySQL), therefore I suggest that you read up on SQL injection:

Since you may be querying from possible user input.

Community
  • 1
  • 1
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141