我想要显示的usermail
一旦我登录,登录后的页面应该显示“欢迎alex01@gmail.com”我的登录页面的php代码是
<?php
if(isset($_POST['submit']))
{
$host="localhost";
$user="root";
$pass="";
$db="documentation";
$usermail=$_POST['email'];
$password=$_POST['password'];
$conn=mysqli_connect($host,$user,$pass,$db);
$query="SELECT * FROM users where
user_mail='$usermail' and password='$password'";
$result=mysqli_query($conn,$query);
if(mysqli_num_rows($result)==1)
{
session_start();
$_SESSION['documentation']='true';
$_SESSION['user_mail']=$_POST['email'];
header('location:index.php');
}
else{echo 'wrong username or password';}
}
?>
我的index.php的代码(用户登录后看到的页面)
<?php
session_start();
$_SESSION['user_mail']=$_POST['email'];
if(!$_SESSION['documentation'])
{
header('location:login.php');
}
?>
我正在尝试通过以下方式保存usermail
$_SESSION['user_mail']=$_POST['email'];
我正在尝试通过编写以下代码来检索index.php中的值
$_SESSION['user_mail']=$_POST['email'];
但是它没有显示用户名
发布于 2015-12-18 14:22:01
在您index.php
页面中,像这样进行检索;
$usermail = $_SESSION['user_mail'];
echo $usermail;
发布于 2015-12-18 14:22:19
通过echo $_SESSION['user_mail'];
检索会话
发布于 2015-12-18 14:22:25
要显示会话数据,只需编写
echo $_SESSION['user_mail'];
还要确保在使用会话的页面上启动会话。
https://stackoverflow.com/questions/34349543
复制相似问题