PHP注册表单不显示


PHP Registration Form Not Showing

这是我的PHP代码:

<?php
require('config.php');
if(isset($_POST['submit'])){
 $email = $_POST['email'];
 $email2 = $_POST['email2'];
 $password = $_POST['password'];
 $password2 = $_POST['password2'];
 if($password == $password2){
  if($email == $email2){
   //All good, carry on the registration.
  }else{
   echo "Oh no! We can't sign you up; please double-check your passwords match.<br />";
   exit();
  }
 }else{
  echo "Oh no! We can't sign you up; please double-check your emails match.<br /><br />";
 }

$form = <<<EOT
<form action="register.php" method="POST">
Username: <input type="text" name="name" /><br />
Email: <input type="text" name="email" /><br />
Confirm Email: <input type="text" name="email2" /><br />
Password: <input type="password" name="password" /><br />
Confirm Password: <input type="password" name="password2" /><br />
<input type="submit" value="Play!" name="submit" />
</form>
EOT;
echo $form;
}

?>

由于这样或那样的原因,echo $form;不工作,因为它没有显示注册表单。

谁能解释一下如何使内容显示在$form = <<<EOT</form>之间

你在if(isset($_POST['submit'])){语句中有echo $form;和表单本身这意味着它们不会显示,直到你点击提交,你不能因为表单不在那里,移动表单上方的卷括号,应该是这样的:

<?php
require('config.php');
if(isset($_POST['submit'])){
$email = $_POST['email'];
$email2 = $_POST['email2'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
if($password == $password2){
if($email == $email2){
 //All good, carry on the registration.
}else{
 echo "Oh no! We can't sign you up; please double-check your passwords match.<br />";
exit();
}
}else{
echo "Oh no! We can't sign you up; please double-check your emails match.<br /><br />";
}
}
$form = <<<EOT
<form action="register.php" method="POST">
Username: <input type="text" name="name" /><br />
Email: <input type="text" name="email" /><br />
Confirm Email: <input type="text" name="email2" /><br />
Password: <input type="password" name="password" /><br />
Confirm Password: <input type="password" name="password2" /><br />
<input type="submit" value="Play!" name="submit" />
</form>
EOT;
echo $form;
 ?>