PHP - Redirect: Not Header Redirect
How can one re-direct a visitor, without using a header re-direct? I'd like a page to show up, then after about 5 seconds I need the visitor sent to another page. How can I do this?
Similar TutorialsIf I do something like header(Location: www.url.com). Is there a way that url.com would be able to get the IP from the server that did the redirect? It looks like $_SERVER["REMOTE_ADDR"] returns the clients IP address which isnt what I need. Thanks Hi all, I am having a time with my coding. The codes for the form.php will add to the db if the action is giving as form.php. I am trying to get the page to redirect to the login.php. so I put the header function in. It redirects to the login.php as the header but does not add data to the db. So I tried to put the code login.php in the action for the form but it does not add to the db. Where can I put the redirect so it adds to data to the db and goes to the next page.??????? <?php @include_once ("Connections/connect_to_mysql.php"); $err=''; if($_POST["submit"]){ // Validate form data if($_POST["firstname"]=='') $err.='Please enter First Name<br>'; if($_POST["email"]=='') $err.='Please enter Email<br>'; if($err==''){ // Check if there are duplicate entries in the 'contacts' table $results = mysql_query("SELECT id FROM `Members` WHERE firstname='".addslashes($_POST["firstname"])."' and Email='".addslashes($_POST["email"])."'"); if($row = mysql_fetch_array($results)){ $err.='Can not add duplicate entry<br>'; } else{ // adding new record to 'contacts' table mysql_query("INSERT INTO Members (firstname,lastname,country,Email) values ('".addslashes($_POST["firstname"])."','".addslashes($_POST["lastname"])."','".addslashes($_POST["country"])."','".addslashes($_POST["email"])."')"); // redirecting to success screen if($_POST['id']){ header("Location: login.php"); exit; } } } } ?> <html> <head> <title>Add New Contact</title> </head> <body> <h2>Register with us</h2> <?php echo $err==''?'''<p style="color:red;">'.$err.'</p>') ?> <form method="post" action="form.php"> <table border="0"> <tr> <td valign="middle">First Name:</td> <td><input type="text" name="firstname" size="30" value="<?php echo htmlspecialchars($firstname) ?>"></td> </tr> <tr> <td valign="middle">Last Name:</td> <td><input type="text" name="lastname" size="30" value="<?php echo htmlspecialchars($lastname) ?>"></td> </tr> <tr> <td valign="middle">Country:</td> <td><input type="text" name="country" size="30" value="<?php echo htmlspecialchars($country) ?>"></td> </tr> <tr> <td valign="middle">Email:</td> <td><input type="text" name="email" size="30" value="<?php echo htmlspecialchars($email) ?>"></td> </tr> </table><br> <input type="submit" name="submit" value=" Submit! "> </form> </body> </html> hi everyone. i have been working on a site on a local windows server then moved everything to a unix server. now my refresh doesn't redirect anymore. any ideas why? Code: [Select] <?php if(isset($_POST['GO'])){ $page ="go.php?IDNumber=" . $IDNumber; header("Refresh: 1; url=$page"); echo " "; } ?> <form action="" method="post" name="redirect" id="redirect"> <input type="submit" name="GO" id="GO" value="GO" /> </form> Here is the webpage.php which executes data entered in the email form. I want to display a webpage which would confirm that the email has been sent but the header redirect does not work. An email gets sent but a blank page is displayed instead of confirmation. Can anyone help? this is urgent <?php error_reporting(6143); require_once('recaptchalib.php'); $publickey = "6Ldmbr8SAAAAAGT17oCjkB8Y60kSqvq_0w7APAJp"; $privatekey = "6Ldmbr8SAAAAAMY5lEl-7LnkWCovoFa9G7Vl3_kA"; isset($_POST['Email']) ? $Email = $_POST['Email'] : $Email = ""; isset($_POST['name']) ? $name = $_POST['name'] : $name = ""; isset($_POST['surname']) ? $surname = $_POST['surname'] : $surname = ""; ?> <meta http-equiv="content-type" content="text/html; charset=iso-8859-2"> <body bgcolor="#000000"></body> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> <?php if (isset($_POST['Submit'])) { //Validate form $errormessage = ""; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if ($name == '') { $errormessage .= "<li>Please provide your name.</li> ";} if ($surname == '') { $errormessage .= "<li>Please provide your surname.</li>";} if ($Email == '') { $errormessage .= "<li>What is your e-mail address?</li>";} if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $Email)){ $errormessage = $errormessage . "<li>This is not a valid email address! </li>";} if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly $errormessage .= "<li>Please rewrite captcha characters</li>"; } echo "</ul></p>"; //If errors, return error message(s) and form if ($errormessage != "") { ?> <span class="link1"><a href="index.php">back to home page/a></span> <img src="images/clack.JPG"> <table align="center"> <p align="center" class="err_bold">correct the following errors:</p> <span class="text_err"><ul><?=$errormessage?></span> </table> <?php include("email-form.php"); } else { //If good, mail to DL $email_subject = "Hello, you have a new message"; $email_headers = "From: $name [$Email] \r\n"; $to = "blablabla@hotmail.com"; $message_content = "----------------------------------------------------------------------------------\n". " Hello\n". "name: $name\n". "surname: $surname\n". "E-mail: $Email\n". "-----------------------------------------------------------------------------------\n\n"; //Email message to Requestor if (mail($to, $email_subject, $message_content, $email_headers)) { //Display Sent Confirmation (Successful or NOT!) ?> <?php header ("Location: http://www.google.co.uk"); exit; ?> <?php } } } else { ?> <span class="link1"><a href="index.php">back to home page</a></span> <img src="images/clack.JPG"><br> <p class="err" align="center">Please fill the form below<br/></p> <?php include("email-form.php");?> <?php }; is it possible to have a script that changes header based on what page the user came from. something like Code: [Select] if ($_SERVER['HTTP_REFERER']) == http://www.site.com/pagebefore.php) { // do nothing, letting page generate } else { header("Location: back_to_the_start_buddy.php"); } I am using a header redirect after a user makes a post which goes to their post. example they made a post which has an id of 236, then the url redirect would be index.php?forum=1&topic=1&post=236#p236 i have the <a name> set up on each post and it works fine until the post is on a different page. the url should be: index.php?forum=1&topic=1&page=2&post=236#p236 but how would i be able to tell the header redirect which page to go to. I was thinking if statements like: if ($number_of_results >=10) { $page = 2; } but that would involve alot of if statements with no way of knowing how many pages the topic could have. Is there an easier way? Hi Everyone, I'm having a bit of a problem if someone could help me with? I have a simple registration form with fields userid, username, password, clientaddress So when the user logs in with their username and password it will redirect to their client address but I cant get the redirect working. Here is my code: Code: [Select] $clientaddress = trim($_POST['clientaddress']); $_SESSION['start'] = time(); header("Location:$clientaddress"); exit; } also note if I add: Code: [Select] $clientaddress = 'http://www.google.com'; it redirects ok to google. It's getting the field from the database I think thats the problem Can somone help it just wont redirect to the client address I have an html login page. Once a user is verified through the PHP page they get redirected to another page. For some reason once I have validated that the user exists I get the message that is was successful but the page will not redirect. This is my script I use on my HTML page to pass the parameters: Code: [Select] $(document).ready(function() { $('#submit').click(function() { var username = $('input[name=username]'); var password = $('input[name=password]'); var data = 'username=' + username.val() + '&password=' + password.val(); .ajax({ url: "login.php", type: "GET", data: data, cache: false, success: function() { alert("SUCCESS"); } }); return false; }); }); And this is my PHP page: Code: [Select] <?php $username = ($_GET['username']) ? $_GET['username'] : $_POST['username']; $password = ($_GET['password']) ? $_GET['password'] : $_POST['password']; if ($_POST) $post=1; $userFound = false; $memberId = ""; // Create connection string, Note, params are as follow // mysql_connect(databaseLocation, username, password) $con = mysql_connect("localhost","root",""); if (!$con) { die("Could not connect: " . mysql_error()); } mysql_select_db("memberdb", $con); // SQL Query $result = mysql_query("SELECT memberId, firstName, lastName, username, password FROM member"); while($row = mysql_fetch_array($result)) { if ($username == $row["username"] && $password == $row["password"]) { echo "<h1>Welcome " . $row["firstName"] ." ". $row["lastName"] . "! </h1></br>"; $userFound = true; $memberId = $row["memberId"]; } } // If User is found, continue on to next page, if not redirect to index.html if ($userFound) { echo "<h2>Login Successful</h2>"; echo "<h3>Page will redirect</h3>"; header( "url=menu.html?memberId=" . $memberId); } else { echo "<h2>LOGIN FAILED</h2>"; echo "<h3>Page will redirect</h3>"; header( "refresh: 1; url=index.html#loginPage"); } ?> It does the echo successfully but hangs on the part where is says : Quote header( "url=menu.html?memberId=" . $memberId); How can I get it to redirect? Thanks Hi Everyone was kind enough to help with my last issue and am now nearly there. The data actually populates correctly now in my database, however, it will not direct me to my redirect. I get the error Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\loginsystem\Permnew.php:4) in C:\xampp\htdocs\loginsystem\Permnew.php on line 124 This is the redirect i am trying to do anyone any ideas? Thanks Steve
<?php require "header.php"; ?> <main> <div class="wrapper-main"> <div class="welcomelogged"> <p>Adding A Permanent New Starter<p> </div> <form class="form-addperm" action="" method="post"> <table id="Tableperm" width="1000px;" border="0"> <tr> <th align="right" scope="row"><label for="select">Week Commencing</label></th> <td><select name="WeekComm"> <option value="WC 6th April">WC 6th April</option> <option value="WC 13th April">WC 13th April</option> <option value="WC 20h April">WC 20h April</option> <option value="WC 27h April">WC 27h April</option> </select></td> </tr> <tr> <th align="right" scope="row"><label for="StartDate">Start Date</label></th> <td><input type="date" name="StartDate" placeholder="Start Date"></td> </tr> <tr> <th align="right" scope="row"><label for="select1">Consultant</label></th> <td><select name="Consultant"> <option value="Steven Buntin">Steven Buntin</option> <option value="Sam Ahmed">Sam Ahmed</option> <option value="David Millington">David Millington</option> <option value="Steven Nixon">Steven Nixon</option> <option value="Grahame Walsh">Grahame Walsh</option> <option value="Helal Ahmed">Helal Ahmed</option> </select></td> </tr> <tr> <th align="right" scope="row"><label for="FirstName">First Name</label></th> <td><input type="text" name="FirstName" placeholder="First Name"></td> </tr> <tr> <th align="right" scope="row"><label for="LastName">Last Name</label></th> <td><input type="text" name="LastName" placeholder="Last Name"></td> </tr> <tr> <th align="right" scope="row"><label for="ClientName">Client Name</label></th> <td><input type="text" name="ClientName" placeholder="Client Name"></td> </tr> <th align="right" scope="row"><label for="Position">Position</label></th> <td><input type="text" name="Position" placeholder="Position"></td> </tr> <th align="right" scope="row"><label for="Comments">Comments</label></th> <td><input type="text" name="Comments" placeholder="Comments"></td> </tr> <tr> <th align="right" scope="row"><label for="Salary">Salary</label></th> <td><input type="varchar" name="Salary" placeholder="Salary"></td> </tr> <tr> <th align="right" scope="row"><label for="ChargePercentage">Charge Percentage</label></th> <td><input type="varchar" name="ChargePercentage" placeholder="ChargePercentage"></td> </tr> <ty> <th align="right" scope="row"><label for="GPNotes">GP Notes</label></th> <td><input type="text" name="GPNotes" placeholder="GPNotes"></td> </tr> </table> <button type="submit" name="addstarter">Add Starter</button> </form> </div> </main> <?php $dBServername = "localhost"; $dBUsername = "root"; $dBPassword = ""; $dBName = "loginsystemtut"; mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $conn = mysqli_connect($dBServername, $dBUsername, $dBPassword, $dBName); if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } if (isset($_POST['addstarter'])) { $WeekComm = $_POST['WeekComm']; $StartDate = $_POST['StartDate']; $Consultant = $_POST['Consultant']; $FirstName = $_POST['FirstName']; $LastName = $_POST['LastName']; $ClientName = $_POST['ClientName']; $Position = $_POST['Position']; $Comments = $_POST['Comments']; $Salary = $_POST['Salary']; $ChargePercentage = $_POST['ChargePercentage']; $GPNotes = $_POST['GPNotes']; $sql = ("INSERT INTO permanent (WeekComm, StartDate, Consultant, FirstName, LastName, ClientName, Position, Comments, Salary, ChargePercentage, GpNotes) values (?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmt = mysqli_stmt_init($conn); if (!mysqli_stmt_prepare($stmt, $sql)) { // If there is an error we send the user back to the signup page. header("Location: ../signup.php?error=sqlerror"); exit(); } else { mysqli_stmt_bind_param($stmt,"sssssssssss",$WeekComm,$StartDate,$Consultant,$FirstName,$LastName,$ClientName,$Position,$Comments,$Salary,$ChargePercentage,$GPNotes); mysqli_stmt_execute($stmt); } header("Location: ../loginsystem/permnew1.php?success"); exit(); } ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <style> .error {color: #FF0000;} h6 { font-family: bookman old style; font-size:20px; text-align: center; font-weight: normal; } h5 { font-family: bookman old style; font-size:15px; text-align: center; font-weight: normal; } </style> <?php $nameErr = $emailErr = $websiteErr = $categoryErr; $name = $email = $comment = $website = $reset = $category; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $name = test_input($_POST["name"]); if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Only letters and white space allowed"; } } if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; } } if (empty($_POST["website"])) { $websiteErr = "URL is required"; } else { $website = test_input($_POST["website"]); if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) { $websiteErr = "Invalid URL"; } } if (empty($_POST["comment"])) { $comment = ""; } else { $comment = test_input($_POST["comment"]); } if (empty($_POST["category"])) { $categoryErr = "Category is required"; } else { $category = test_input($_POST["category"]); } if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['website']) && !empty($_POST['category'])) { $myemail = "links@loadsofads.com"; $subject = "Link Submission"; $message = "Your Link Submission form has been submitted by: Website Name: $name E-mail: $email URL: $website Category: $category Description: $comment"; mail($myemail, $subject, $message); header('location:submitthanks.php'); }} function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <?php include'header.php'?> <h6>Link Submission</h6> <h5><p><span class="error">* required field.</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> Name Of Site: <input type="text" name="name" value=""> <span class="error">* <?php echo $nameErr;?></span> <br><br> E-mail: <input type="text" name="email" value=""> <span class="error">* <?php echo $emailErr;?></span> <br><br> URL: <input type="text" name="website" value=""> <span class="error">* <?php echo $websiteErr;?></span> <br><br> Description: <textarea name="comment" rows="5" cols="40"></textarea> <br><br> Category Of Site: <select size="1" name="category"> <option value=""> -- Please select -- </option> <option>Arts</option> <option>Business</option> <option>Computers</option> <option>Games</option> <option>Health</option> <option>Home</option> <option>Kids and Teens</option> <option>News</option> <option>Recreation</option> <option>Reference</option> <option>Science</option> <option>Shopping</option> <option>Society</option> <option>Sports</option> <option>World</option> </select><span class="error">* <?php echo $categoryErr;?></span> <br><br> <input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Reset Form"> </form> <?php include'footer.php'?>Hello All, OK so I have been at this for a few days now and everywhere I go to learn or read information it says the same thing, to redirect the code is header('location:mypage.php');exit(); but it just will not redirect it every thing I try it does not load the redirect page. it clears the form and sits there, I do not know why! Can please someone please help me and see why it is not doing it? Thanks I cannot use a header redirect anymore because I'm echo'ing out in the header.php file for the navigation, which will echo out a profile and settings button ONLY if the user is logged in, it's basically a simple if statement with session variables. Now when the user goes to the login page and has successfully logged in I'd like to redirect the user to the main page, but of course this won't work since I have already an echo in the header.php file for the navigation. So my question is, is there a workaround or alternate redirect for this case? I need to know if what I am doing will even work. I have a .php page which submits information into a form to a insert_form.php page which then parses then information and adds it to a DB. In this insert_form.php page I have a function which is being called which is located in another .php file called function.php. This function adds images to the file system and will display errors if anything happens to the user. I do this by doing a header redirect: Code: [Select] header('location:link.php?error=error message that i want to display'); The problem is the function is working because the images are being loaded correctly, but if something happens to the images and the header redirect gets initiated, its not redirecting. I need to know if the header redirect would work when being a function in another file or not. thanks beemer Hello, I am new to some of the rules to PHP as far as what you can POST or SEND via forms in PHP. I am attempting to change the location of a page via the header() function and basically redirect to another page if the weather is inclimate at an outdoor events center. Currently what I have is two different submit buttons that would post the header() redirect based on if the weather is good or bad. Ex. <div style="width:220px; height:50px;"> <form method="POST" action="../../weather.php"> <input type="submit" value="Good Weather" name="weather_good" /> <input type="submit" value="Bad Weather" name="weather_bad" /> </form> </div> Then the processing for the form is this file - <?php if(isset($_POST['weather_good'])){ $myFile = "../myfile.php"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = echo "<?php header ('Location:fall_festival/index.php'); ?>"; fwrite($fh, $stringData); fclose($fh); echo "Page Updated"; } else if(isset($_POST['weather_bad'])){ $myFile = "../myfile.php"; $fh = fopen($myFile, 'w') or die("can't open file"); $link = "header('Location:fall_festival/weather/index.php');" ; $stringData = $link; fwrite($fh, $stringData); fclose($fh); echo "Page Updated"; } ?> The file doesn't return an error when it's processed but it also doesn't update the file header and redirect to the proper page. Thanks for your time and help! I am running a nginx web server. with this following config return 302 https://www.mysite.com/game_errorpage.php?sub=$name; The intent, is if someone types in "blah.mysite.com" and that subdomain (game server) is not running, I want them to be redirected to a error page. This error page then starts the game game server in question. This all works up to to this point. Then I want to redirect the user back to the original request url, to log into their game "blah.mysite.com" I use the following php header("Location: https://blah.mysite.com"); exit(); The issue I have is, because the browser has it cached already as https://www.mysite.com/game_errorpage.php?sub=$name it keeps returning there even though the game server is now running. The only thing I can do is close all the browsers and open a new window in Chrome using "Incognito" then type the url again. I have the following in my global file, for all pages. header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); So I am looking for some creative solutions. Thanks. Brad
Edited March 11, 2020 by Daxcor All, I found the following script to do the download: $resultsetpic = mysql_fetch_array($resultpic); $filename = "full_size/$resultsetpic[filename]"; // don't accept other directories $size = @getimagesize($filename); $fp = @fopen($filename, "rb"); if ($size && $fp) { header("Content-type: {$size['mime']}"); header("Content-Length: " . filesize($filename)); header("Content-Disposition: attachment; filename=$filename"); header('Content-Transfer-Encoding: binary'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); fpassthru($fp); exit; } This downloads the file fine. However what I would like to do is also refresh the page that the user was just on. So I tried to add this: $resultsetpic = mysql_fetch_array($resultpic); $filename = "full_size/$resultsetpic[filename]"; // don't accept other directories $size = @getimagesize($filename); $fp = @fopen($filename, "rb"); if ($size && $fp) { header("Content-type: {$size['mime']}"); header("Content-Length: " . filesize($filename)); header("Content-Disposition: attachment; filename=$filename"); header('Content-Transfer-Encoding: binary'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); fpassthru($fp); exit; } $target = "work_queue.php"; header("Location:". $target); However, this doesn't reload the page they were on. Any ideas on how to do this? Thanks in advance. I've got an issue with a header redirect that is confusing me. I haven't been able to find any similar problems that have help me solve it and the PHP man page on headers isn't helping me either. <?php if(isset($_POST['add_cat'])) { $cat_obj->add_category($_POST['cat_title']); header("Location: admin/category.php"); } ?> This code is in a file called add_category.php which is in the same directory as the category.php file I want it to redirect to. without the 'header..' line it works perfectly; but with the 'header..' line I get the following warning - QuoteWarning: Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/**/**/admin/add_category.php:2) in /opt/lampp/htdocs/**/**/admin/add_category.php on line 30
but there's no other place sending headers (that I can see) and to my inexperienced eye it seems like it's cyclical logic as it's saying the same line I want to send the redirect is the one that already sent it. Would someone mind giving me an ELI5 breakdown of why this isn't working properly and maybe a route to solving the problem, please? TIA I am trying to find a way to check if a user has already entered their email address in my MySQL database.
If they have an entry then it jumps to another script that avoids the questionnaire, but if they have no entry, then they do the questionnaire.
I have tried using
header('Location: /questionnaire.html');
but I get this error warning:
Warning: Cannot modify header information - headers already sent by (output started at /homepages/43/d344817611/htdocs/Test/questionnaire_connect.php:14) in /homepages/43/d344817611/htdocs/Test/eCheck.php on line 16
The script I am using:
<?php include('questionnaire_connect.php'); doDB12(); if ($_POST["email"] == "") { header("Location: emailChecker.html"); exit; } else { //check that email is in list emailChecker($_POST["email"]); //get number of results and do action if (mysqli_num_rows($check_res) < 1) { //free result mysqli_free_result($check_res); header('Location: /questionnaire.html'); }else { header('Location: /Alt_inputform.html'); } } //close connection to MySQL mysqli_close($mysqli); ?>The emailChecker is a function in the DB connect script: function emailChecker($email) { global $mysqli, $check_res; //check that email is not already in list $check_sql = "SELECT id FROM questionnaire WHERE email = '".$email."'"; $check_res = mysqli_query($mysqli, $check_sql) or die(mysqli_error($mysqli)); }Is there another way I can redirect the program flow other than using Header? Hi, Why doesn't this work? Driving me nuts! Thanks. <?php if($_SERVER[PHP_SELF] == 'somepage.php') { Header("Location: http://www.thissite.com"); } else { Header("Location: http://www.anothersite.com"); } ?> The code NEVER redirects to the first URL (thissite.com). It ALWAYS redirects to the second URL (anothersite.com). What the heck am I doing wrong? Hi I've been working on a site for 6 months and have used the header command to redirect loads and loads of times. But i just noticed some crazy behaviour today. Heres a test page: <?php include("includes/db_connect.php"); header('location:stores.php'); $sql = "insert into test (id) values (77)"; $result = mysql_query($sql); ?> when i hit this page, i get redirected to stores.php, but the sql gets executed! Is this supposed to be the behaviour? Have i completely missed the point of header(location:)?? Im baffled as i've used this before, but only now noticed this crazy behaviour! this code works if i use the header() in the else section it doesnt but it will echo the commented part Code: [Select] <? /** * User has already logged in, so display relevant links, including * a link to the admin center if the user is an administrator. */ if($session->logged_in){ echo "<li>Logged In "; echo "<b>$session->username</b></li>"; if($session->isAdmin()){ echo "<li><a href=\"LoginSystem/admin/admin.php\">Admin Center</a></li>"; } echo "<li><a href=\"../LoginSystem/process.php\">Logout</a</li>"; } else{header("Location: ../LoginSystem/main.php"); //echo "<li><a href=\"../LoginSystem/process.php\">Login</a></li>"; } ?> |