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

Amend code to allow multiple attachments
Hi

I have a php page that allows the user to browse to a file (image) then sumbit, the confi

Warning: session_start() headers already sent error - Driving me Nuts!
I am trying my sister in laws site and I keep getting an error with my coding. I am more of a design

Wordpress IE issue
So I am trying to add the background shadow to my wordpress page. It works fine in Firefox but does

php multiple action on submit
I have a form which says:

<form enctype='multipart/form-data' method='post' action='pr

Looping Problem
I've got a client that has a database with about 200 events at any given time. I'm trying to loop t

php/xmlrpc class issue
I am working on xml-rpc in php to start with.

I have a class that only has variables defined

Need help urgant
why down my code ony return one item instead of all the items selected.

$arr = array($date,$

What are causes of a connection-timeout with fopen()?
Hello! Here is the situation: The server I host my website on just upgraded it's PHP build from 4.4.

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

Error Messaging not working
I changed the way my form tells the user of an error. But I can't seem to get it to work properly.

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