how to stop multiple entries?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
kanchan
Forum Commoner
Posts: 80
Joined: Tue Nov 30, 2004 12:03 pm

how to stop multiple entries?

Post by kanchan »

i want the code to stop the users from posting the form not more than i time...........

i want them to block them from their emails...........

can anybody help me?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Store all the emails that people use to submit the form and then check to make sure that the email entered has not already been entered - a simple if statment or in_array() will do it.
kanchan
Forum Commoner
Posts: 80
Joined: Tue Nov 30, 2004 12:03 pm

Post by kanchan »

kettle_drum wrote:Store all the emails that people use to submit the form and then check to make sure that the email entered has not already been entered - a simple if statment or in_array() will do it.

can u please let me the code..........
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

<?php
session_start();
if (isset($_SESSION['posted']))
{

echo 'You have already posted';

}
else
{

//do your thing here

$_SESSION['posted'] = 'set';

}
?>
Depending on your setup, it will look something like this
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Either as phemom says with sessions or:

Code: Select all

CREATE TABLE emails (
   address varchar(255) NOT NULL unique,
   PRIMARY KEY (address)
);

Code: Select all

$address_posted = $_POST['email_address'];
$result = mysql_query("SELECT * FROM emails WHERE address = '$address_posted'");
if(mysql_num_rows($result)){
   echo "You have already submitted the form.";
}else{
   echo "Thanks for submitting the form.";
   mysql_query("INSERT INTO emails VALUES ('$address_posted')");
}
Post Reply