This should be easy but I'm can't make it work. The idea is to look for an email adress posted from a form. If it exists echo something and if not echo something else.
My code is:
<?php
//MySQL Database Connect
mysql_connect("localhost", "********", "**********")
or die("Unable to connect to MySQL");
//get data from form
$email=$_POST['email'];
//ask the database for coincidences
$result = mysql_query("SELECT email FROM pressmails WHERE email='.$email.'");
$num_rows = mysql_num_rows($result);
if($num_rows < 0){
echo "The user is registered";
} else {
echo "The user is not registered";
}
//Close database connection
mysql_close();
?>
mysql-extension is outdated. Read more php.net/en/mysql-connect. // Oh, and you are obviously introduce some SQL-injectionsmysql_*. They are deprecated now, and you should get into the habit of usingmysqlias a minimum...$num_rows<0is the wrong way round...mysqliuntil I read "as a minimum" ;)mysqliandmysqlfunctions are very similar, but they are not identical; if you're taking our advice and switching tomysqli, you should read the manual to see how they differ. HINT:mysqlifunctions require the connection variable, as returned frommysqli_connect().