我想创建为3 PHP页面之间一个非常简单的会话:的index.php,validate.php和target.php 的index.php问题用PHP会议
<?php
session_start();
$_SESSION['uid'] = 'test';
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Start A Session</title>
</head>
<body>
<h1>Welcome to Heaven</h1>
<form method="POST" action="validate.php">
Your Name: <input type="text" name="name" value="" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
和validate.php为:
<?php
session_start();
$err="Not Allowed";
if(($_POST['name']) == $_SESSION['uid']){
header ("Location: heaven.php");}
else
{echo $err; }
?>
最后target.php作为
<?php
session_start();
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Start Email with PHP</title>
</head>
<body>
<h1>Welcome to Targer <?php echo $_SESSION['uid'] ?></h1>
<img src="session.jpg">
</body>
</html>
现在我的问题是:
- 如何让用户仍然可以访问目标页面,而我已经设置了页面之间的会话(根据我对会话的理解,目标页面必须是不可访问的,除非提交正确的seesion值但我可以获得通过单击wamp索引列表中的页面链接访问页面!与$ err相呼应; ! )
- 我试图通过使用isset()来验证$ _SESSION值,但它没有经过!你可以让我知道如何使用isset()而不是if(($ _ POST ['name'])== $ _SESSION ['uid'])comarison来修改validate.php吗?
- 你可以让我知道我可以如何合并两个(index.php和validate.php)在一个页面?我的意思是我如何验证index.php中的会话并减少文件两个索引和目标?在这种情况下,我需要处理索引页面内的错误登录。
- 最后,您可以让我知道如何从用户输入中将值赋给$ _SESSION吗?我的意思不是像$ _SESSION ['uid'] ='test'这样的硬编码部分;让会话值从用户输入开始!我知道这看起来毫无意义在这里,但我想获得提前在同一索引页创建的验证码
感谢您的时间观念