在php中重定向到post submit上的索引页
在这里,我从数据库中检索一些问题,并为每个问题显示一些单选选项。。在php中重定向到post submit上的索引页,php,Php,在这里,我从数据库中检索一些问题,并为每个问题显示一些单选选项。。 make name='ans[“$sno.”而不是name='ans[$sno]'很好。。但我的问题是,它正在重定向到索引页面,并在同一个页面中显示回显值page@VaisakhPc由于代码的这一部分在双引号内,因此不会产生任何错误difference@user3124621你说你的页面正在重定向,但我看不到任何会导致重定向的代码。请分享所有相关代码以帮助解决您的问题。那么您的表单标签在哪里 <?php include(
make name='ans[“$sno.”而不是name='ans[$sno]'很好。。但我的问题是,它正在重定向到索引页面,并在同一个页面中显示回显值page@VaisakhPc由于代码的这一部分在双引号内,因此不会产生任何错误difference@user3124621你说你的页面正在重定向,但我看不到任何会导致重定向的代码。请分享所有相关代码以帮助解决您的问题。那么您的表单标签在哪里
<?php
include('conn.php');
$sql=mysql_query("select * from questions");
while($row=mysql_fetch_array($sql))
{
$sno=$row['s_no'];
$que=$row['question'];
echo "<li style='font-size:16px;font-family:Century Gothic,calibri;color:skyblue;margin:0px;padding:0px;font-weight:bold;'> $que
<p style='margin:0px 0px 0px 20px;font-size:14px;color:orange;'>
<input type='radio' name='ans[$sno]' value='Yes' required='required'>Yes
<input type='radio' name='ans[$sno]' value='No' required='required'>No
</p></li>";
}
?>
</ol>
<p style="text-align:center">
<input type="submit" name="submit" value="Submit" style="width:75px;background:black;color:white;border-radius:5px;height:25px;font-size:14px;margin-bottom:20px;font-weight:bold">
</p>
</form>
<?php
if(isset($_REQUEST['submit']))
{
include('conn.php');
if (isset($_POST['ans']))
{
$flag==0;
foreach ($_POST['ans'] as $key => $value)
{
// echo 'Question #' . $key . ' is ' . $value . '<br>';
$sql1="select answer as 'ans' from questions where s_no='$key'";
$res=mysql_query($sql1);
$row1=mysql_fetch_array($res);
$ans=$row1['ans'];
if( $ans == $value)
{
$flag=$flag+1;
}
}
}
if ($flag >= 6)
{
echo "<p style='color:#C00;font-size:30px;'>You Are Eligible For The Job</p>";
}
else
{
echo "<p style='color:#C00;font-size:30px;'>You Are not Eligible For The Job</p>";
}
}
?>