Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 提交信息后如何重定向我的表单?_Php_Forms_Email_Contact - Fatal编程技术网

Php 提交信息后如何重定向我的表单?

Php 提交信息后如何重定向我的表单?,php,forms,email,contact,Php,Forms,Email,Contact,我终于得到了我的表格信息发送到我的电子邮件,但我的表格网页仍然有问题。当我点击提交按钮时,浏览器不会刷新页面,而是转到我的php.file,其中显示一个黑色页面。我正在尝试将页面重新定向回表单网页(不使用java脚本) 以下是我到目前为止的代码,包括PHP文件: <form method="post" action="PHP_Email_Form.php"> <p style="font-family:Arial, He

我终于得到了我的表格信息发送到我的电子邮件,但我的表格网页仍然有问题。当我点击提交按钮时,浏览器不会刷新页面,而是转到我的php.file,其中显示一个黑色页面。我正在尝试将页面重新定向回表单网页(不使用java脚本)

以下是我到目前为止的代码,包括PHP文件:

 <form method="post" action="PHP_Email_Form.php">
                            <p style="font-family:Arial, Helvetica, sans-serif; color:#FFF; font-size:12px; 
                            font-weight:bold"><label>First Name:
                                <input type="text" name="First Name" size="30" maxlength="30"
                                style="margin-left:27px"  />
                            </label></p>
                            <p style="font-family:Arial, Helvetica, sans-serif; color:#FFF; font-size:12px; 
                            font-weight:bold"><label>Last Name:
                                <input type="text" name="Last Name" size="30" maxlength="30" 
                                style="margin-left:27px"  />
                            </label></p>
                            <p style="font-family:Arial, Helvetica, sans-serif; color:#FFF; font-size:12px; 
                            font-weight:bold"><label>Phone Number:
                                <input type="text" name="Phone Number" size="30" maxlength="10"  
                                style="margin-left:5px" />
                            </label></p>
                            <p style="font-family:Arial, Helvetica, sans-serif; color:#FFF; font-size:12px; 
                            font-weight:bold"><label>Email:
                                <input type="text" name="Email" size="30" maxlength="30"  
                                style="margin-left:59px" />
                            </label></p>
                            <p style="margin-top:19px; margin-left:244px;">
                                <input type="submit" value="submit"  />
                            </p>

                        </form>

名字:

姓氏:

电话号码:

电子邮件:

PHP文档:

 <?php
 $to = 'dew02d@yahoo.com';
 $subject = 'test email form';
 $message= '';
 foreach ($_POST as $key => $value)
 {
     $message .= $key . ': ' . $value . PHP_EOL;
 }
 mail($to, $subject, $message);
 ?>

成功发送电子邮件后使用php标题重定向:

<?php
...
...
mail($to, $subject, $message);

header("Location: successmessage.php"); // Redirect browser

/* Make sure that code below does not get executed when we redirect. */
exit;

您还没有从PHP输出任何内容,所以您可以只发送一个头来重定向

<?php

// ... send email

header('Location: /backToMyForm.html');

?>