twitter bootstrap - PHP header won't redirect to home.php -
i'm following this video tutorial on website designing myself. have run 2 major problems:
the first being when code comes header("location: home.php");
command script erases entire screen instead , echo's pass onto blank screen. meaning login credentials have passed. reason header() function not redirecting home.php page. site hosted on bluehost.com.
my second problem while loop commented out not allow page load problem has stumped me.
code:
<header id="header"> <?php include ( "./inc/connect.inc.php" ); session_start(); if(isset($_post['login'])){ $user_login = strip_tags(@$_post['user_login']); $password_login = strip_tags(@$_post['login_password']); $password_login = md5($password_login); $sql = mysql_query("select id users email='$user_login' , password='$password_login' limit 1"); $usercount = mysql_num_rows($sql); if($usercount == 1){ /*while($row = mysql_fetch_array($sql)){ $id = row["id"]; }*/ echo("pass"); $_session['user_login'] = $user_login; header("location: home.php"); exit(); }else { echo("invalid username/password"); exit(); } } ?> <div id="top-bar"> <div class="container"> <div class="row"> <div class="col-sm-12"> <ul id="top-info"> <li>phone: 703-518-4325</li> <li>email: <a href="mailto:info@urbanare.com">info@urbanare.com</a></li> </ul> <ul class="nav pull-right" id="top-buttons" style="line-height:10px !important;"> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-sign-in"></i>log in<strong class="caret"></strong></a></a> <ul id="login-dp" class="dropdown-menu" style="padding: 15px;"> <form action="" method="post" accept-charset="utf-8"> email: <input id="user_username" style="margin-bottom: 15px;" type="text" name="user_login" size="30" /> password: <input id="user_password" style="margin-bottom: 15px;" type="password" name="login_password" size="30" /> <input id="user_remember_me" style="float: left; margin-right: 10px;" type="checkbox" name="remember" value="1" /> <label class="string optional" for="user_remember_me"> remember me</label> <input class="btn btn-primary" style="clear: left; width: 100%; height: 32px; font-size: 13px;" type="submit" name="login" value="sign in" /> </form> </ul> </li> <li class="divider"></li> <li><a href="../register"><i class="fa fa-pencil-square-o"></i> register</a></li> </ul> </div> </div> </div> </div> <div class="sticky-wrapper"><div id="nav-section"> <div class="container"> <div class="row"> <div class="col-sm-12"> <a href="http://comingsoon.safepropserv.com/landing/index.html" class="nav-logo"><img src="./files/logo_transparent.png" alt="urbanare logo"></a> <!-- begin search --> <div id="sb-search" class="sb-search"> <form> <input class="sb-search-input" placeholder="search..." type="text" value="" name="search" id="search"> <input class="sb-search-submit" type="submit" value=""> <i class="fa fa-search sb-icon-search"></i> </form> </div> <!-- end search --> <!-- begin main menu --> <nav class="navbar"> <button id="nav-mobile-btn"><i class="fa fa-bars"></i></button> <ul class="nav navbar-nav"> <li class="dropdown"> <a href="./files/urbanare -- property info.html" data-toggle="dropdown" data-hover="dropdown">home<b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="http://comingsoon.safepropserv.com/landing/index.html">home search</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/index-slider.html">home slider</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/index-grid.html">home grid</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/index-map.html">home map</a></li> </ul> </li> <li class="dropdown"> <a href="./files/urbanare -- property info.html" data-toggle="dropdown" data-hover="dropdown">properties<b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="http://comingsoon.safepropserv.com/landing/properties-detail.html">properties detail</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/properties-list.html">properties list</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/properties-grid.html">properties grid</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/properties-grid2.html">properties grid 2</a></li> </ul> </li> <li class="dropdown"> <a class="dropdown" href="./files/urbanare -- property info.html" data-toggle="dropdown" data-hover="dropdown">pages<b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="http://comingsoon.safepropserv.com/landing/about.html">about us</a></li> <li class="dropdown-submenu"> <a href="./filse/urbanare -- property info.html">agency</a> <ul class="dropdown-menu"> <li><a href="http://comingsoon.safepropserv.com/landing/agency-detail.html">agency detail</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/agency-listing.html">agency listing</a></li> </ul> </li> <li class="dropdown-submenu"> <a href="./files/urbanare -- property info.html">agent</a> <ul class="dropdown-menu"> <li><a href="http://comingsoon.safepropserv.com/landing/agent-detail.html">agent detail</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/agent-listing.html">agent listing</a></li> </ul> </li> <li><a href="http://comingsoon.safepropserv.com/landing/pricing-tables.html">pricing tables</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/login.html">login</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/register.html">register</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/faq.html">faq</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/404.html">404</a></li> <li class="divider"></li> <li><a tabindex="-1" href="./files/urbanare -- property info.html"> separated link </a></li> </ul> </li> <li class="dropdown"> <a href="./files/urbanare -- property info.html" data-toggle="dropdown" data-hover="dropdown">blog<b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="http://comingsoon.safepropserv.com/landing/blog-detail.html">blog detail</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/blog-listing1.html">blog listing 1</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/blog-listing2.html">blog listing 2</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/blog-listing3.html">blog listing 3</a></li> <li><a href="http://comingsoon.safepropserv.com/landing/blog-listing4.html">blog listing 4</a></li> </ul> </li> <li><a href="http://comingsoon.safepropserv.com/landing/contacts.html">contacts</a></li> </ul> </nav> <!-- end main menu --> </div> </div> </div> </div></div> </header> <!-- end header -->
there multiple issues here:
you should not use
mysql_
functions. deprecated , dangerous. usemysqli_
functions instead.you should not output before
header()
function. comment outecho $pass
,<header id="header">
you missing
$
in line:$id = row["id"];
. should$id = $row["id"];
your
header
function incorrect. location must @ least have slash @ beginning:header("location: /home.php");
Comments
Post a Comment