Php implements a daily vote for each ip address. The following is the implementation code :? Php *** PHP + MySQL ** CREATETABLEIFNOTEXISTS 'IP _ poll '(* 'IP' varchar (15) NOTNULL, * 'date' datetimeNOTNULL *) enginemyisamdefacharcharset the following code is implemented:
-
-
- /**
- * PHP + MySQL
- * Create table if not exists 'IP _ poll '(
- * 'IP' varchar (15) not null,
- * 'Date' datetime NOT NULL
- *) ENGINE = MyISAM default charset = latin1;
- *
- */
-
- Function getIP (){
- $ Ip = "";
- If (getenv ("HTTP_CLIENT_IP") $ ip = getenv ("HTTP_CLIENT_IP ");
- Else if (getenv ("HTTP_X_FORWARDED_FOR") $ ip = getenv ("HTTP_X_FORWARDED_FOR ");
- Else if (getenv ("REMOTE_ADDR") $ ip = getenv ("REMOTE_ADDR ");
- Else $ ip = "";
- Return $ ip;
- }
-
- Function checkVote ()
- {
- $ Ip = getIP ();
- $ SQL = "select count (*) from ip_poll where ip = '". $ ip. "'and SUBSTR (date,) = '". date ("Y-m-d "). "'";
- If ($ res = mysql_query ($ SQL ))
- {
- $ Row = mysql_num_rows ($ res );
- If ($ row = 0)
- {
- $ Sqloud = "insert into ip_poll values ('". $ ip. "', now ());";
- If (mysql_query ($ sqlIns ))
- Return true;
- Else
- Return false;
- } Else {
- Return false;
- }
- } Else {
- Return false;
- }
- }
-
- ?>
Why :? Php/*** PHP + MySQL * create table if not exists 'IP _ poll '(* 'IP' varchar (15) not null, * 'date' datetime not null *) ENGINE = MyISAM default charset =...