PHP redirect not working on successful login -


i'm teaching myself php stupid don't know yet, why redirect not working...

i'm trying this:

header("location: members.php?view=$user"); exit;

which doesn't anything, when place link in die statement upon successful login

die("you logged in. please <a href='members.php?view=$user'>click here</a> continue.");

i can click on link , works fine.

full code

<?php //login.php   include_once 'header.php';   echo "<div class='main'><h3>please enter details log in</h3>";   $error = $user = $pass = "";    if (isset($_post['user'])) {     $user = sanitizestring($_post['user']);     $pass = sanitizestring($_post['pass']);      if ($user == "" || $pass == "") {       $error = "not fields entered<br />";     }     else {       $query = "select user,pass members user='$user' , pass='$pass'";        if (mysql_num_rows(querymysql($query)) == 0) {         $error = "<span class='error'>username/password invalid</span><br /><br />";       }       else {         $_session['user'] = $user;         $_session['pass'] = $pass;         header("location: members.php?view=$user"); exit;       }     }   }  echo <<<_end <form method='post' action='login.php'>$error <span class='fieldname'>username</span><input type='text' maxlength='16' name='user' value='$user' /><br /> <span class='fieldname'>password</span><input type='password' maxlength='16' name='pass' value='$pass' /> _end; ?>  <br /> <span class='fieldname'>&nbsp;</span> <input type='submit' value='login' /> </form><br /></div></body></html>    <?php //header.php session_start(); echo "<!doctype html>\n<html><head><script src='js/osc.js'></script>"; include 'functions.php';  $userstr = ' (guest)';  if (isset($_session['user'])) {     $user     = $_session['user'];     $loggedin = true;     $userstr  = " ($user)"; } else {     $loggedin = false; }  echo "<title>$appname$userstr</title><link href='css/main.css' rel='stylesheet' type='text/css' />" .      "</head><body><div class='$appname'>$appname$userstr</div>";  if ($loggedin) {     echo "<br /><ul class='menu'>" .       "<li><a href='members.php?view=$user'>home</a></li>" .       "<li><a href='members.php'>members</a></li>" .       "<li><a href='friends.php'>friends</a></li>" .       "<li><a href='messages.php'>messages</a></li>" .       "<li><a href='profile'>edit profile</a></li>" .       "<li><a href='logout.php'>log out</a></li></ul><br />"; } else {     echo ("<br /><ul class='menu'>" .      "<li><a href='index.php'>home</a></li>" .      "<li><a href='signup.php'>sign up</a></li>" .      "<li><a href='login.php'>log in</a></li></ul><br />" .      "<span class='info'>&#8654; must logged in view page.</span><br /><br />"     ); }  ?> 

i've tried removing first echo @ top, $error message. said, i'm trying improve on code picked this o'reilly book, appreciate help, guidance, criticism, etc.

any output (echo) php script prior setting location header cause redirection fail. in ideal world, script redirects user shouldn't have body, though many still do.

remove echo lines before call header.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -