![](/img/trans.png)
[英]Loading a PHP Contact Form Into an Iframe that is on a Seperate HTML Page?
[英]PHP page not loading (PHP contact form)
所以这是第一次使用 php 文档。 我的页面作为 .html 运行良好,在联系页面中是一个联系表单,因此我现在将其更改为 .php 文件,因为表单的 php 位于文档的顶部。 我还没有成功发送电子邮件。 我不确定代码中是否有错误,是否需要通过 CPanel 进行设置?
https://www.decisive-development.com/contact.php - 这是未加载的页面
https://decisive-development.com/ - 这是主页
<?php
$message_sent = false;
if(ifsset($_POST['email']) && $_POST['email'] != ''){
if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {
$userName = $_POST['name'];
$userEmail = $_POST['email'];
$messageSubject = $_POST['subject'];
$message = $_POST['message'];
$to = "tom@decisive-development.com";
$body = "";
$body .= "From: ".$userName. "\r\n";
$body .= "Email: ".$userEmail. "\r\n";
$body .= "Message: ".$message. "\r\n";
mail($to,$messageSubject,$body);
$message_sent = true;
}
}
?>
<html lang="en" dir="ltr">
HTML 的顶部位于此片段的底部,文件名为 contact.php(来自 contact.html),因此尚未设置 htaccess 重写。
下面是表单的同一页面上的html
<form class="contact-form" action="contact.php" method="POST">
<input class="contact-form-text" type="text" name="name" id="name" placeholder="Full name" tabindex="1" required>
<input class="contact-form-text" type="email" name="email" id="email" placeholder="Your E-mail" tabindex="2" required>
<input class="contact-form-text" type="text" name="subject" id="subject" placeholder="Subject" tabindex="3" required>
<textarea class="contact-form-text" name="message" placeholder="Message" tabindex="4"></textarea>
<button class="contact-form-button" type="submit" name="submit">Send</button>
</form>
你的问题就在这里: if(ifsset(
当然你的意思是if(isset())
以后你可以在 PHP 脚本的顶部添加以下两行代码来帮助你查找错误:
error_reporting(E_ALL);
ini_set("display_errors", 1);
此外,您会注意到在访问页面时收到 HTTP 500 错误。 这几乎总是意味着您的 PHP 代码中有语法错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.