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!
Did you know?Explore Trending and Topic pages for more stories like this.

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

md5 is it unique
I know this is most likely one of many simple questions that can be found semi easily. But I'm press

PHP SUBMIT
Code: <input name="doLogin" type="image" src="images/loginsubmit.jpg

Please help with SMTP Authenticated PHP Email Form
Hello, I'm creating a PHP email form, and for this particular server, I have to use SMTP Authenticat

Parse Error with doctype
I'm getting a parse error with this simple code. I don't get it. It worked one time then when I relo

If statement help please.
Hello on my site I have 2 content boxes. 1 is for the main content (which is the biggest one) and th

HELP with mysql_real_escape_string
I'm looking to remove apostrophes completely when someone enters lyrics but don't have a clue how to

C problem struct and string
Hi guys,

This is my first post and I'm hoping the experts here can help me solve my problem.<

Showing selected item at top of list
Hi,

I've got a list of names which i am fetching from database like this:
$qry = db_query

Header is not working in IE
Hi ! header function is not working in IE but it works in FF, Safari, Chrome. any help please. :

php/mysql problem
Hey all,

Problem: im trying to setup a shop where people can use a drop-down list to select t

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