mysql trouble

admin

Administrator
Staff member
I am creating a newsletter and want to take the email address the user submitted and loop it through a search in the database and see if it matches. If it does, then I want to report an error saying email address already subscribed. if no match, then insert it into the db.

here is my code so far

$link = mysql_connect($host,$user,$pass);
mysql_select_db($db, $link);

// Check for existing email address
$match = false;
$i = 0;

$total = mysql_list_dbs($link);

while ($i < mysql_num_rows($total)) {

if ($email == ($dup_email[$i])
$match = true;
break;
}

$i++;
}

mysql_free_result($total);

if($match == true) {
echo "error";
exit;
}

please fill in the rest of the php/mysql code to make this work.
 
Back
Top