gpt4 book ai didi

php - 从php中的另一个页面获取变量

转载 作者:行者123 更新时间:2023-11-29 17:34:46 25 4
gpt4 key购买 nike

我想将变量用户名显示到另一个页面。这些是我用过的代码。这是插入用户名的第一页。

<?php
include('login.php'); // Includes Login Script
if(isset($_SESSION['login_user'])){
}
?>

<html>
<head>
<title>Login</title>
</head>
<body>
<div id="login" align="center">
<h2>Welcome!</h2>
<form action="" method="post">
<label>Username :</label>
<input id="name" name="username" placeholder="username" type="text"><br>
<label>Password :</label>
<input id="password" name="password" placeholder="**********" type="password"><br><br>
<input name="submit" type="submit" value=" Login ">
<span><?php echo $error; ?></span>
</form>
</div>
</body>
</html>

然后在这个页面中我想显示插入的用户名

<?php include 'database.php'; ?>
<?php session_start(); ?>
<?php
function visualizza($file) {
$f = fopen($file, "r"); // apro il file in lettura
return fread($f, filesize($file));
fclose($f);
}
?>
<html>
<main>
<div class="container">
<h2> Quiz Completato!</h2>
<p> Congratulations <?php
$username = $_POST['username'];
echo $username;
?>

! You completed the test</p>
<p>Final Score:<?php echo $_SESSION['score']; ?> </p>
</div>
</main>

但它告诉我注意:未定义索引:第 29 行 C:\xampp\htdocs\quizzer\final.php 中的用户名请问如何解决?

最佳答案

应该可以改变

<form action="" method="post">

<form action="final.php" method="post">

关于php - 从php中的另一个页面获取变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50379943/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com