我有这个表格
<form action="" method="GET">
<label>NAME:</label>
<input type="text" name="name" id="name" required/>
<button>GET</button>
</form>
<?php
if (isset($_GET['name'])){
$name = $_GET['name'];
echo "hello".$name;}
?>
如果输入一个名称“google” 之后我再次进入“示例”
当我输入另一个名字时,有什么方法可以显示最近输入的名字吗?
答案 0 :(得分:1)
我认为足以解决问题的代码将是
<?php
if(!isset($_GET["name"]){
print "the name parameter was not supplied";
die();
}
session_start();
$name = $_GET["name"];
$_SESSION["list"][sizeof($_SESSION["list"])] = $name;
var_dump($_SESSION["list"]);
//I used var_dump here only to show the output you are free to use any other
//way to display the data as you like