php - HOW DO I CHECK IF BOTH $_POST['name']=name AND $_POST['phone']=phone exist in a db row? -


if('select * users firstname='$_post['firstname']' ,  phone='$_post['phone']''){echo 'their match';} 

parse error: syntax error, unexpected t_variable

assuming you using object-oriented mysqli, code this:

$phone = ( isset( $_post['phone'] ) && !empty( $_post['phone'] ) ) ? $conn->real_escape_string( $_post['phone'] ) : null; $firstname = ( isset( $_post['firstname'] ) && !empty( $_post['firstname'] ) ) ? $conn->real_escape_string( $_post['firstname'] ) : null;  //create mysql query $sql = "select * users firstname='$firstname' , phone='$phone'";  $result = $conn->query($sql); //query database  if ($result->num_rows > 0) { //check if there results    echo "there match."; } else {    echo "no matches."; } 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -