开发者

HTML Radiobutton form not POSTing

开发者 https://www.devze.com 2023-01-18 16:46 出处:网络
I have written a small HTML form and added it to the page. My goal is for it to POST the value of the Checked button to a PHP page which I have also written. The PHP page is not getting the valu开发者

I have written a small HTML form and added it to the page. My goal is for it to POST the value of the Checked button to a PHP page which I have also written. The PHP page is not getting the valu开发者_StackOverflow社区e for some reason. I am also not getting any PHP errors. The codes are below.


form.php

<form action="http://www.zbrowntechnology.com/InsaneBrain/quiz.php" method="POST">
<font color="white" size="3">
<?php
$con = mysql_connect("HOST", "USER", "PASS");
if(!$con) {
  die('Unable to connect to MySQL:   '.mysql_error());
}
mysql_select_db("zach_insaneB", $con);
$result = mysql_query("SELECT Name FROM quiz"); 
while($row = mysql_fetch_assoc($result)) {
 $qname = $row['Name'];
 echo "<input type='radio' name='button1' id='$qname'>";
 echo "<label for='$qname'><font color='white'/>$qname</font></label>";
}
?>
</font>
</div>
</div>

<div id="Oobj12">
<div id="Gcode234" class="dfltc">
<input type="image" src="http://www.zbrowntechnology.com/InsaneBrain/begin.png" alt="Begin" />
</form></div>
</div>

getdata.php

<?php
$data = $_POST['button1'];
echo $data;
?>


Actually, I see the problem...you don't actually have a value in the radio button. You need something like:

echo "<input type='radio' name='button1' id='$qname' value='$some_value'>";
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号