我想把这个页面的朋友名复制到下一个页面并在那里回显。问题是它是 showinh undefined vairable 。目标是将相同的朋友名值回显到下一页,即 form2.php 并在那里回显
<?php
include("config.php");
session_start();
$user=$_POST['username'];//username
$friendname=$_POST['friendname'];//friendname
$years=$_POST['years'];
$nickname=$_POST['nickname'];
$place=$_POST['place'];//username
$sql = "INSERT INTO data (username,friendname,years,nickname,place)
VALUES ('$user', '$friendname', '$years','$nickname','$place')";
if ($con->query($sql) === TRUE) {
$_POST['friendname']=$frnd;//username
header('location: ../form2.php');
} else {
echo "Error: " . $sql . "<br>" . $con->error;
}
$con->close();
?>
这是我尝试过但不起作用 insert.php
<?php
include("config.php");
session_start();
$user=$_POST['username'];//username
$friendname=$_POST['friendname'];//friendname
$years=$_POST['years']
$nickname=$_POST['nickname'];
$place=$_POST['place'];
$sql = "INSERT INTO data (username,friendname,years,nickname,place)
VALUES ('$user', '$friendname', '$years','$nickname','$place')";
if ($con->query($sql) === TRUE) {
$_POST['friendname']=$frnd;//username
header('location: ../form2.php');
} else {
echo "Error: " . $sql . "<br>" . $con->error;
}
$con->close();
?>
表单2.php
<?php
session_start();
if (!isset($_SESSION['username'])) {
}
if (isset($_GET['logout'])) {
}
?>
<html>
<body>
<p><?php echo $_SESSION['username']; ?></p>
<h4>Enter some details for your friend <?php echo $frnd;?></h4>
<form>
</form>
</body>
</html>
注意:行号上的未定义索引变量 frnd
Cats萌萌
摇曳的蔷薇