Direct URL to submit vote to replace radio button use
Posted: Fri Aug 14, 2009 9:36 am
Hi all,
I am new to this forum,
I am working on an online voting / poll section on a website and the theme is voting for our next model.
As we are dealing with images, what i have done is create a pretty cool flash gallery where the user can click the image - then they can click it again to directly cast their vote. Each image i can assign a unique url which i have been trying to assign the correct url string to submit the vote but so far i am unable to do this.
This is sample of the code for the page where the vote page is done with the radio buttons and the submit button
"
if(isset($_COOKIE["$cookie_name"]) && $_GET["message"] != "1" && $_GET["message"] != "2" && $_GET["message"] != "3") $message = "<ins>Results</ins><br /><br />";
elseif(!isset($_COOKIE["$cookie_name"]) && !isset($_GET["message"]) || $_GET["message"] < "1" || $_GET["message"] > "3") $message = "<ins>Cast your vote below.</ins><br /><br />";
elseif($_GET["message"] == "1") $message = "<ins>Your vote has been added.</ins><br /><br />";
elseif($_GET["message"] == "2") $message = "<ins>You must select a choice.</ins><br /><br />";
elseif($_GET["message"] == "3") $message = "<ins>You can only vote once per week.</ins><br /><br />";
?>
<table>
<tr>
<td>
<?=$date?>
</td>
</tr>
<tr>
<td>
<em><?=$header?></em><br />
<strong><?=$question?></strong><br /><br />
<?=$message?>
<form action="vote.php" method="post">
<hr />
<p><input name="choice" type="radio" value="0" /> <?=$choices[0]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[10]?></strong>)<? } ?></p>
<p><input name="choice" type="radio" value="1" /> <?=$choices[1]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[11]?></strong>)<? } ?></p>
<? if(isset($choices[2]) && trim($choices[2]) != "") { ?>
<p><input name="choice" type="radio" value="2" /> <?=$choices[2]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[12]?></strong>)<? } ?></p>
<? } if(isset($choices[3]) && trim($choices[3]) != "") { ?>
<p><input name="choice" type="radio" value="3" /> <?=$choices[3]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[13]?></strong>)<? } ?></p>
<? } if(isset($choices[4]) && trim($choices[4]) != "") { ?>
<p><input name="choice" type="radio" value="4" /> <?=$choices[4]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[14]?></strong>)<? } ?></p>
<? } if(isset($choices[5]) && trim($choices[5]) != "") { ?>
<p><input name="choice" type="radio" value="5" /> <?=$choices[5]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[15]?></strong>)<? } ?></p>
<? } if(isset($choices[6]) && trim($choices[6]) != "") { ?>
<p><input name="choice" type="radio" value="6" /> <?=$choices[6]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[16]?></strong>)<? } ?></p>
<? } if(isset($choices[7]) && trim($choices[7]) != "") { ?>
<p><input name="choice" type="radio" value="7" /> <?=$choices[7]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[17]?></strong>)<? } ?></p>
<? } if(isset($choices[8]) && trim($choices[8]) != "") { ?>
<p><input name="choice" type="radio" value="8" /> <?=$choices[8]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[18]?></strong>)<? } ?></p>
<? } if(isset($choices[9]) && trim($choices[9]) != "") { ?>
<p><input name="choice" type="radio" value="9" /> <?=$choices[9]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[19]?></strong>)<? } ?></p>
<? } ?>
<hr />
<p><strong><?=$total_votes?></strong> total votes<br /><br /></p>
<? if(!isset($_COOKIE["$cookie_name"])) { ?>
<p><input name="submit" type="submit" value="Vote" /></p>
<? } else { ?>
<p><em>Already voted.</em></p>
"
Now this is the sample from the actual action page called vote.php
"
include("poll_script.php");
$choice = $_POST["choice"];
if(isset($choice) && !isset($_COOKIE["$cookie_name"])) {
$pick = "1".$choice;
$choices[$pick] += 1;
$file_write = $choices[0]."|".$choices[1]."|".$choices[2]."|".$choices[3]."|".$choices[4]."|".$choices[5]."|".$choices[6]."|".$choices[7]."|".$choices[8]."|".$choices[9]."|".$choices[10]."|".$choices[11]."|".$choices[12]."|".$choices[13]."|".$choices[14]."|".$choices[15]."|".$choices[16]."|".$choices[17]."|".$choices[18]."|".$choices[19];
$choices_file = fopen($poll_file, "w");
fwrite($choices_file, $file_write);
fclose($choices_file);
setcookie("$cookie_name", "true", time()+$cookie_timeout);
header("Location: $redirect_page?message=1#poll");
}
elseif(!isset($choice)) {
header("Location: $redirect_page?message=2#poll");
}
elseif(isset($_COOKIE["$cookie_name"])) {
header("Location: $redirect_page?message=3#poll");
}
?>
"
Apologies for pasting alot of stuff, i am not certain which is required anymore to locate how to bypass the need for selecting the radio button and then clicking submit, instead i was thinking of using the direct URL which could possibly be http://mydomainname.com/modelvote/vote.php?id=2
Any help would be greatly appreciated
If you require any more info i would happily give it to you.
Regards
I am new to this forum,
I am working on an online voting / poll section on a website and the theme is voting for our next model.
As we are dealing with images, what i have done is create a pretty cool flash gallery where the user can click the image - then they can click it again to directly cast their vote. Each image i can assign a unique url which i have been trying to assign the correct url string to submit the vote but so far i am unable to do this.
This is sample of the code for the page where the vote page is done with the radio buttons and the submit button
"
if(isset($_COOKIE["$cookie_name"]) && $_GET["message"] != "1" && $_GET["message"] != "2" && $_GET["message"] != "3") $message = "<ins>Results</ins><br /><br />";
elseif(!isset($_COOKIE["$cookie_name"]) && !isset($_GET["message"]) || $_GET["message"] < "1" || $_GET["message"] > "3") $message = "<ins>Cast your vote below.</ins><br /><br />";
elseif($_GET["message"] == "1") $message = "<ins>Your vote has been added.</ins><br /><br />";
elseif($_GET["message"] == "2") $message = "<ins>You must select a choice.</ins><br /><br />";
elseif($_GET["message"] == "3") $message = "<ins>You can only vote once per week.</ins><br /><br />";
?>
<table>
<tr>
<td>
<?=$date?>
</td>
</tr>
<tr>
<td>
<em><?=$header?></em><br />
<strong><?=$question?></strong><br /><br />
<?=$message?>
<form action="vote.php" method="post">
<hr />
<p><input name="choice" type="radio" value="0" /> <?=$choices[0]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[10]?></strong>)<? } ?></p>
<p><input name="choice" type="radio" value="1" /> <?=$choices[1]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[11]?></strong>)<? } ?></p>
<? if(isset($choices[2]) && trim($choices[2]) != "") { ?>
<p><input name="choice" type="radio" value="2" /> <?=$choices[2]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[12]?></strong>)<? } ?></p>
<? } if(isset($choices[3]) && trim($choices[3]) != "") { ?>
<p><input name="choice" type="radio" value="3" /> <?=$choices[3]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[13]?></strong>)<? } ?></p>
<? } if(isset($choices[4]) && trim($choices[4]) != "") { ?>
<p><input name="choice" type="radio" value="4" /> <?=$choices[4]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[14]?></strong>)<? } ?></p>
<? } if(isset($choices[5]) && trim($choices[5]) != "") { ?>
<p><input name="choice" type="radio" value="5" /> <?=$choices[5]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[15]?></strong>)<? } ?></p>
<? } if(isset($choices[6]) && trim($choices[6]) != "") { ?>
<p><input name="choice" type="radio" value="6" /> <?=$choices[6]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[16]?></strong>)<? } ?></p>
<? } if(isset($choices[7]) && trim($choices[7]) != "") { ?>
<p><input name="choice" type="radio" value="7" /> <?=$choices[7]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[17]?></strong>)<? } ?></p>
<? } if(isset($choices[8]) && trim($choices[8]) != "") { ?>
<p><input name="choice" type="radio" value="8" /> <?=$choices[8]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[18]?></strong>)<? } ?></p>
<? } if(isset($choices[9]) && trim($choices[9]) != "") { ?>
<p><input name="choice" type="radio" value="9" /> <?=$choices[9]?><? if($display_votes == false && isset($_COOKIE["$cookie_name"]) || $display_votes == true) { ?> (<strong><?=$choices[19]?></strong>)<? } ?></p>
<? } ?>
<hr />
<p><strong><?=$total_votes?></strong> total votes<br /><br /></p>
<? if(!isset($_COOKIE["$cookie_name"])) { ?>
<p><input name="submit" type="submit" value="Vote" /></p>
<? } else { ?>
<p><em>Already voted.</em></p>
"
Now this is the sample from the actual action page called vote.php
"
include("poll_script.php");
$choice = $_POST["choice"];
if(isset($choice) && !isset($_COOKIE["$cookie_name"])) {
$pick = "1".$choice;
$choices[$pick] += 1;
$file_write = $choices[0]."|".$choices[1]."|".$choices[2]."|".$choices[3]."|".$choices[4]."|".$choices[5]."|".$choices[6]."|".$choices[7]."|".$choices[8]."|".$choices[9]."|".$choices[10]."|".$choices[11]."|".$choices[12]."|".$choices[13]."|".$choices[14]."|".$choices[15]."|".$choices[16]."|".$choices[17]."|".$choices[18]."|".$choices[19];
$choices_file = fopen($poll_file, "w");
fwrite($choices_file, $file_write);
fclose($choices_file);
setcookie("$cookie_name", "true", time()+$cookie_timeout);
header("Location: $redirect_page?message=1#poll");
}
elseif(!isset($choice)) {
header("Location: $redirect_page?message=2#poll");
}
elseif(isset($_COOKIE["$cookie_name"])) {
header("Location: $redirect_page?message=3#poll");
}
?>
"
Apologies for pasting alot of stuff, i am not certain which is required anymore to locate how to bypass the need for selecting the radio button and then clicking submit, instead i was thinking of using the direct URL which could possibly be http://mydomainname.com/modelvote/vote.php?id=2
Any help would be greatly appreciated
If you require any more info i would happily give it to you.
Regards