0
我的表單有姓名,電子郵件,電話&消息字段不起作用。當我提交表單時,空白頁面將以php郵件處理程序url打開。它應該顯示感謝信息。電子郵件ID也不會收到電子郵件。請幫忙。PHP表單不能正常顯示空白頁面
我的HTML表單代碼是
<form id="contactform" action="contact_form.php" method="POST">
<div>
<input type="text" class="form-control" placeholder="Name" name="name" required id="name">
</div>
<div>
<input type="email" class="form-control" placeholder="Email" name="email" required id="email">
</div>
<div>
<input type="text" class="form-control" placeholder="Phone" required name="phone" id="phone">
</div>
<textarea class="form-control" name="message" id="message" rows="4" placeholder="Enter Your Message" required></textarea>
<div class="text-center">
<button type="submit" value="submit" class="btn btn-default">SUBMIT</button>
</div>
</form>
PHP代碼的郵件
<?php
if(isset($_POST['submit'])){
$to = "[email protected]"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$name = $_POST['name'];
$phone = $_POST['phone'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = "Name:". $name . "\n" . "Phone:" . $phone . "\n" . "\n" . "Message:" . "\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . "\n" . "Name:" . $name . "\n" . "Phone:" . $phone . "\n" . "\n" . "Message:" . "\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you, " . $name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
// You cannot use header and echo together. It's one or the other.
}
?>
的形式是在這個頁面的底部 https://www.delveindia.com/products/billing-software/
如果它在本地,那麼你需要做一些更多的東西。搜索如何通過PHP中的本地主機發送郵件,你會得到大量的例子。 –
它託管在Cpanel服務器上。 – 1bunty1
要求您的服務器提供商在您的服務器上進行郵件設置。沒有郵件將不會發送 –