简体   繁体   English

PHP 页面未加载(PHP 联系表)

[英]PHP page not loading (PHP contact form)

So this is the first time using a php doc.所以这是第一次使用 php 文档。 My page worked fine as a .html, in the contact page is a contact form, hence why I have now changed it to a .php file, as the php for the form is at the top of the document.我的页面作为 .html 运行良好,在联系页面中是一个联系表单,因此我现在将其更改为 .php 文件,因为表单的 php 位于文档的顶部。 I have yet to send an email successfully.我还没有成功发送电子邮件。 I am not sure if there is an error in the code, do I need to set something up through CPanel?我不确定代码中是否有错误,是否需要通过 CPanel 进行设置?

https://www.decisive-development.com/contact.php - this is the page that is not loading https://www.decisive-development.com/contact.php - 这是未加载的页面

https://decisive-development.com/ - this is the homepage 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">

the top of the HTML is at the bottom of this snip, the file name is contact.php (from contact.html) so the htaccess rewrite isn't set up yet. HTML 的顶部位于此片段的底部,文件名为 contact.php(来自 contact.html),因此尚未设置 htaccess 重写。

Below is the html on the same page for the form下面是表单的同一页面上的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>

Your problem is right here: if(ifsset( Surely you mean if(isset())你的问题就在这里: if(ifsset(当然你的意思是if(isset())

In the future you can add the following two lines of code to the top of a PHP script to help you find errors:以后你可以在 PHP 脚本的顶部添加以下两行代码来帮助你查找错误:

error_reporting(E_ALL);
ini_set("display_errors", 1);

Further, you'll notice that you get a HTTP 500 error when you visit your page.此外,您会注意到在访问页面时收到 HTTP 500 错误。 This almost always means that you have a syntax error in your PHP code.这几乎总是意味着您的 PHP 代码中有语法错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM