<?php
$sel1="";
$sel2="";
$suc="";
$male="";
$female="";
$selected_radio="";
if(isset($_POST['save']))
{
$e=0;
if(isset($_POST['sport']))
{
$select_sport=$_POST['sport'];
if($_POST['sport']=="")
{
$sel1="<--Select The Game-->";
$e=1;
}
}
if(isset($_POST['gender']))
{
$selected_radio = $_POST['gender'];
}
else
{
$sel2="<--Select Your Gender-->";
$e=1;
}
if($e==0)
{
$suc="Success";
$male ="";
$female ="";
}
}
?>
<body>
<select name="sport">
<option value="">
<option value="cri" <?php if($select_sport=='cri') { echo "selected"; } ?>> CRICKET </option>
<option value="foot" <?php if($select_sport=='foot') { echo "selected"; }?>> FOOTBALL </option>
</select>
当我在浏览器上打开这个程序时,错误“未定义的索引”出现在选择选项(下拉框)中。
但是当我点击保存按钮时,错误消失了。当我不选择任何运动时,它工作得很好,它显示错误消息。
所以请帮助我找到解决方案...