点击提交时,系统将引发错误,
此页面不起作用如果问题仍然存在,请与网站所有者联系。 HTTP错误405
HTML(index.html)。
我已经为form.php创建了一个单独的文件,用于PHP表单提交(提供给action属性)
<form method="post" action="form.php" class="contact-form row" data-sal="zoom-in" data-sal-duration="800">
<div class="form-field col x-50" id="contact_page">
<input type="text" id="name" class="input-text" name="sender_name" required>
<label for="name" class="label">Name</label>
</div>
<div class="form-field col x-50">
<input type="email" id="email" class="input-text" name="sender_mail" required>
<label for="email" class="label">Email</label>
</div>
<div class="form-field col x-100">
<input type="text" id="message" class="input-text" name="sender_message" required>
<label for="message" class="label">Message</label>
</div>
<div class="form-field col x-100 align-center">
<input type="submit" name="submit" class="submit-btn" value="Submit">
</div>
</form>
我认为不需要CSS
PHP
<?php
if($_POST["submit"]) {
$recipient="subinsamrat96@gmail.com";
$subject="Form to email message";
$sender=$_POST["sender_name"];
$senderEmail=$_POST["sender_mail"];
$message=$_POST["sender_message"];
$mailBody = "Name: $sender\nEmail: $senderEmail\n\n $message";
mail($recipient, $subject, $mailBody, "From: $sender <$senderEmail>");
$thankYou = "<p>Thank you! Your message has been sent. </p>";
}
?>