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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.