How can I put condition on date?

if(isset($_POST[‘register’])) {

$uname = clean($_POST['username']); 
$pword = clean($_POST['password']); 
$studno = clean($_POST['studentno']); 
$fname = clean($_POST['firstname']); 
$lname = clean($_POST['lastname']); 
$section = clean($_POST['section']); 
$status = clean($_POST['status']); 


$query = "SELECT username FROM students WHERE username = '$uname' && date_joined= NOW()";
$result = mysqli_query($con,$query);

if(mysqli_num_rows($result) == 0) {

  $query = "SELECT studentno FROM students WHERE studentno = '$studno'";
  $result = mysqli_query($con,$query);

  if(mysqli_num_rows($result) == 0) {

    $query = "INSERT INTO students (username, password, studentno, firstname, lastname, section, status, date_joined)
    VALUES ('$uname', '$pword', '$studno', '$fname', '$lname', '$section', '$status ',NOW())";

    if(mysqli_query($con, $query)) {

      $_SESSION['prompt'] = "Account registered. You can now log in.";
      header("location:index.php");
      exit;

    } else {

      die("Error with the query");

    }

  } else {

    $_SESSION['errprompt'] = "That student number already exists.";

  }

} else {

  $_SESSION['errprompt'] = "Username already exists.";

}

}

?>


> Blockquote
  $query = "SELECT username FROM students WHERE username = '$uname' && date_joined= NOW()"; // 
![date|690x219](upload://5K3e65cnqdYR4E7jETlOAaN4nvp.png) this is my datebase...

Try AND instead of &&


Unrelated, but if you want to up your game, I’d strongly advise looking into PDO and prepared statements. Your current code, as is, isn’t safe to work with.

You can read through PHPDelusions if you’re interested :slight_smile: