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

do while...woes
I'm sure this is childsplay but it is stumping me, everytime i try what I think would make this work

exclude characters from counting?
Hello, I wanted to ask if you have a string like:
Code: $my_s='ASRGREGTGTR----REGREGRE+++RRRRRR..

Alternate messaging
I have 4 strings in MySQL db1

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

using variables in another page
I have a test database set up on localhost. I have a form that I can type a name into, hit the butto

Upload, SSL and more php help
I recently just installed a ssl cert and do i use https for the whole site or just for the checkout.

ALV grid with 2 headers
Hi Gurus,

I need to display ALV GRID as below.

Header1

Frustrated php Newbie
First off, I am pretty much a PHP nub. I can read and understand the language (most of the time) so

Embedding flash object in Else statement
This is my first major project in PHP and I'm having some trouble embedding a flash object in an Els

Fetching META TAGS through
Hello everybody
I want to fetch meta tags of a domain.
It will be done from following code of

Memory Allocation
Hi folks,
see this ex:

int v=5;
v=v+10;

then what will do the compiler before th

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