本文介绍了Php不使用在线服务器中的标题功能重定向到成功页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的php页面没有重定向到在线的成功页面,所以很多人说我添加了ob_start()和ob_flush()函数但是没有用,请找到下面的代码。详细信息在数据库中成功输入但不重定向。
我的尝试:
<!DOCTYPE html>
< html>
< body>
<?php
ob_start();
?>
<?php
if(isset($ _ POST ['name'],$ _ POST ['email'],$ _ POST ['mobile'],$ _ POST ['comment']))
{
$ name = $ _POST [name];
$ email = $ _POST [email];
$ mobile = $ _POST [mobile];
$ comment = $ _POST [comment];
echoname:$ name,email:$ email,mobile:$ mobile,comment:$ comment;
$ servername =localhost;
$ username =XXXX;
$ password =****;
$ dbname =$$$$$;
//创建连接
$ conn = mysqli_connect($ servername,$ username,$ password,$ dbname);
//检查连接
if(!$ conn){
die(Connection failed:。mysqli_connect_error());
}
echo已成功连接;
if($ name!=){
echo没有空值;
$ sql =INSERT INTO`customerinfo`(`name`,`email`,`mobile`,`comment`)
VALUES('$ name','$ email','$ mobile' ,'$ comment');
}
if(mysqli_query($ conn,$ sql)){
echo新记录创建成功;
} else {
echo错误:。 $ sql。 <峰; br> 中。 mysqli_error($康恩);
}
mysqli_close($ conn);
}
?>
<?php
header(Location:success.php);
退出;
?>
<?php
ob_end_flush();
?>
< / body>
< / html>
解决方案
My php page is not redirecting to the success page in the online so many said ob_start() and ob_flush() functions I added but there is no use please find the code below.Details are entering successfully in a database but not redirecting.
What I have tried:
<!DOCTYPE html> <html> <body> <?php ob_start(); ?> <?php if(isset($_POST['name'],$_POST['email'],$_POST['mobile'],$_POST['comment'])) { $name = $_POST["name"]; $email = $_POST["email"]; $mobile = $_POST["mobile"]; $comment = $_POST["comment"]; echo "name: $name, email: $email, mobile:$mobile, comment:$comment"; $servername = "localhost"; $username = "XXXX"; $password = "****"; $dbname = "$$$$$"; // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } echo "Connected successfully"; if($name !=""){ echo "There are no null values"; $sql = "INSERT INTO `customerinfo` (`name`, `email`, `mobile`, `comment`) VALUES ('$name', '$email', '$mobile', '$comment')"; } if (mysqli_query($conn, $sql)) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } mysqli_close($conn); } ?> <?php header("Location: success.php"); exit; ?> <?php ob_end_flush(); ?> </body> </html>
解决方案
这篇关于Php不使用在线服务器中的标题功能重定向到成功页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!