Jump to content

Poll Script to Allow All Users


poison6feet

Recommended Posts

Hi There,

I have written a script for a poll and I am displaying poll option based on Remote IP address.

How to allow all the users connecting to one network to VOTE the poll,

Ex: If one user casted VOTE then IP is recorded and my site is not displaying the POLL option other users on the network.

 

Could some one plz help me to achieve this option???

 

Thanks & Regards

Link to comment
https://forums.phpfreaks.com/topic/158730-poll-script-to-allow-all-users/
Share on other sites

Does your server provide MySQL Database support? If so, I recommend reading up on MySQL: INSERT and SELECT queries.

 

And, you can retrieve a user's IP address at any time using the superglobal array "$_SERVER."

 

$ip_address = $_SERVER['REMOTE_ADDR'];

thanks for quick reply,

I am attaching a part of script

 

<?session_start();

 

$uip=$_SERVER['REMOTE_ADDR'];

$query = "select pollId from pollanswers where pollId=1 and visitorIP='$uip'";

  $numresults=mysql_query($query);

  $numrows=mysql_num_rows($numresults);

if ($numrows == 0){?>

  <h2>Poll Of The Day</h2>

  <form action="" name="poll" >

  <?

  $result=mysql_query("select * from pollquestions");

  while($row_list=mysql_fetch_assoc($result))

<display Poll Questions / Options>

}

 

For Exp:

I have Casted vote and My External IP is 1.1.1.1 and to this external ip there 3 computers connected with internal ip.

How to allow others to cast the vote, hopefully I am expressing my question properly, if not I appologise.

Thanks

 

thanks for quick reply,

I am attaching a part of script

 

<?session_start();

 

$uip=$_SERVER['REMOTE_ADDR'];

$query = "select pollId from pollanswers where pollId=1 and visitorIP='$uip'";

  $numresults=mysql_query($query);

  $numrows=mysql_num_rows($numresults);

if ($numrows == 0){?>

  <h2>Poll Of The Day</h2>

  <form action="" name="poll" >

  <?

  $result=mysql_query("select * from pollquestions");

  while($row_list=mysql_fetch_assoc($result))

<display Poll Questions / Options>

}

 

For Exp:

I have Casted vote and My External IP is 1.1.1.1 and to this external ip there 3 computers connected with internal ip.

How to allow others to cast the vote, hopefully I am expressing my question properly, if not I appologise.

Thanks

 

 

Well, unfortunately (as far as I know), there's no way to differentiate from devices connected locally to the same remote IP address. So, even if one IP address is consistent with ten local users (all in the same house, for argument's sake), once one of the ten voted, the other nine could not vote.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.