i use two files for this purpose as i use sessions to check the user is
always logged in:
validate_session.php
<?php
session_start();
//check the session variables
if (!session_is_registered("ses_user_name")) {
//if not registered then redirect to corresponding page
require ("authorization_required.php");
//finish reading the script
exit;
} else {
include ("top.php");
}
?>
authenticate_user.php:
<?php
require("dbconnect.php");
// Assume user is not authenticated
$auth = false;
// Formulate the query
$query = "SELECT * FROM Wherearewenow_User WHERE
User_Username = '$_POST[username]' AND
User_Password = '$_POST[password]'";
// Execute the query and put results in $result
$result = mysql_query( $query )
or die ( 'Unable to execute query.' );
// Get number of rows in $result.
$num = mysql_numrows( $result );
if ( $num != 0 ) {
// A matching row was found - the user is authenticated.
$auth = true;
//get the data for the session variables
$username = mysql_result($result, 0, "User_Name");
//assign session variables
session_start();
$ses_user_name = $username;
session_register("ses_user_name");
}
//if user isn't authenticated redirect to appropriate page
if ( ! $auth ) {
include("authorization_required.php");
exit;
}
//if user is authenticated, include the main menu
else{
include("main_menu.php");
}
?>
you would want to replace authorization_required.php with login.php.
i hope this helps
"Bobby Rahman" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
>
> Hiya
>
> I have a login_screen.html which on submit is sent to login.php.
> Login.php does all the checking of usernames and passwords. I am trying to
> to produce this logic:
> //In login.php
> if password and username correct {
> go to main page
> }
> else
> {
> go back to login.screen.html
> echo "Please try again";
> echo "login Incorrect";
>
> I cannot seem to automatically go back to login_screen.html with the error
> message displayed in the else statment in login.php.
>
> Any suggestions?
>
> Thanks
>
> _________________________________________________________________
> It's fast, it's easy and it's free. Get MSN Messenger today!
> http://messenger.msn.co.uk
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php