0
我想知道如何使其點擊我的提交按鈕,並且URL不會更改。現在,當我點擊它時,它只是向我發送操作頁面。點擊提交後重定向頁面
PHP代碼是
<?php
// Check for empty fields
if(empty($_POST['name']) \t \t ||
empty($_POST['email']) \t \t ||
empty($_POST['message']) \t ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
\t echo "No arguments Provided!";
\t return false;
}
\t
$name = strip_tags(htmlspecialchars($_POST['name']));
$email_address = strip_tags(htmlspecialchars($_POST['email']));
$message = strip_tags(htmlspecialchars($_POST['message']));
\t
// Create the email and send the message
$to = '[email protected]'; // Add your email address inbetween the '' replacing [email protected] - This is where the form will send a message to.
$email_subject = "Website Contact Form: $name";
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nMessage:\n$message";
$headers = "From: [email protected]\n"; // This is the email address the generated message will be from. We recommend using something like [email protected]
$headers .= "Reply-To: $email_address"; \t
mail($to,$email_subject,$email_body,$headers);
return true; \t \t
?>
我在想,如果有人可以幫我做它,所以它停留在頁面而不是重定向。
嘗試重定向回用'頭:;'完成後郵寄( '位置' $ _ SERVER [ 'HTTP_REFERER'])。 –
我會在那裏放置,我試過了代碼的結束,它沒有工作 – wot
沒關係。作品:)。 TY – wot