在为自己设置网站的过程中,我使用PHP联系表单打了一个路障。我相信它编码正确,但无论何时我将其上传到我的网站并尝试使用联系表格,我都会被禁止使用403"。我顺便使用Hostinger,我已将public_html文件的权限设置为755.不确定问题是什么。包括我的代码,任何帮助将不胜感激。
从索引中联系HTML代码:
<div class="row stay-behind" id="contact">
<h4 class="right-name">Contact</h4>
<div class="col-md-1"></div>
<div class="col-sm-12 col-md-4 feature-image"><img alt="VX1K" height="510" src="images/ux/004.jpg" width="374"> <img alt="VX1K" class="mobile-only" src="images/ux/mobile/004.jpg"></div>
<div class="col-sm-12 col-md-6 main">
<h3 class="title">Contact</h3>
<form class="contact-form" id="contactForm" novalidate method="post" action="public_html/mail/contact_me.php">
<div id="form-alert"></div>
<div class="form-group">
<input class="form-control" id="name" name="name" placeholder="Name" type="name">
</div>
<div class="form-group">
<input class="form-control" id="email" name="email" placeholder="Email" type="email">
</div>
<textarea class="form-control" id="message" placeholder="Message" rows="3"></textarea> <input class="btn btn-block btn-primary" id="btnSubmit" name="submit" type="submit" value="Send">
</form>
</div>
<div class="col-md-1"></div>
&#13;
PHP文件中的代码。
<?php
function Validate()
{
// Check for empty fields
if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
{
return false;
}
else return true;
}
function SendEmail($to = 'noreply@vx1k.com')
{
if (Validate() == true)
{
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
// Create the email and send the message
$email_subject = "Website Contact Form: $name";
$email_body = "You have received a new message from your website contact form.\n\n" . "Here are the
details:\n\nName: $name\n\nEmail: $email_address\n\nMessage:\n$message";
$headers = "From: noreply@vx1k.com\n";
$headers.= "Reply-To: $email_address";
// Send true on successful send.
// Send false if failed
return (mail($to, $email_subject, $email_body, $headers)) ? true : false;
}
else
// Invalid inputs
return 'err';
}
// Apply function(s). You will get true, false, or err
$send = SendEmail();
// On return, you can echo any result
if ($send == 'err') echo 'Invalid Fields.';
elseif ($send == false) echo 'An Error Occurred.';
else echo 'Email Sent Successfully.';
?>