Am really beginner at this so sorry in advance.
i have a database that i can connect to and insert data etc.
it is an email database in which i want users to be able to add their email address. At the moment, all works well with the adding of emails.
my problem is that if you put the users email adddress in the form again, the email address gets added again into the database.
the script that i found does not work...
i have worked for days just trying to get the IF statement to work correctly but cannot work out the variables?
here it is.
require('connec t.php');
$form_email = ($_POST['email']);
function emailChecker($e mail){
global $check_result;
$check = "SELECT id FROM esubs WHERE email = '$form_email'";
$check_result = mysql_query($ch eck) or die(mysql_error ());
if(!mysql_num_r ows($check_resu lt)) return false;
else return true;
mysql_close();
}
i simplified it so that if the query found something, then it printed a"found result" or if nothing was found then print "nothing Found"
this is the script i did up.
require('connec t.php'); // Connect to the database
$form_email = ($_POST['email']);
$SQL= "SELECT * FROM esubs WHERE email = '$form_email'";
$check_result = mysql_query($SQ L);
if(mysql_query( $SQL)) {
print 'found result';
} else {
print 'Nothing found';
}
but no matter what email i put into the field, i get found result.
if i put a ! in front of the mysql_query($SQ L)) {
making it:
if(!mysql_query ($SQL)) {
then every time i get nothing found....
Please help....
thats if this makes sense....
i have a database that i can connect to and insert data etc.
it is an email database in which i want users to be able to add their email address. At the moment, all works well with the adding of emails.
my problem is that if you put the users email adddress in the form again, the email address gets added again into the database.
the script that i found does not work...
i have worked for days just trying to get the IF statement to work correctly but cannot work out the variables?
here it is.
require('connec t.php');
$form_email = ($_POST['email']);
function emailChecker($e mail){
global $check_result;
$check = "SELECT id FROM esubs WHERE email = '$form_email'";
$check_result = mysql_query($ch eck) or die(mysql_error ());
if(!mysql_num_r ows($check_resu lt)) return false;
else return true;
mysql_close();
}
i simplified it so that if the query found something, then it printed a"found result" or if nothing was found then print "nothing Found"
this is the script i did up.
require('connec t.php'); // Connect to the database
$form_email = ($_POST['email']);
$SQL= "SELECT * FROM esubs WHERE email = '$form_email'";
$check_result = mysql_query($SQ L);
if(mysql_query( $SQL)) {
print 'found result';
} else {
print 'Nothing found';
}
but no matter what email i put into the field, i get found result.
if i put a ! in front of the mysql_query($SQ L)) {
making it:
if(!mysql_query ($SQL)) {
then every time i get nothing found....
Please help....
thats if this makes sense....
Comment