エラーが発生します Notice: Undefined index: q_id in D:\pinnaclequizsoft\USBWebserver v8_en\root\test.php on line 21 Notice: Undefined index: option in D:\pinnaclequizsoft\USBWebserver v8_en\root\test.php on line 22
誰かが私が間違っているところを教えてもらえますか? これが私のコードです
<?php
$link = mysql_connect('localhost', 'root', 'usbw');
if (!$link) {die('Could not connect: ' . mysql_error());}
$select = mysql_select_db("quiz",$link);
if (!$select)
{
die('Could not Connect to Database');
}
$perpage = 1;
if(isset($_GET['id'])){
$start = $_GET['id'];
}else{
$start = 0;
}
$id= $_POST['q_id'];
$value = $_POST['option'];
$sql = "INSERT INTO ans "."(ques_id, ans_s) "."VALUES('$id','$value')";
mysql_select_db('quiz');
$retval = mysql_query( $sql, $link );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully\n";
$TotalRec = mysql_num_rows(mysql_query("SELECT * FROM ques_bank"));
$select = "SELECT * FROM ques_bank LIMIT $start, $perpage";
$result = mysql_query($select) or die(mysql_error());
$rows = mysql_fetch_array($result);
?>
<form action="test.php?id=<?php echo ($start + 1); ?>" method="post">
<?php echo $rows['id'].". ". $rows['ques']; ?> <br>
<input type="radio" name="option" value="a"><?php echo $rows['optionA']; ?><br>
<input type="radio" name="option" value="b"><?php echo $rows['optionB']; ?><br>
<input type="radio" name="option" value="c"><?php echo $rows['optionC']; ?><br>
<input type="radio" name="option" value="d"><?php echo $rows['optionD']; ?><br>
<input type="radio" name="option" value="e"><?php echo $rows['optionE']; ?><br>
<input type="hidden" value="<?php echo $rows['id'] ?>" name="q_id">
<?php
if($start == 0){
echo "Previous «";
}else{
echo "<a href=\"./test.php?id=" . ($start - 1) . "\">Previous «</a>";
}
echo " ";
if($start == $TotalRec-1){
echo "Next »";
}else{
echo "<a href=\"./test.php?id=" . ($start + 1) . "\">Next »</a>"; ?>
<input type='Submit' value='SUBMIT & NEXT' name="next">
<?php
}
?>
</form>