我知道以前有人问过这个问题,但从头到尾都没有解释。我有一个login.php我想从中获得$_SESSION['user_id']
从
<?php
include "connect.php";
session_start();
$email=$_POST['email'];
$password=$_POST['password'];
$select_data=mysql_query("select * from user where email='$email' and password='$password'");
if(isset($_POST['email']))
{
if($row=mysql_fetch_array($select_data))
{
$_SESSION['user_id']=$row['id']; //The variable want to access from ext.js
echo "success";
}
else
{
echo "fail";
}
exit();
}
?>
顺便说一句,这种身份验证工作正常
我的主.php
<!DOCTYPE html>
<?php include 'connect.php';
session_start();
echo $_SESSION['user_id']; //works fine
//;
?>
<body>
//contents
<script src="login.js"></script>
<script src="postad.js"></script> //the script from which I want to get $SESSION_['user_id']
</body>
我希望这个变量稍后插入到数据库中。有什么建议?
慕虎7371278
侃侃尔雅