注意:未定义的索引变量.PHP脚本可以在Linux上运行,但不能在Windows上运行


Notice: Undefined index variable. PHP script works on Linux but not Windows

我有一个PHP脚本,它可以在Linux上运行,但不能在Windows上运行。我可以接受我的PHP编码不是很好,我是个新手。我有一个表格,我把数据发布到它上。现在它在Windows服务器上,我得到:

注意:第31行C:''Apache24''htdocs''index.php中的未定义索引:nmr…

等等

我尝试将所有变量声明为0,并使用isset,但似乎不起作用。也许我用错了。有人能帮我吗?

    <html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="http://www.hackmaine.org/favicon.ico">
<link rel="stylesheet" type="text/css" href="sty.css">
    <title>NMR Scheduler</title>
</head>
<body>
<?PHP
$Unity = 'unchecked';
$Inova = 'unchecked';
$Experiment = $duration = $ToD = $startTime = $ddate = $nmr = $UName = 0;
if (isset($_POST['Submit1']))
{
    $selected_radio = $_POST['nmr'];
    switch ($selected_radio) 
    {
        case Unity:
            break;
        case Inova:
            break;
        default:
        echo "Select an NMR";
    }
}
isset($Experiment, $duration, $ToD, $startTime, $ddate, $UName);    
    $reg_wvar=$_POST['nmr'];
    $reg_UName=$_POST['UName'];
    $reg_Date=$_POST['ddate'];
    $reg_startTime=$_POST['startTime'];
    $reg_ToD=$_POST['ToD'];
    $reg_duration=$_POST['duration'];
    $reg_Experiment=$_POST['Experiment'];
    $stringy = "$reg_wvar, $reg_UName, $reg_Date, $reg_startTime $reg_ToD,  $reg_duration, $reg_Experiment 'n";
    echo $stringy;
    $filename = 'newEntry.txt';
// Let's make sure the file exists and is writeable first.
if (is_writable($filename)) {
    if (!$handle = fopen($filename, 'a')) {
         echo "Cannot open file ($filename)";
         exit;
    }
    // Write $somecontent to our opened file.
    if (fwrite($handle, $stringy) === FALSE) {
        echo "Cannot write to file ($filename)";
        exit;
    }
//echo "Success, wrote ($somecontent) to file ($filename)";
    fclose($handle);
    } else {
    echo "Data not written, Make Sure you selected an NMR";
}
?>
<center>
<FORM ACTION="if.php" method="post">
<h2>NMR Usage Scheduler</h2>
<br /><br />
<INPUT TYPE = 'Radio' Name ='nmr'  value= 'Unity'>Unity
<INPUT TYPE = 'Radio' Name ='nmr'  value= 'Inova' >Inova<br /><br />
<B>Your Name :</B><input type="text" size="20" maxlength="10" name="UName" required><br /><br />
<B>Enter Date (mm/dd):</B> <input type="text" size="20" maxlength="5" name="ddate"  required><br /><br />
<B>Start Time (hh:mm):</B> <input type="text" size="8" maxlength="5" name="startTime"  required>
<INPUT TYPE = 'Radio' Name ='ToD'  value= 'AM' >AM
<INPUT TYPE = 'Radio' Name ='ToD'  value= 'PM' checked>PM
<br /><br />
<B>Duration:  </B> <input type="text" size="20" maxlength="5" name="duration"  required><br /><br />
<B>Experiment:</B> <input type="text" size="20" maxlength="5" name="Experiment" required><br /><br />
<INPUT TYPE = "Submit" Name = "Submit1"  VALUE = "Submit">
</FORM>
</center>

</body>
</html>
if(isset($_POST['nmr'], $_POST['UName'], ...) {
 $reg_wvar=$_POST['nmr'];
  $reg_UName=$_POST['UName'];
  ...
}