PHP标头未重定向get变量
我有一个页面,它获取上一个页面中输入的数据,并将这些数据输入数据库。然后它获取该帖子的数据库id。我想在头中使用这个id($id),但是当我运行下面的代码时,get变量是空的 代码:PHP标头未重定向get变量,php,forms,header,Php,Forms,Header,我有一个页面,它获取上一个页面中输入的数据,并将这些数据输入数据库。然后它获取该帖子的数据库id。我想在头中使用这个id($id),但是当我运行下面的代码时,get变量是空的 代码: 直到末尾才定义$id 如果要在代码中使用header(),请将ob\u start()放在开头。mysql\u query()是否正在执行其工作(是否插入行)? <?php header("Location: http://localhost/biology/question.php?q=$id");
直到末尾才定义$id
如果要在代码中使用header()
,请将ob\u start()
放在开头。mysql\u query()是否正在执行其工作(是否插入行)?
<?php header("Location: http://localhost/biology/question.php?q=$id"); ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<?php
include '../connect.php';
if (isset($_POST['questionSubmit'])){
$question=mysql_real_escape_string($_POST['question']);
$detail=mysql_real_escape_string($_POST['detail']);
$date=date("d M Y");
$time=time();
$user=$_SESSION['id'];
$put=mysql_query("INSERT INTO questions VALUES ('','$question','$detail','$date','$time','$user','biology','0')");
$id=mysql_insert_id();
}
?>
</body>
</html>