我正在尝试在第二页上使用会话变量$_SESSION['name']
,即review.php
。
但是在第二页上却没有任何帮助我如何在第二页上使用Session变量?
这是index.php
<?php
session_start();
$connect = mysqli_connect('localhost','root','root','review');
if(isset($_POST['submit']))
{
$id = $_POST['id'];
$_SESSION['name'] = $id;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>
login
</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
</head>
<body>
<form action="review.php">
<input type="text" name="id" placeholder="id">
<input type="password" name="password" placeholder="password">
<input type="submit" name="submit" class="btn btn-success">
</form>
</body>
</html>
这是review.php
<?php
session_start();
$connect = mysqli_connect('localhost','root','root','review');
if(isset($_SESSION['name']))
{
echo $_SESSION['name'];
}
else{
echo "nothing";
}
?>
答案 0 :(得分:0)
您有2个问题:
{
"edges": [
{
"node": {
"id": "121323",
"slug": "path1",
"information": {
"propertyID": "property1"
}
}
},
{
"node": {
"id": "332342",
"slug": "path2",
"information": {
"propertyID": "property2"
}
}
},
{
"node": {
"id": "123234",
"slug": "path3",
"information": {
"propertyID": "property3"
}
}
}
]
}
,因此您应该阅读review.php
中的表单数据review.php
。默认情况下,method
是method
,但是您读了GET
变量。 (What is the default form HTTP method?)因此,您应按以下步骤更改$_POST
:
index.php