1

这里各条战线上的第一个计时器。我已经完成了我的挖掘,我准备发布它。我似乎无法让我的会话变量结转。从我读过的内容来看, header(LOCATION:) 可以做一些非常奇怪的事情,而有些代码可能无法完成。session_start(); 位于每一页的顶部。继承人第 1 页:

<?php
session_start();
include "/header.php";
$username = $_POST["user"];
$db = new SQLite3("../../database/login.db");
$password = md5($_POST["password"]);
$userquery = $db->querySingle("SELECT username FROM accounts WHERE username='$username';");
$passquery = $db->querySingle("SELECT password FROM accounts WHERE username='$username';");
$loggedin = false;

我在同一页面 (1) 上调用会话变量:

if ($loggedin == true)
{
    $_SESSION['user'] = $username;
    header('LOCATION: ../test.php');
}

然后在登录页面 (2) 上,我拥有的标题引用:

<?php session_start();?>
<?php include "header.php";?>
<html>
    <head>
        <link href="dashboard.css" rel="StyleSheet" type="text/css"/>
        <title>
             Dashboard
        </title>
        <h1>
            Dashboard
        </h1>
        <h2>
            Greetings: <span><?php echo $_SESSION['user'];?></span> Today's date: <span><?php $date = date("l,F,N,Y"); echo $date;?></span>

任何帮助,将不胜感激。我觉得我错过了一些简单的东西。感谢大家!

4

1 回答 1

3

I FIGURED IT OUT!! So I'm using cloud9 IDE and the PHP.ini file in use doesn't permit sessions. Now what I had to do was create my own PHP.ini file in the root project folder. This ini file overrides the one that cloud 9 defaults to which is only readable. I hope this helps someone in the future!!!!!

于 2013-09-25T16:23:13.617 回答