我有几个页面,第1页是一个输入表单,允许访问的用户更改第2/3页等……我希望使用PHP来做到这一点,但我不太懂PHP。
场景
页面1有两个用HTML(母版页)制作的下拉菜单,第一个是人名"Mike"&"Jim",第二个包含从0到10的分数。我希望如果我选择mike和7,然后点击提交,它将更新第2页(mike页面)并显示"mike"&"7",然后如果我点击"Jim"&"3"它将更新jims页面以显示Jim和3
我将如何最有效地完成这项工作?最好是简单的PHP(如果可能的话)。
所有这些页面+脚本都将在服务器上&我知道jscript只是客户端,这意味着它不能更改另一个页面。
非常感谢您的任何帮助
您可以通过创建会话来实现这一点。例如,我已经取了两个页面,并将数据从一个页面的输入字段发送到另一个
page1.php
<?php
session_start(); //this must be the first line in php page
$_SESSION['variable']=$_POST['anything']; // this will save value from input tag in form in session.
header( "Location: page2.php" );
?>
<html>
<head>
<title>Session</title>
</head>
<body>
Welcome to page 1.
<br/>
<br/>
<form method="post" action="page1.php"> // this will call page2.php on button click
Type anything
<input type="text" name="anything" />
<input type="submit" value="Send value to page 2" />
</form>
</body>
</html>
page2.php
<?php
session_start();
echo $_SESSION['variable'];
?>