Hello,

> Hello!
>
> I'm sitting here trying to create a loginpage, but it doesn't look very
> nice. So now I'ld use some help to decide whether the following solution
> is possible to create...
>
> I want to create a little script which will be included on every page
> and do the following:
>
> 1 does the user come from the log in part?

Check for the presence of a $_POST['username'] and $_POST['password']
variable for instance.

> 1.1 If so, veryfy the user against the database

SELECT * FROM table WHERE username = $_POST['username'] AND password =
$_POST['password']

> 1.1.1 If this succeeds, set the session 'is_logged_in'

session_start();
$_SESSION['is_logged_in'] = 1;

> 1.2 If not, is the session set, that is, is the user already logged in?

if(isset($_SESSION['is_logged_in']))

> 1.2.1 If not, show a login form that has the action php_self
> _and halt_

header("Location: http://www.example.com/login.php";);
exit();

or

include("login_form.html");
exit();

> 1.2.2 If so, show the rest of the page, that is, what follows
> after the include of this script
> In this, my problem are
>
> 1.2.1 How to stop loading the page.

exit();

> 1.2.2 How to show the rest of the page without having to supply a "}" on
> the end of each page...

if(!logged_in || !correct_password)
{
  header("Location: http://www.example.com/login.php";);
  exit();
}
//rest of page...

> Perhaps I've thought wrong, but if so, please help me with ideas...
>
> Best regards,
>
> Victor
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to