Hello Pros,
I have a quick question here. Basically, I want to have multiple forms in one page where a user can submit their e-mail address to each form on the page, but cannot submit their name more than once to each form.
So, I guess but doing the INSERT I have to check for duplicates.
My table is setup where each form has an ID. So I need to do dulpicate checking on the e-mail address, but only for the form they are submitting to. make sense?
Here's my code which seems to have some flaws:
$query = "SELECT * FROM Data WHERE email='$email' AND listID='listID'";
$result = mysql_query($query);
if (mysql_num_rows($result) != 0) {
echo "<b>Hey!</b> You've already entered this contest with the e-mail address:<br><span class='main'>$email</span><br><br>While we DO accept multiple enteries to one contest,<br> you do have to use a unique e-mail address with each entry!<br><br>If you'd like to enter the contest again, please enter with a different e-mail address!<br>GOOD LUCK!<br><br><A HREF='javascript:window.history.back();'><img src='/media/news/clickhere.gif' width='76' height='14' align='absmiddle' border='0'></a> to go back to the contest page.<br>";
}
else {
$sql = "INSERT INTO Data VALUES( \"$ID\", \"$name\", \"$email\", \"$extra\", \"$listID\" )";
$res = mysql_query( $sql );
echo "<span class='main2'><font color='#000000'>THANKS FOR ENTERING!</font></span><br><br>Your e-mail address of: <b>$email</b> has been entered into the drawing!<br>Winners will be notified shortly!<br><br><a href='index.php' class='main2'>CLICK HERE TO ENTER ANOTHER CONTEST!</a>";
mysql_close();
}
Any advice will help! Thanks!