[英]i am trying to send an email from my contact us page to email by php but it gives error my code and error given below
this is my html code.这是我的 html 代码。
<!DOCTYPE html>
<html>
<head>
<title>form</title>
</head>
<body>
<form action="send.php" method="post" class="contact-form contact_form_u" id="">
<div class="form-group">
<input class="form-control contact_user_fname" id="user-fname" name="user-fname" type="text" placeholder="First name :" required>
</div>
<div class="form-group">
<input class="form-control contact_user_lname" id="user-lname" name="user-lname" type="text" placeholder="Last name :" required>
</div>
<div class="form-group">
<input class="form-control contact_user_email" id="user-email" name="user-email" type="email" placeholder="Email :" required>
</div>
<div class="form-group">
<input class="form-control contact_user_phone" id="user-phone_" name="user-phone" type="text" placeholder="Phone :" required>
</div>
<div class="form-group">
<textarea class="form-control contact_user_message" name="user-message" id="user-message" placeholder="Message:" required></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-info btn-lg btn--highlight contact_btn_u" id="submit-btn" name="submit-btn">Send </button>
</div>
<div class="form-group">
<a class="btn btn-info btn-lg btn--highlight contact_btn_u_c" id="close_contact" type="submit">Close</a>
</div>
<div id="response"></div>
</form>
</body>
</html>
this is my php code这是我的 php 代码
<?php
if (!isset($_POST["submit"]))
{
echo "error; you need to submit the form";
}
$fname =$_POST["user-fname"];
$lname =$_POST["user-lname"];
$email =$_POST["user-lname"];
$phone =$_POST["user-lname"];
$message =$_POST["user-lname"];
if (empty($fname) || empty($lname) || empty($email) || empty($phone) || empty($message)){
echo "please fill all the fields";
exit;
}
else
{
mail("email@gmail.com", "company Message", $message, "From: $fname <$email>");
echo "<script type='text/javascript'>alert('Your message sent successfully');
window.history.log(-1);
</script>";
}
?>
when i am click on the submit button.it's taking me to send.php page but it's gives me an error which is given below.当我单击提交按钮时。它带我发送。php 页面,但它给了我一个错误,如下所示。 how can i solve it.
我该如何解决。
This page isn't working If the problem continues, contact the site owner.此页面不工作 如果问题仍然存在,请联系网站所有者。 HTTP ERROR 405
HTTP 错误 405
Hi please change button name I think that is the problem in your code.嗨,请更改按钮名称,我认为这是您代码中的问题。
<button type="submit" class="btn btn-info btn-lg btn--highlight contact_btn_u" id="submit-btn" name="submit">Send </button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.