I am creating a verification code system, where a user receives an email with a code, they go to my website, input it, and if there code matches a code in the database table "verificationcodes", then they are redirected to another url. However so far, every code I input comes out as testsite.php?code=not matching. What am I doing wrong?
<?php 
if (isset($_POST['code-submit'])) {
require 'notseendatabasehandler.php';
$code = $_POST['code'];
//Checking for empty fields
if (empty($code)) {
  header("Location: testsite1.php?error=emptyfields");
  exit();
}
else {
  $sql = "SELECT codeNumber FROM verificationcodes;";
  $result = mysqli_query($conn, $sql);
  if ($result == $code) {
    header("Location: testsite2.php?code=success");
    exit();
  }
  else {
    header("Location:  testsite1.php?code=notmatching");
    exit();
  }
}
}
//Sending the user backwards if they entered incorrectly 
else {
  header("Location: homepage.php");
  exit(); 
}
 
    