为什么我会得到"未定义的索引"?

mag*_*gna 1 html javascript css php forms

目前我正在开发联系我们,当我在localhost上运行该脚本时,我的问题是什么,错误中的名称字段和电子邮件字段如下所示:

(<br /><b>Notice</b>:  Undefined index: name in <b>E:\wamp\www\rrr\btech\index.php</b> on line <b>49</b><br />)
(<br /><b>Notice</b>:  Undefined index: email in <b>E:\wamp\www\rrr\btech\index.php</b> on line <b>49</b><br />)
Run Code Online (Sandbox Code Playgroud)

单击提交后,响应将是未定义的语法错误.

<tr>
<td valign="bottom"><span class="contactus-txt">
  <input name="textfield222" type="text" class="contact-field" style="width:125px;"   value="<?php echo $_GET['name'];?>" />
</span></td>
<td valign="bottom"><span class="contactus-txt">
  <input name="textfield2222" type="text" class="contact-field" style="width:125px;"  value="<?php echo $_GET['Email-Id'];?>"/>
</span></td>
</tr>
Run Code Online (Sandbox Code Playgroud)

我使用了那个HTML代码.

谁能告诉我我犯了什么错误?

You*_*nse 7

这是正确的方式:

<?php
$FORM['name'] = "";
$FORM['Email-Id'] = "";
if (isset($_GET['name'])) $FORM['name'] = htmlspecialchars($_GET['name']);
if (isset($_GET['Email-Id'])) $FORM['Email-Id'] = htmlspecialchars($_GET['Email-Id']);
?>
<tr>
<td valign="bottom"><span class="contactus-txt">
  <input name="textfield222" type="text" class="contact-field" style="width:125px;"   value="<?php echo $FORM['name'];?>" />
</span></td>
<td valign="bottom"><span class="contactus-txt">
  <input name="textfield2222" type="text" class="contact-field" style="width:125px;"  value="<?php echo $FORM['Email-Id'];?>"/>
</span></td>
Run Code Online (Sandbox Code Playgroud)

所有变量应在使用前初始化.