我想使用pin列我的查询结果设置会话ID,并检查会话是否在下一页上设置为该值,这是我的代码
<?php
require_once('AppLogin_Class.php');
$success='';
if(isset($_POST['submit'])){
$pin=$_POST['SIDN'];
$status=0;
try{
require_once('connection.php');
$message='Invalid Application Pin';
$STH=$db_conn->prepare("SELECT * FROM pins WHERE pin=? && status=?");
$STH->bindParam(1,$pin);
$STH->bindParam(2,$status);
$STH->execute();
$row=$STH->fetch();
if($STH->rowCount()==1){
$_SESSION['id']=$row['pin'];;
echo '<meta http-equiv="refresh" content="=1;applicants/upload_pass.php?pin=$pin"/> ';
}else{
return $message;
}
}catch(PDOException $e){
echo $e->getMessage();
}
}
?>
这是我的下一页验证码
<?php
$pin=$_GET['pin'];
require_once('class_applicants.php');
if(!isset($_SESSION['id'])){
echo '<meta http-equiv="refresh" content="=1;../appHome.php"/> ';
}else{
//success page here
}?>
由于会话ID
,有人应该帮我检查网页是否正在退出答案 0 :(得分:1)
使用session_start()
;
示例:
<?php
session_start();
$pin=$_GET['pin'];
require_once('class_applicants.php');
if(!isset($_SESSION['id'])){
echo '<meta http-equiv="refresh" content="=1;../appHome.php"/> ';
}else{
//success page here
}?>
以及
<?php
session_start();
require_once('AppLogin_Class.php');
$success='';
if(isset($_POST['submit'])){
$pin=$_POST['SIDN'];
$status=0;
try{
require_once('connection.php');
$message='Invalid Application Pin';
$STH=$db_conn->prepare("SELECT * FROM pins WHERE pin=? && status=?");
$STH->bindParam(1,$pin);
$STH->bindParam(2,$status);
$STH->execute();
$row=$STH->fetch();
if($STH->rowCount()==1){
$_SESSION['id']=$row['pin'];;
echo '<meta http-equiv="refresh" content="=1;applicants/upload_pass.php?pin=$pin"/> ';
}else{
return $message;
}
}catch(PDOException $e){
echo $e->getMessage();
}
}?>
答案 1 :(得分:0)
第一名:在页面顶部启动会话页面
session_start();
第二名:而不是元标记。只需使用标题功能。
<?php
session_start();
$pin=$_GET['pin'];
require_once('class_applicants.php');
if(empty($_SESSION['id'])){
header('Location:../appHome.php');
exit();
}else{
//success page here
}
?>
注意:标头功能不会停止代码执行,因此您需要在标头功能之后使用exit()。