Re: A question about session variables. Please help
From: Ang Talunin (please.no.spam_at_no-reply.com)
Date: 12/30/03
- Next message: tuxim: "Re: java enabled browser detection with PHP"
- Previous message: Ang Talunin: "Re: site gallery"
- In reply to: Sender: "A question about session variables. Please help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 30 Dec 2003 11:33:42 +0100
Please post your code....
I've once wrote something like this..it might be usefull to you:
<?php
$submit=$_POST["submit"];
if ($submit)
{
$login=$_POST["login"];
$pass=$_POST["pass"];
$file = "$login.txt"; //I've got the login date in a file....
$fo = fopen($file,"r");
$correctPass = fgets($fo, 4096);
fclose($fo);
$cPass = crypt($pass,"AB"); //Just some security
if($cPass==$correctPass)
{
session_start();
$_SESSION['login'] = "true";
$_SESSION['user'] = $login;
echo "You're logged on, click <a href=whatever.php>HERE</a> to proceed";
}
else
{
echo "Wrong Login";
}
}
else
{
?>
<form action = "<?php echo($PHP_SELF); ?>" method=post>
Login <input type=text size=40 name="login><br>
Password<input type=password size=40 name="pass"><br>
<input type=submit size=40 name="submit" value="Login">
</form>
<?php
}
?>
In every next page you can check the login status by using this:
<?php include 'info.inc';
session_start();
if($_SESSION['login'] == "true")
{
$user= $_SESSION['user'];
$login= $_SESSION['login'];
echo "User :: $user";
....
}
else
{
echo 'NOT LOGGED ON';
}
"Sender" <blah@blah.com> schreef in bericht
news:OzWHb.2636$Vl6.734639@news20.bellglobal.com...
> Hi folks. I was writing a login script that uses session variables to
> register a user. As I understand it, once a session variable is created,
it
> can be called upon in other php scripts later on, right?
>
>
>
> Now, a person logs in and I provide a link for them on their login screen.
> The target of the link loads a new page, its content is based on a
database
> entry that is accessed using their username and password (that way each
> login is personalized). But, when I click on the link, I get one of three
> things:
>
> 1. if the target page is html, it views it no problem.
>
> 2. if the target page is html with a <?php SOME CODE HERE ?> in it, it
comes
> up blank on the screen.
>
> 3. if the target page has a php extension and php code within it, an error
> 404 message comes up telling me that the page doesn't exist.
>
>
>
> Can someone help explain to me why I see this, and/or offer a suggestion
or
> an alternate way to provide personalized login pages.
>
>
>
> TIA
>
>
>
> Doug
>
>
>
- Next message: tuxim: "Re: java enabled browser detection with PHP"
- Previous message: Ang Talunin: "Re: site gallery"
- In reply to: Sender: "A question about session variables. Please help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|