Jump to content

Need help adding include in login page. Only works on failed login.


blesseld

Recommended Posts

Hey,

 

In my login script, If the user enters an invalid login the include works, also if they leave a field empty it works.  But because there is a die() and it just says "you are now logged in, click here."

 

The include is my middle content div, and footer.  I can't figure out how to make this script load my include if its a successful login.

 

Here is the login script

 

<?php
include_once 'tbnl-header.php';
echo "<h3>Member Log in</h3>";
$error = $user = $pass = "";
if (isset($_POST['user']))
{
$user = sanitizeString($_POST['user']);
$pass = sanitizeString($_POST['pass']);
if ($user == "" || $pass == "")
{
$error = "Not all fields were entered<br />";
}
else
{
$query = "SELECT user,pass FROM tbnlmembers
WHERE user='$user' AND pass='$pass'";
if (mysql_num_rows(queryMysql($query)) == 0)
{
$error = "Username/Password invalid<br />";
}
else
{
$_SESSION['user'] = $user;
$_SESSION['pass'] = $pass;
die("You are now logged in. Please
<a href='tbnl-members.php?view=$user'>click here</a>.)");
}
}
}
echo <<<_END
<form method='post' action='tbnl-login.php'>$error
Username <input type='text' maxlength='16' name='user'
value='$user' /><br />
Password <input type='password' maxlength='16' name='pass'
value='$pass' /><br />
             
<input type='submit' value='Login' />
</form>
_END;
include("../inc/page-bot.php");
?>

 

any ideas how I can get this to load include("../inc/page-bot.php"); after

die("You are now logged in. Please
<a href='tbnl-members.php?view=$user'>click here</a>.)");

 

Thanks in advance

<?php
include_once 'tbnl-header.php';
echo "<h3>Member Log in</h3>";
$error = $user = $pass = "";
if (isset($_POST['user'])) {
    $user = sanitizeString($_POST['user']);
    $pass = sanitizeString($_POST['pass']);
    if ($user == "" || $pass == "") {
        $error = "Not all fields were entered<br />";
    } else {
        $query = "SELECT user,pass FROM tbnlmembers
WHERE user='$user' AND pass='$pass'";
        if (mysql_num_rows(msql_query($query)) == 0) {
            $error = "Username/Password invalid<br />";
        } else {
            $_SESSION['user'] = $user;
            $_SESSION['pass'] = $pass;
            die("You are now logged in. Please
<a href='tbnl-members.php?view=$user'>click here</a>.)");
        }
    }
}
echo <<< _END
<form method='post' action='tbnl-login.php'>$error
Username <input type='text' maxlength='16' name='user'
value='$user' /><br />
Password <input type='password' maxlength='16' name='pass'
value='$pass' /><br />
             
<input type='submit' value='Login' />
</form>
_END;
include ("../inc/page-bot.php");
?>

 

 

If there is a successful login,  my include  "page-bot" will not load

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.