联系表格php文件找不到服务器

时间:2019-05-28 22:17:34

标签: php

我正在尝试在我的网站上获取联系表格,以便与我的主机提供商(go daddy)一起工作,但是我收到一个错误,这是-

在此服务器上找不到请求的URL / lw ... / index.php。

此外,尝试使用ErrorDocument处理请求时遇到404未找到错误。

我有php表单,在这种情况下,我仅将标头位置index.php部分更改为index.html,但仍然存在问题。另外,我给go daddy打了电话,他们说他们的结局没错,它一定是我的mailer.php文件。我目前正在使用cpanel。

 <?php

   // Get the form fields, removes html tags and whitespace.
   $name = strip_tags(trim($_POST["name"]));
   $name = str_replace(array("\r","\n"),array(" "," "),$name);
   $email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
   $message = trim($_POST["message"]);

   // Check the data.
   if (empty($name) OR empty($message) OR !filter_var($email, 
   FILTER_VALIDATE_EMAIL)) {
   header("Location: 
   http://www.lw.../lw.../index.php? 
   success=-1#form");
    exit;
}

// Set the recipient email address. Update this to YOUR desired email address.
$recipient = "<lw.....com>";

// Set the email subject.
$subject = "New contact from $name";

// Build the email content.
$email_content = "Name: $name\n";
$email_content .= "Email: $email\n\n";
$email_content .= "Message:\n$message\n";

// Build the email headers.
$email_headers = "From: $name <$email>";

// Send the email.
mail($recipient, $subject, $email_content, $email_headers);

// Redirect to the index.html page with success code
header("Location: http://www.lws.co.uk/lws../index.php? 
    success=1#form");

?>

这也是我的html文件中的php代码的片段-

  <div class="form-box" id="form">
            <div class="row">
                <h2>Get in Touch</h2>
            </div>

            <div class="row">
                <form method="post" action="mailer.php" class="contact-form">

                    <div class="row">

                        <?php
                        if($_GET['success'] == 1) {
                            echo "<div class=\"form-messages 
  success\">Thank you! your message has been sent.</div>";
                        }

                        if($_GET['success'] == -1) {
                            echo "<div class=\"form-messages error\"> 
  Oops! something went wrong. Please try again!</div>";
                        }
                        ?>
                    </div>

此外,问题仍然存在,并且错误始终相同。我很感激 任何建议,谢谢您。

0 个答案:

没有答案