I am new to PHP but I like to create a script that checks if an email is in my MySQL Database, the Database name is "Fily_Registrations"
, the table is "users" and the value is called "email"
. So basically if an the email "hi@all.com"
exists in my database and I call the php script like "http://path/to/php.php?email=hi@all.com"
it should echo out "YES"
if it don't exists it should echo out "NO"
.
This is how fare I am now, but it always echoes out "NO":
<?php
$email = $_GET["email"];
$DataBase = "Fily_Registrations";
mysql_connect("server", "username", "password") or die(mysql_error());
mysql_select_db($DataBase) or die(mysql_error());
$string = sprintf("SELECT '$DataBase' FROM users WHERE email = '$email'");
$query = msql_query($string);
if($query == false) {
echo("No");
} else {
echo("Yes");
}
?>
Does anyone know how to fix this?