Hi,

i'm doing a validation of registration form, and i'm checking if there's the same username and email:

$query_verify_email = "SELECT * FROM alunos WHERE username ='".$username."' AND email_aluno='".$email."'";
        $result_verify_email = mysql_query($query_verify_user, $connect);
        
		//if the Query Failed ,similar to if($result_verify_email==false)
if (!$result_verify_email)

How do i do both checks separated?

Does the AND operator works, like:

$query_verify_user= "SELECT * FROM alunos WHERE username ='".$username."'";
        $result_verify_user = mysql_query($query_verify_email, $connect);

$query_verify_email = "SELECT * FROM alunos WHERE email_aluno='".$email."'";
        $result_verify_email = mysql_query($query_verify_email, $connect);

        
		//if the Query Failed ,similar to if($result_verify_email==false)
if (!$result_verify_user AND $result_verify_email)

Can someone help me?

Thank you,
PF2G

No the AND operator doesn't work like that it needs to be &&.

You are also missing the ! at the start of $result_verify_email in the if statement.

Why do you want to split into 2 queries anyway?

AND is for mysql syntax search operator basically in the where clause. but in your case you cannot use AND. && is what you need for logical comparisons
but in the case you want to separate the query in to syntax queries Isuggest you do this.

<?php
if(isset($username)){
$query_verify_user= "SELECT * FROM alunos WHERE username ='".$username."'";
        $result_verify_user = mysql_query($query_verify_email, $connect);
//verifying the query for the second time
if(isset($email)){
$query_verify_email = "SELECT * FROM alunos WHERE email_aluno='".$email."'";
        $result_verify_email = mysql_query($query_verify_email, $connect);
//flag for boolean
$comapareIdentical=false;
if($result_verify_email==$result_verify_user){
//what ever action you want goes here
$compareIdentical=true;
}
}}
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.