Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP未识别索引,单独的PHP和html文件_Php_Html - Fatal编程技术网

PHP未识别索引,单独的PHP和html文件

PHP未识别索引,单独的PHP和html文件,php,html,Php,Html,我知道这个话题已经涉及太多了,但我仍然在回避一个解决方案。我在这个php文件中不断得到一个未识别的索引错误: 感谢您提交申请 以下是我们收到的信息: 名称: 电话: 电子邮件: 生日: 性别: 当你第一次想成为一名动物园管理员时: 以下是此php文件从中获取其值的html表单: <form id="zooKeeperForm" action="zoo.php" method="GET" onsubmit="return validateForm()"> <p>

我知道这个话题已经涉及太多了,但我仍然在回避一个解决方案。我在这个php文件中不断得到一个未识别的索引错误:


感谢您提交申请
以下是我们收到的信息:
名称:
电话:
电子邮件:
生日:
性别:
当你第一次想成为一名动物园管理员时:
以下是此php文件从中获取其值的html表单:

<form id="zooKeeperForm" action="zoo.php" method="GET" onsubmit="return validateForm()">
  <p><i>Please complete the form. Mandatory fields are marked with a </i><em>*</em></p>
  <fieldset>
    <legend>Contact Details</legend>
      <label for="name">Name <em>*</em></label>
      <input id="name" placeholder="Jane Smith" autofocus required><br>
      <label for="telephone">Telephone</label>
      <input id="telephone" placeholder="(xxx) xxx-xxxx"><br>
      <label for="email">Email <em>*</em></label>
      <input id="email" type="email" required><br>
  </fieldset>
  <fieldset>
    <legend>Personal Information</legend>

      <label for="birthDate">Birth Date<em>*</em></label>
      <input id="birthDate" type="date" required><br>

      <label for="age">Age<em>*</em></label>
      <input id="age" type="number" min="0" max="120" step="0.1" required><br>
      <label for="gender">Gender</label>
      <select id="gender">
        <option value="female">Female</option>
        <option value="male">Male</option>
      </select><br>
      <label for="comments">When did you first know you wanted to be a zoo-keeper?<em>*</em></label>
      <textarea id="comments" oninput="validateComments(this)" required></textarea>
  </fieldset>
  <p><input type="submit" value="Submit Application"></p>
</form>

请填写表格。必填字段标记为*

联系方式 名字*
电话
电子邮件*
个人信息 出生日期*
年龄*
性别 女性 男性
你什么时候第一次知道你想成为一名动物园管理员*

我在这里做错了什么??我觉得自己像个白痴。我不断地从获取未识别的索引错误到它打印出我想要的格式,但是对于所有应该插入的值,它都是空白的

第一件事:

改成POST

<form id="zooKeeperForm" action="zoo.php" method="POST" onsubmit="return validateForm()">
                                             //  ^ POST not GET

//^POST无法获取
第二。名称属性是要使用的属性,而不是ID

<input id="name" placeholder="Jane Smith" autofocus required>
      // NOT ID but name="name"

//不是ID而是name=“name”
这必须是:

<input name="telephone" placeholder="(xxx) xxx-xxxx" id="telephone" />
<input name="email" type="email" required id="email" />
<input name="birthDate" type="date" required id="birthDate" />
<select name="gender" id="gender">
<textarea name="comments" oninput="validateComments(this)" id="comments" required>

第三:

这里简单的一点是,在提交表单时,始终处理表单输入。不是在初始负载时

使用以下内容捕获提交内容:

<input type="submit" name="zoo_submit" value="Submit Application" />

然后在PHP中:

// simple initialization
$name = $telephone = $email = $birthDate = $gender = $comments = '';

if(isset($_POST['zoo_submit'])) {

  $name = isset($_POST['name']) ? $_POST['name'] : '';
  $telephone = isset($_POST['telephone']) ? $_POST['telephone'] : '';
  $email = isset($_POST['email']) ? $_POST['email'] : '';
  $birthDate = isset($_POST["birthDate"]) ? $_POST['birthDate'] : '';
  $gender = isset($_POST['gender']) ? $_POST['email'] : '';
  $comments = isset($_POST['comments']) ? $_POST['comments'] : '';

}
?>

Thanks for submitting your application!<br>
The following is the information we received:<br>

<!-- now you have already set the variables above, use them, not the POST values again -->
Name: <?php echo $name; ?><br>
Telephone: <?php echo $telephone; ?><br>
E-Mail: <?php echo $email; ?><br>
Birthday: <?php echo $birthDate; ?><br>
Gender: <?php echo $gender; ?><br>
When you first wanted to be a zookeeper: <?php echo $comments; ?>
//简单初始化
$name=$telephone=$email=$birthDate=$gender=$comments='';
如果(isset($_POST['zoo_submit'])){
$name=isset($_POST['name'])?$_POST['name']:'';
$telephone=isset($_POST['telephone'])?$_POST['telephone']:'';
$email=isset($_POST['email'])?$_POST['email']:'';
$birthDate=isset($_POST[“birthDate”])?$_POST[“birthDate”]:'';
$SEXT=isset($_POST['SEXT'])?$_POST['email']:'';
$comments=isset($_POST['comments'])?$_POST['comments']:'';
}
?>
感谢您提交申请
以下是我们收到的信息:
名称:
电话:
电子邮件:
生日:
性别:
当你第一次想成为一名动物园管理员时:
boom!那次编辑就是诀窍。它基于名称而不是id。我发誓,这需要在互联网上的数百个php线程上发布。谢谢你,先生@用户3547373很高兴这有帮助
// simple initialization
$name = $telephone = $email = $birthDate = $gender = $comments = '';

if(isset($_POST['zoo_submit'])) {

  $name = isset($_POST['name']) ? $_POST['name'] : '';
  $telephone = isset($_POST['telephone']) ? $_POST['telephone'] : '';
  $email = isset($_POST['email']) ? $_POST['email'] : '';
  $birthDate = isset($_POST["birthDate"]) ? $_POST['birthDate'] : '';
  $gender = isset($_POST['gender']) ? $_POST['email'] : '';
  $comments = isset($_POST['comments']) ? $_POST['comments'] : '';

}
?>

Thanks for submitting your application!<br>
The following is the information we received:<br>

<!-- now you have already set the variables above, use them, not the POST values again -->
Name: <?php echo $name; ?><br>
Telephone: <?php echo $telephone; ?><br>
E-Mail: <?php echo $email; ?><br>
Birthday: <?php echo $birthDate; ?><br>
Gender: <?php echo $gender; ?><br>
When you first wanted to be a zookeeper: <?php echo $comments; ?>