Hello eveybody! I’m a beginner in PHP. I’m trying to make a fake poll using radio buttons and a script, and my code doesn’t work to the point where I’m thinking I’ve gotten something completely wrong.
I don’t need the answer to be stored anywhere, but I need the poll to refresh the page with a thank you message after a vote has been cast. Here is the code of the main page:
[PHP]<?php
if ($_POST[vote]=='1') {echo("Thank you for voting.");}
else {echo("
<p><b>QUESTION</b></p>
<p> </p>
<form action=\"vote.php\" method=\"post\">
<p>
<input type=\"radio\" name=\"vote1\" value=1 > OPTION 1<br />
<input type=\"radio\" name=\"vote2\" value=1 > OPTION 2<br />
<input type=\"radio\" name=\"vote3\" value=1 > OPTION 3
</p>
<p> </p>
</form>
<input type=\"submit\" value=\"VOTE\" />
</form>
");}
?> [/PHP]
and the script (vote.php):
[PHP]<?php
$vote=$_POST[vote];
header(“main.php?vote=”.$vote);
?>[/PHP]
I’ve been looking at tutorials but I still haven’t found what the problem is… The output is crazy wrong, I’m getting fields where there should have been buttons and the ");} ?> trail of the code is showing. Please help…