提交按鈕在contact-us.html
,代碼在contact-us.php
。用php重定向到上一頁
我試過,沒有運氣使用header('Location: example');
...(我嘗試使用網頁的網址,以及:header('Location: http://www.example.com/contact-us.html');
)
有什麼想法?
<?php
if($_POST["submit"]) {
$recipient="[email protected]";
$subject="Form to email message";
$sender=$_POST["firstname"];
$senderlast=$_POST["lastname"];
$senderemail=$_POST["senderemail"];
$message=$_POST["message"];
$mailBody="First Name: $sender\nLast Name: $senderlast\nEmail: $senderemail\n\nMessage: $message";
header('Location: /contact-us.html'); /*Something Wrong?*/
mail($recipient, $subject, $mailBody, "From: $sender <$senderemail>")
}
你想把用戶發回給聯繫人us.html?你發送電子郵件後的頁面? –
是的!當按鈕被按下時,它進入到PHP頁面並停留在那裏 –
郵件是否發送?可能是'if($ _ POST ['submit'])'是'false'並且頭文件從不設置。 – ImClarky