【发布时间】:2017-06-25 10:04:37
【问题描述】:
我想知道这个联系表单出了什么问题。我不知道为什么,但它总是默认为else 并说Something went wrong, please try again later. 我不知道为什么,并且error_log 没有显示任何内容。有什么明显的我想念的吗?我对 PHP 很陌生。
PHP
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$captcha = $_POST['captcha'];
$from = 'From: HankSmith.com Contact Form';
$to = 'thatbraxjohnsonguy@gmail.com';
$subject = 'HANK SMITH CONTACT FORM';
$body = "
From: $name\n
E-Mail: $email\n
Phone: $phone\n
Message: $message\n";
if ($_POST['submit'] and $captcha == 4) {
if (mail ($to, $subject, $body, $from)) {
echo '<p style="margin-top: 150; text-align:center; font-size: 18px;">Your message has been sent! Click <a href="../index.php">here</a> to return to the website.</p>';
} else {
echo '<p>Something went wrong, try again later!</p>';
}
}
?>
HTML 表单
<form class="contactform" method="post" action="php/contact.php">
<h3>Name</h3>
<input class="form inputboxes" type="text" name="name">
<h3>Email</h3>
<input class="form inputboxes" type="text" name="email">
<h3>Phone</h3>
<input class="form inputboxes" type="text" name="phone">
<h3>Message</h3>
<textarea class="form inputboxes" name="message"></textarea>
<h3 class="captchastyle">Are you real? What is 2 + 2?</h3><input class="captcha captchastyle" type="text" name="captcha" maxlength="1">
<input class="form submit" name="submit" type="submit" value="Submit">
</form>
【问题讨论】:
-
可能需要看表格
-
我会用表格更新帖子。
-
发布 html 表单。
-
@RodrigoSartoriJarouche 完成。
标签: php html css forms contact