[英]PHP Contact form issue - works in XAMPP not hosted
我有一個網頁另存為contact_us.php,但是在加載(托管)該網頁時,它只是返回空白。
我在這里使用了代碼(帶有綠色勾號和23票的答案): 在提交時使用相同腳本從HTML表單發送PHP電子郵件
我擁有的代碼(在頁面頂部)是:
<?php
if(isset($_POST['submit'])){
$to = "abc123@hotmail.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $first_name . "\n\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 " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
並且(在體內):
<form action="" method="post">
First Name: <input type="text" name="first_name"><br><br>
Last Name: <input type="text" name="last_name"><br><br>
Email: <input type="text" name="email"><br><br>
Message:<br><textarea rows="5" name="message" cols="30"></textarea><br><br>
<input type="submit" name="submit" value="Submit">
</form>
有人可以看到任何錯誤嗎?
我在XAMPP中對其進行了測試,並且運行良好-發送2封電子郵件並表示感謝,等等,但是當我將其“實時”投放時,我會白屏死了?
我現在設法使它正常工作(並浪費大量時間打電話給Go Daddy,但無處可尋)。
唯一的區別是:
<!DOCTYPE html>
<html>
代替
<?xml version=”1.0” encoding=”UTF-8”?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
我還將php代碼放在正文中,而不是放在文檔的頂部,但是我懷疑這有什么區別。
那會有很大的不同嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.