blesseld Posted August 26, 2009 Share Posted August 26, 2009 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 https://forums.phpfreaks.com/topic/171883-need-help-adding-include-in-login-page-only-works-on-failed-login/ Share on other sites More sharing options...
merck_delmoro Posted August 26, 2009 Share Posted August 26, 2009 cant understand make it more clearly Link to comment https://forums.phpfreaks.com/topic/171883-need-help-adding-include-in-login-page-only-works-on-failed-login/#findComment-906337 Share on other sites More sharing options...
redarrow Posted August 26, 2009 Share Posted August 26, 2009 well spotted ... 10/10 man, if it the prob lol Link to comment https://forums.phpfreaks.com/topic/171883-need-help-adding-include-in-login-page-only-works-on-failed-login/#findComment-906339 Share on other sites More sharing options...
blesseld Posted August 26, 2009 Author Share Posted August 26, 2009 Fatal error: Call to undefined function msql_query() in /home/tbaynigh/public_html/members/tbnl-login.php on line 17 Link to comment https://forums.phpfreaks.com/topic/171883-need-help-adding-include-in-login-page-only-works-on-failed-login/#findComment-906341 Share on other sites More sharing options...
blesseld Posted August 26, 2009 Author Share Posted August 26, 2009 <?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 https://forums.phpfreaks.com/topic/171883-need-help-adding-include-in-login-page-only-works-on-failed-login/#findComment-906343 Share on other sites More sharing options...
merck_delmoro Posted August 26, 2009 Share Posted August 26, 2009 you should always place the include on the top of your code not on the bottom and "mysql_query" not "msql_query" Link to comment https://forums.phpfreaks.com/topic/171883-need-help-adding-include-in-login-page-only-works-on-failed-login/#findComment-906346 Share on other sites More sharing options...
blesseld Posted August 26, 2009 Author Share Posted August 26, 2009 How else could i get my footer to load then on the successful login? Link to comment https://forums.phpfreaks.com/topic/171883-need-help-adding-include-in-login-page-only-works-on-failed-login/#findComment-906347 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.