note 65396 deleted from function.time by mazzanet

From: Date: Sun, 30 Apr 2006 07:17:26 +0000
Subject: note 65396 deleted from function.time by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-110151@lists.php.net to get a copy of this message
Note Submitter: Alper Kaya Reason: useless ---- Generally we use this function to make some applications more secure. For instance, you are programming a poll for your website. Adding 1 to each selection in mysql database is the easiest way but there is a problem. Your visitors might be in a wicked situation and they might trick the system. In my opinion, this cause some mistakes. You can try this exercise: At first, create an additional table for your poll. It will include visitors IP and date of insertion. And of course, we use this command to save date in database. Now we'll decide to what the time is necessary for our project. If you know a little math, you can calculate that one day includes 86400 seconds. I think that its enough. After that, you must check datas from database, which is about the current visitors IP. We will use an IF function to learn visitors last usage of poll system. For example, this visitor had used this system. Get these datas from database and check what's the date? <? // You have to write there your database connection // I will use $row for mysql_fetch_array $ip=$REMOTE_ADDR; // VISITOR IP $date=$row['poll_date']; // DATE IN DATABASE $date2=time(); // NOW $sensitivity=86400; $date3=$date+$sensitivity; // WE WILL COMPARE DATES if($date3>=$date2) {echo "Thanks.";} // INSERT DATA TO DATABASE else {echo "You cant use poll system two times in a day"; // DONT INSERT DATA TO DATABASE ?>

« previous php.notes (#110151) next »