I have a radio button poll form that I am developing. How can I make the submit button disappear once the user clicks submit? (I am displaying the results just below the questions, once the user hits submit. That works, but submit button still stays there…I tried all kinds of if else statemetns, with issets, is_nulls etc…I can not make the submit button go away.)
Here is my code, after connecting to database: (by the way it submits to itself, this file is called displaypoll. – may be that is the mistake, but if i dont do it, and submit the poll to another file, a whole new page comes, only with the poll results, and my home page where the poll sists in, disappear, which i dont want.)
[code=php]
$query=mysql_query(“select * from questions WHERE `category`='{$kat}’ ORDER BY id DESC LIMIT 1”);
while ($row = mysql_fetch_array($query)):
$id=$row[‘id’];
$category=$row[‘category’];
$title=$row[‘title’];
$date=$row[‘date’];
$q1=$row[‘q1’];
$q2=$row[‘q2’];
$q3=$row[‘q3’];
$q4=$row[‘q4’];
$q5=$row[‘q5’];
$q6=$row[‘q6’];
$q7=$row[‘q7’];
$q8=$row[‘q8’];
$qtotal=$row[‘qtotal’];
endwhile;
$sot = array(0,$q1,$q2,$q3,$q4,$q5,$q6,$q7,$q8);
echo “<form method=”post” action=”displaypoll.php”>”;
echo $title;
echo “</br>”;
for($i=1; $i<=$qtotal; $i++)
{
$answer=”answer”.$i;
echo “<input type=”radio” name=”answer” value=$answer>”;
echo $sot[$i];
echo “</br>”;
}
echo “<input type=”hidden” name=”aypi” value=$userip>”;
echo “<input type=”hidden” name=”aydi” value=$id>”;
echo “<input type=”hidden” name=”qtotal” value=$qtotal>”;
echo “<input type=”submit” name=”submitname” value=”submit my answer”/>”;
echo “</form>”;
//////////Below is the response display part
$response=$_POST[‘answer’];
$userip=$_POST[‘aypi’];
$idpoll=$_POST[‘aydi’];
$qtotal=$_POST[‘qtotal’];
$submitname=$_POST[‘submitname’];
$query1=”INSERT INTO answers1 (idpoll, userip, response) VALUES (‘$idpoll’,’$userip’,’$response’)”;
mysql_query($query1) or die (‘ I could not update the database’);
for($i=1; $i<=$qtotal; $i++)
{
$answer=”answer”.$i;
$query=”query”.$i;
$query=”select count(1) FROM answers1 WHERE `idpoll`='{$idpoll}’ AND `response`='{$answer}’ “;
$rs=mysql_query($query);
$total = mysql_fetch_array($rs);
echo $answer;
echo $total[0];
}
?>