Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.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发送表单,一旦发送了联系人信息,它就会转到另一个url?_Php - Fatal编程技术网

如何使用php发送表单,一旦发送了联系人信息,它就会转到另一个url?

如何使用php发送表单,一旦发送了联系人信息,它就会转到另一个url?,php,Php,我想做的是,当我点击submit时,它会进入索引页面,而不是停留在php页面上 这是我的密码 $name = $_POST[\'name\']; $email = $_POST[\'email\']; $phone = $_POST[\'phone\']; $reason = $_POST[\'reason\']; $header = \'From: \' . $email . \" \\r\\n\"; $msg = \"Sent from: \" . $name . \"\\r\\n\";

我想做的是,当我点击submit时,它会进入索引页面,而不是停留在php页面上 这是我的密码

$name = $_POST[\'name\'];
$email = $_POST[\'email\'];
$phone = $_POST[\'phone\'];
$reason = $_POST[\'reason\'];

$header = \'From: \' . $email . \" \\r\\n\";

$msg = \"Sent from: \" . $name . \"\\r\\n\";
$msg .= \"Email: \" . $email . \" \\r\\n\";
$msg .= \"Phone: \" . $phone . \" \\r\\n\";
$msg .= \"Contact reason:\" . $reason . \" \\r\\n\";
$msg .= \"Message: \" . $_POST[\'message\'] . \" \\r\\n\";
$msg .= \"Date and time \" . date(\'d/m/Y\', time());

$to = \'emailhere@something.com\';
$subject = \'contact page\';

mail($to, $subject, utf8_decode($msg), $header);

echo \'The Message is sent\';
我想知道是否有人能帮我?我觉得不太难吧

header("Location: http://www.example.com/");

有关更多信息,请参见

为什么要逃避所有这些引用

$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$reason = $_POST['reason'];

$header = 'From: ' . $email . "\r\n";

$msg = "Sent from: " . $name . "\r\n";
$msg .= "Email: " . $email . "\r\n";
$msg .= "Phone: " . $phone . "\r\n";
$msg .= "Contact reason:" . $reason . "\r\n";
$msg .= "Message: " . $_POST['message'] . "\r\n";
$msg .= "Date and time " . date(\'d/m/Y\', time());

$to = 'emailhere@something.com';
$subject = 'contact page';

mail($to, $subject, utf8_decode($msg), $header);

// redirect to page
$url = 'http://example.com';
header('Location: '.$url); // must be used before any output to the browser
die; // prevent execution of other code
您只需要转义要以字符串形式显示的引号

e、 g:

将显示:

这是一个“测试”

或者你可以:

$test = 'This is a "test"';
您可以使用标题(“位置:”)重定向到 您网站的index.php


在出现任何问题之前,必须调用header()方法,如echo“发送消息”

我刚刚找到了所有这些php代码。。4.我真的不知道还有别的办法。。但是谢谢你让我知道!!
$test = 'This is a "test"';