我已經(jīng)閱讀了所有有關(guān)將標(biāo)頭插入php表單文件中以便在提交表單后將用戶(hù)重定向到另一個(gè)URL的文章-但我不知道該怎么做。下面是我的代碼。您能告訴我在哪里放置標(biāo)題/重定向,以便通過(guò)電子郵件發(fā)送信息,然后用戶(hù)轉(zhuǎn)到另一個(gè)html頁(yè)面嗎? <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "pecraig@moneymovers.com"; $email_subject = "Mailing List Form"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['company']) || !isset($_POST['street']) || !isset($_POST['city']) || !isset($_POST['state']) || !isset($_POST['zip'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // required $company = $_POST['company']; // required $street = $_POST['street']; // required $city = $_POST['city']; // required $state = $_POST['state']; // required $zip = $_POST['zip']; // required $error_message = ""; $string_exp = "/^[A-Za-z0-9 .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';<?php}?>
3 回答

慕田峪4524236
TA貢獻(xiàn)1875條經(jīng)驗(yàn) 獲得超5個(gè)贊
之后 @mail($email_to, $email_subject, $email_message, $headers);
header('Location: nextpage.php');
請(qǐng)注意,您將永遠(yuǎn)不會(huì)看到“感謝您訂閱我們的郵件列表”
那應(yīng)該在下一頁(yè)上,如果您回顯任何文本,您將得到一個(gè)錯(cuò)誤,因?yàn)闃?biāo)頭已經(jīng)被創(chuàng)建,如果您要重定向,則永遠(yuǎn)不會(huì)返回任何文本,甚至也不是空格!
- 3 回答
- 0 關(guān)注
- 603 瀏覽
添加回答
舉報(bào)
0/150
提交
取消