簡體   English   中英

使用模板,重定向至“謝謝您”頁面在我的PHP代碼中不起作用

[英]The redirect to thank you page is not working in my PHP code, using template

我是PHP新手。 我一直在通過網站使用此示例,“重定向至謝謝”頁面無法正常工作,有人可以解決原因嗎? 另外,我也沒有收到自己的電子郵件,我從以下網址獲得了示例代碼: http : //form.guide/email-form/html-email-form.html

下載完整代碼后,它僅重定向到PHP代碼,而不是轉到“謝謝”頁面。

 if( empty($errors)) { $to = $myemail; $email_subject = "Contact form submission: $firstname"; $email_body = "You have received a new message. ". " Here are the details:\\n Name: $firstname \\n Email: $email_address \\n Message \\n $message"; $headers = "From: $myemail\\n"; $headers .= "Reply-To: $email_address"; mail($to,$email_subject,$email_body,$headers); //redirect to the 'thank you' page header('Location: contact-form-thank-you.html'); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Contact form handler</title> </head> <body> <!-- This page is displayed only if there is some error --> <?php echo nl2br($errors); ?> </body> </html> 

你忘了:

<?php

在代碼的第一行。 php解釋器不會弄清楚您的代碼從哪里開始,您會看到php代碼為html。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM