<?php
require('config.php');
if(isset($_post['submit'])){
//Perform Verification
$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
if($email1 == email2) {
$firstName = mysql_escape_string($_POST['firstName']);
$lastName = mysql_escape_string($_POST['lastName']);
$username = mysql_escape_string($_POST['username']);
$email1 = mysql_escape_string($email1);
$email2 = mysql_escape_string($email2);
$phone = mysql_escape_string($_POST['phone']);
$sql = mysql_query("SELECT * FROM `websiteAccount` WHERE `username` = '$username'");
if(mysql_num_rows($sql) > 0) {
echo "Sorry, that usename is already in use.";
exit();
}
mysql_query("INSERT INTO `websiteAccount` (`id`, `firstName`, `lastName`, `username` `email`, `phone`) VALUES (NULL, '$firstName', '$lastName', '$username', '$email1', '$phone')");
}else{
echo "Emails do not match";
}
}else{
$form = <<<EOT
<form action="register.php" method="post">
First Name:<br><input type="text" name="firstName"><br>
Last Name:<br><input type="text" name="lastName"><br>
Username:<br><input type="text" name="username"><br>
Email:<br><input type="text" name="email1"><br>
Confirm Email:<br><input type="text" name="email2"><br>
Phone:<br><input type="text" name="phone"><br>
<inpu type="submit" value="Register" name="submit">
</form>
EOT;
echo $form;
}
?>
当我尝试在PHP服务器中打开此代码时: 我收到一条消息说 解析错误:语法错误,第48行/Applications/XAMPP/xamppfiles/htdocs/Web/register.php中的意外文件结尾
答案 0 :(得分:2)
http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
警告
注意具有结束标识符的行非常重要 必须不包含其他字符,分号(;)除外。
EOT;
^
您需要删除这个额外的空间。