Re: Sessions + Variables + includes
| From: | ReDucTor | Date: | Thu, 19 Jul 2001 13:12:39 +0000 |
| Subject: | Re: Sessions + Variables + includes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-58675@lists.php.net to get a copy of this message | ||
<?php
$loginpass = "test";
$loginuser = "test";
$locationof403 = "error.php?403";
session_start();
session_register("user","pass");
if(isset($user))
$username = $user;
if(isset($pass))
$password = $pass;
if(isset($username))
$user = $username;
if(isset($password))
$pass = $password;
if((isset($password)) && (isset($username)))
{
if(($loginpass != $password) && ($loginuser != $username))
header("location: ".$locationof403);
else
$loggedin = 1;
}
else
$loggedin = 0;
?><html><body>
<?php if(loggedin != 1){ ?>
<form>
Username : <input type="text" name="username"><br>
Password : <input type="password" name="password"><br>
<input type="submit" value="Login"><input type="reset"
value="Reset">
</form>
<?php }
else
{ ?>
<a href="profile.php">Profile</a><br>
<a href="moo.php">Moo</a><?php
}
?></body></html>
----- Original Message -----
From: dosenbrei <dosenbrei@hotmail.com>
To: <php-general@lists.php.net>
Sent: Thursday, July 19, 2001 10:01 PM
Subject: [PHP] Sessions + Variables + includes
>
>
> Hi
>
> Sorry for my bad english ;-)
>
> I'm writing an application using php and sessions.
> In the first include file i'm writing something like this
>
> session_start();
> session_register(loggedin);
>
> The i have another include file with the functions.
> When i'm submitting the username and passwort to the function
> which checks them i'd like to set loggedin to 1 how does this work?
>
> function CheckLogin($username,$password)
> {
> if($username=='test' && $password=='user')
> {
> $loggedin=1;
> header("location:secretpage.php");
> }
> else
> {
> $loggedin =0;
> header("location:login.php")
> }
>
> Can i user include with sessions or doe i have to use requiere?
> I also tried to set the $loggedin to 1 this way:
>
> $HTTP_SESSION_VARS[loggedin]=1;
>
> This doesn't work too.
>
> Please help me
>
>
> THX
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>