我对PHP有点生疏。我想要做的是保存2个变量以在我的项目中使用。我想保存登录页面中的电子邮件和密码,以便稍后在Parse.com上解析我的数据库。
使用参考链接:[http://php.net/manual/en/book.session.php]
已解决,谢谢@Fred -ii-的帮助和解释!
登录文件:
try{
$query = new ParseQuery("Clients");
$query->equalTo("email", "$email");
$query->equalTo("password","$password");
$results = $query->find();
} catch(Exception $e){
echo $e->getMessage();
}
if(count($results)==1){
session_start();
$_SESSION['email'] = $email;
$_SESSION['password'] = $password;
header("Location: http://localhost/ClientPortal/mainMenu.php");
}
mainMenu文件:
session_start();
$email = $_SESSION['email'];
$password = $_SESSION['password']; //* fixed spelling error (used to be 'passowrd')
session_commit();
try{
$query = new ParseQuery("Clients");
$query->equalTo("email", "$email");
$query->equalTo("password","$password");
$results = $query->find();
} catch(Exception $e){
echo $e->getMessage();
}
if(count($results)==1){
echo "<p align=center>1 correct row</p>";
}
else{
echo "<p align=center>NO correct rows</p>";
}
答案 0 :(得分:1)
谢谢@Fred -ii-帮助我解决这个问题!!!
登录文件:
try{
$query = new ParseQuery("Clients");
$query->equalTo("email", "$email");
$query->equalTo("password","$password");
$results = $query->find();
} catch(Exception $e){
echo $e->getMessage();
}
if(count($results)==1){
session_start();
$_SESSION['email'] = $email;
$_SESSION['password'] = $password;
header("Location: http://localhost/ClientPortal/mainMenu.php");
}
mainMenu文件:
session_start();
$email = $_SESSION['email'];
$password = $_SESSION['password']; //* fixed spelling error (used to be 'passowrd')
session_commit();
try{
$query = new ParseQuery("Clients");
$query->equalTo("email", "$email");
$query->equalTo("password","$password");
$results = $query->find();
} catch(Exception $e){
echo $e->getMessage();
}
if(count($results)==1){
echo "<p align=center>1 correct row</p>";
}
else{
echo "<p align=center>NO correct rows</p>";
}