还在学习PHP。我正在尝试制作一个表格,将其信息邮寄给电子邮件。我使用wampserver,php永远不会给我一个错误。请检查一下,告诉我这是我的代码中的问题,还是本地服务器无法发送电子邮件。我尝试“配置”我的wampserver但最终我弄乱了我的Apache和PHP。所以我需要帮助。 这是我的HTML
<div class="container">
<div class="col-md-6 wrapper col-md-offset-3">
<h2>Sign Up</h2>
<?php echo $result; ?>
<p class="lead">Please fill in your credentials below: </p>
<form class="form-group" method="post">
<label for="first_name">First Name</label>
<input name="first_name" class="form-control" type="text" value="<?php echo $_POST['first_name']; ?>"/>
<label for ="last_name">Last Name</label>
<input name = "last_name" class="form-control" type="text" value="<?php echo $_POST['last_name']; ?>"/>
<label for ="Username">Username</label>
<input name="Username" class="form-control" type="text" value="<?php echo $_POST['Username']; ?>"/>
<label for="email">Email</label>
<input name="email" class="form-control" type="email" value="<?php echo $_POST['email']; ?>"/>
<label for ="password">Password</label>
<input name ="password" class="form-control" type="password" value="<?php echo $_POST['password']; ?>"/>
<label for="confirm_password">Confirm Password</label>
<input name="confirm_password" class="form-control" type="password" value="<?php echo $_POST['confirm_password']; ?>"/>
<input type="submit" name="submit" class="form-control btn" id="submit" value="Submit" />
</form>
<p>Already a user? <a href="#">Sign in</a></p>
</div>
</div>
</body>
这是我的PHP
<?php
if ($_POST["submit"]){
if (!$_POST["first_name"]){
$error="<br />Please enter your First Name";
}
if (!$_POST["last_name"]){
$error.="<br />Please enter your Last Name";
}
if (!$_POST["Username"]){
$error.="<br />Please enter a Username";
}
if (!$_POST["email"]){
$error.="<br />Please enter an email";
} if ($_POST["email"]!= "" AND !filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
$error.="<br />Please enter a valid email address";
}
if (!$_POST["password"]){
$error.="<br />Please enter a password";
}
if (!$_POST["confirm_password"]){
$error.="<br />Please confirm your password";
}
if ($_POST["password"]!=$_POST["confirm_password"]){
$error.="<br />Please enter matching passwords";
}
$result = '<strong style="color:red;"><span>There were error(s) in your form:'.$error.'</span></strong><br />';
if($error==""){
$to="eapriok@gmail.com"; $subject="New Member to Chuk's site";
if( mail($to, $subject, "Name $_POST[\"first_name\"] $_POST[\"last_name\"] and his Username is $_POST[\"Username\"]. Password is $_POST[\"password\"]." )){
$result='<div class="alert alert-info">You have been signed in successfully. Please wait while we take you to your dashboard</div>';
}else{
$result='<div class="alert alert-danger">Something went wrong and we couldn\'t complete the registration. Please try again.</div>';
}
}
}
?>
现在这是PHP抛出的错误,“(!)解析错误:语法错误,意外''(T_ENCAPSED_AND_WHITESPACE),期待C中的标识符(T_STRING)或变量(T_VARIABLE)或数字(T_NUM_STRING) :\ wamp \ www \ php \ contactform.php第56行“
我真的很沮丧......