simple login to see the one php page

I am looking for a simple log in page

that will keep a user logged in 30 minutes

and only show one page if logged in


log in will not use a database
just one hardcoded php login and password
LVL 1
rgb192Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
The part about only show one page kind of defies logic.  The user can close the browser or click away any time.  The part about logged in 30 minutes misunderstands the nature of client/server computing.  Please read this article about how C/S works and while you do that I'll see if I can put together an example for you.
0
Ray PaseurCommented:
<?php // RAY_temp_rgb192.php 2013-10-10
error_reporting(E_ALL);

// ONE PAGE WITH LOG-IN REQUIRED
// http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28263785.html

// SESSION CONTROLS AUTHORIZATION DATA
session_start();

// THE AUTHENTICATION CREDENTIALS
$uid = 'rgb192';
$pwd = 'secret';

// IF THE AUTHORIZATION FORM HAS BEEN POSTED
if (!empty($_POST))
{
    // TEST BOTH UID AND PWD
    if ($_POST['uid'] == $uid)
    {
        if ($_POST['pwd'] == $pwd)
        {
            $_SESSION['authorized'] = $uid;
        }
    }
}
// IF THE CLIENT IS NOT AUTHORIZED, PUT UP THE LOGIN FORM
if (!isset($_SESSION['authorized']))
{
    $form = <<<EOD
Please Login:
<form method="post">
<input name="uid" placeholder="User Id" />
<input name="pwd" placeholder="Password" />
<input type="submit" />
</form>
EOD;
    echo $form;
}
// IF THE CLIENT IS AUTHORIZED, SHOW THE WEB PAGE
else
{
    echo "<h1>Welcome $uid</h1>" . PHP_EOL;
    echo "<p>You successfully entered the User Id and Password, so now you can see this page.</p>" . PHP_EOL;
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgb192Author Commented:
thanks
code teaches me about login and is easy to understand
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.