IP Logger for Voting Script


Posted on 16th Feb 2014 07:03 pm by admin

Can anybody help me place an IP logger into my voting script?
I know that maybe it is not as secure, but I would prefer them to be logged into a text file for simplicity's sake.

THANKS!

The php script is this at the moment:

<?php
$vote = $_REQUEST['vote'];

//get content of textfile
$filename = "poll_result.txt";
$content = file($filename);

//put content in array
$array = explode("||", $content[0]);
$a = $array[0];
$b = $array[1];
$c = $array[2];
$d = $array[3];

if ($vote == 1)
{
$a = $a + 1;
}
if ($vote == 2)
{
$b = $b + 1;
}
if ($vote == 3)
{
$c = $c + 1;
}
if ($vote == 4)
{
$d = $d + 1;
}

//insert votes to txt file
$insertvote = $a."||".$b."||".$c."||".$d;
$fp = fopen($filename, "w");
fputs($fp,$insertvote);
fclose($fp);
?>

<font face="helvetica" color="gray"><i>
<?php echo($a); ?><br /><br />
<?php echo($b); ?><br /><br />
<?php echo($c); ?><br /><br />
<?php echo($d); ?></i></font>

No comments posted yet

Your Answer:

Login to answer
346 Like 22 Dislike
Previous forums Next forums
Other forums

Date help - fetch dates for Mondays between xxx and yyy?
Does anyone know the best way to do this? I have two dates, say:

2010-01-26 and 2010-05-30

cURL Sending File as Post
This is a bit complicated, I'm just hoping someone else has run into this and knows how to do it a d

Material xxx does not exist in plant xxx
Dear All,

I am working for a steel project which is repetitive manufacturing.

Is there a quick way to do this?
Hi all,

I need to create a mysql table from php that goes a little something like this

How to schedule the a job?
Hi,
I have prepared a task ( i.e. a procedure is prepare the file and send the same to con

Output Full URL of Current Page
Let's say I am currently viewing a dynamic page:

http://www.mydomain.com/directory/index.php

Alternate messaging
I have 4 strings in MySQL db1

$string1 : Hello
$string2 : Hi
$string3 : Great
$strin

Multiple server callbacks (NOT POSTBACKS)
Hello, I have 2 different javascript client side functions that are on timers. When the timers elap

How to get the previous months last date....
Here's my wittle problem. I suck at working with dates.

So today is 10/20/2009, i need to fig

mysql UNION | warning mysql_fetch_array !!
Code: <?php
$i = 0;
$query1="SELECT * FROM `products` WHERE `div

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash