Re: A question about session variables. Please help

From: Ang Talunin (please.no.spam_at_no-reply.com)
Date: 12/30/03


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
>
>
>



Relevant Pages

  • ~~~~~~~~~~~~~~ LOGIN PHP ~~~~~~~~~~~~~~
    ... adding login php script on website ... complete login password system php mysql ... flash php login script ...
    (rec.audio.tech)
  • Re: PHP - D3 subroutine calls?
    ... MVWWW does the login once and then makes the connection available for ... don't think any of the MV vendors have adequately minimized the pain ... your PHP call. ...
    (comp.databases.pick)
  • A question about session variables. Please help
    ... I was writing a login script that uses session variables to ... The target of the link loads a new page, its content is based on a database ... if the target page is html with a <?php SOME CODE HERE ?> in it, ...
    (alt.php)
  • Re: To allow access only from the designated site.
    ... I want to allow access to it only from site "B" login user. ... what capabilities do both servers have, do they have php, does only ... one, which one, does one/both have a database, session support? ... and to a script on siteB, and uses RSA for the form, with B's public ...
    (comp.lang.php)
  • RE: [PHP] why?
    ... It doesn't work together with Windows ... PHP) you mean? ... access to the initial login values ... What we shoot for is Single Source Authentication. ...
    (php.general)