Preventing multiple entries with PHP

The following input fields are presented next to the survey object on the web page, which allow the visitor (voter) to enter their data into the basket lottery as a reward for their participation in the vote.

The lottery script login form does not apply to the polling script. All entries in the lottery script entry form are checked and information is sent to the flatfile file. This is a short survey that lasts only 7 days on various topics that may arise from time to time for a small city forum. (ip is also going)

Name  :<input type="text" name="visitor" /><br /><br />
Email :<input type="text" name="visitormail" /><br /><br />
Phone :<input type="text" name="visitorphone"/><br /><br />

When presenting the "Thank you" page , it advises the visitor that their data should be used once in the basket lottery. In other words, the visitor can come back and fill out the form again and submit, requiring me to check and filter out a few entries from the flatfile before ending the random number draw for the basket!

Question Is there an easy way to establish something that prevents a visitor from trying multiple entries in a draw?

+1
source share
7 answers

I would also register IP (see variable $_SERVER). Then you can narrow down the duplicates by IP. Not always the most reliable method.

cookie.

+1

@David Barker , , , , , . , "". , "".

, , . , . , , , .

, , , , .

, , , , .

:

1 -

" ", , , , .

2 - IP-

, , diconnect -, . , IP, . logmein - . , .

3 -

2 , ( ), .

4 -

( , , ), . , , - 16, 16, 16a, 16b... , , , .

5 - , , ,

+1

, . , ( #) uniqe. , ( # , ).

0

, user_id , . , , IP- $_SERVER['REMOTE_ADDR ']. cookie .

0

- , , . ( ) .

script, flatfile true, , .

.

$input = $_REQUEST['post_data'];

$fp = fopen("poll.txt","r");

while ($ln = fgetcsv($fp, 1000, "\t") !== FALSE) {
    if ($ln[4] == $input['post_data']) {

        // Set exists to true
        $exists = TRUE;
    }
}

// Check if $exists == TRUE {
//     return false;
// Else {
//     write new data to file.
// }

, flatfile /t . : $ln [x], x = .

0

, . , , ,

"SELECT COUNT(visitoremail) FROM users WHERE LOWER(visitoremail) = '" . strtolower($_REQUEST['visitormail']) . "';

, . , , INSERT .

. "SELECT DISTINCT visitoremail FROM users... ", PHP, array_unique(visitoremails), .

0

onclick, .

- :

var btn = document.getElementById("button-id");
btn.onclick = function() {
    btn.disabled = 'disabled';
}
-1

All Articles