brown2005 Posted September 21, 2006 Share Posted September 21, 2006 hi i want to useheader('location http://www.randomhomepage.co.uk/index/faq.php');but how can i write it using it likeheader('location: $config_website_url/$config_website_url_topic/index.php?page=faq');because the above doesnt work...thanks Quote Link to comment https://forums.phpfreaks.com/topic/21541-help-with-headerlocation/ Share on other sites More sharing options...
obsidian Posted September 21, 2006 Share Posted September 21, 2006 use double quotes like any other time you would be interpreting variables:[code]<?phpheader("Location: $config_website_url/$config_website_url_topic/index.php?page=faq");?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/21541-help-with-headerlocation/#findComment-96118 Share on other sites More sharing options...
brown2005 Posted September 21, 2006 Author Share Posted September 21, 2006 omg, i feel so stupid... i think the day is catching up with me..lolthanks alot Quote Link to comment https://forums.phpfreaks.com/topic/21541-help-with-headerlocation/#findComment-96119 Share on other sites More sharing options...
brown2005 Posted September 21, 2006 Author Share Posted September 21, 2006 hey, is there any reason why it would not goto the page?take a look at www.randomhomepage.co.uk/index/index.php?page=contact, it should go to www.randomhomepage.co.uk/index/index.php?page=faqbut doesnt... Quote Link to comment https://forums.phpfreaks.com/topic/21541-help-with-headerlocation/#findComment-96121 Share on other sites More sharing options...
ober Posted September 21, 2006 Share Posted September 21, 2006 echo out the string you're creating to make sure that it is correct. Quote Link to comment https://forums.phpfreaks.com/topic/21541-help-with-headerlocation/#findComment-96124 Share on other sites More sharing options...
obsidian Posted September 21, 2006 Share Posted September 21, 2006 it depends on how you've got your code set up. i don't know where your redirect is placed. you're linking me to ?page=contact, so your redirect would have to be within the content of the contact page. plus, you've got to make sure that any headers you're passing come before [b]any[/b] HTML is output to the browser Quote Link to comment https://forums.phpfreaks.com/topic/21541-help-with-headerlocation/#findComment-96125 Share on other sites More sharing options...
brown2005 Posted September 21, 2006 Author Share Posted September 21, 2006 <?phpsession_start(); header("Location: http://www.randomhomepage.co.uk/index/index.php?page=faq");?>that is my contact.php page<?session_start();if(!isset($page))$page="home";switch($page){ case "account":$file="files/account.php"; break; case "contact":$file="files/contact.php"; break; case "home":$file="files/home.php"; break; case "faq":$file="files/faq.php"; break; case "statistics":$file="files/statistics.php"; break; case "test":$file="files/test.php"; break; }?>thats my pages.php page Quote Link to comment https://forums.phpfreaks.com/topic/21541-help-with-headerlocation/#findComment-96126 Share on other sites More sharing options...
brown2005 Posted September 21, 2006 Author Share Posted September 21, 2006 can anybody help on this please? Quote Link to comment https://forums.phpfreaks.com/topic/21541-help-with-headerlocation/#findComment-96278 Share on other sites More sharing options...
obsidian Posted September 21, 2006 Share Posted September 21, 2006 where are you actually including the content of your contact.php page? Quote Link to comment https://forums.phpfreaks.com/topic/21541-help-with-headerlocation/#findComment-96283 Share on other sites More sharing options...
brown2005 Posted September 21, 2006 Author Share Posted September 21, 2006 sorry i dont understand what u mean?<?phpsession_start(); header("Location: http://www.randomhomepage.co.uk/index/index.php?page=faq");?>that bit Quote Link to comment https://forums.phpfreaks.com/topic/21541-help-with-headerlocation/#findComment-96292 Share on other sites More sharing options...
obsidian Posted September 21, 2006 Share Posted September 21, 2006 somehow, you have to be including you contact.php into your index.php. your link you gave us is to a file index.php?page=contact, right? so, somewhere in index.php, you have to be including the content of contact.php in order for that code to be executed. Quote Link to comment https://forums.phpfreaks.com/topic/21541-help-with-headerlocation/#findComment-96300 Share on other sites More sharing options...
brown2005 Posted September 21, 2006 Author Share Posted September 21, 2006 <?php session_start();include('include/include.php');include('include/hits.php');$page = $_GET['page'];if($page == ""){ header("location: http://www.randomhomepage.co.uk/index/index.php?page=home");}else{ if($page == "home") { include($file); } elseif($page == "test") { include($file); } else { echo"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional dtd'>"; echo"<html xmlns='http://www.w3.org/1999/xhtml'>"; echo"<head>"; echo"<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />"; echo"<title>$config_website</title>"; echo"<link href='$config_website_url/include/style/style.css' rel='stylesheet' type='text/css' />"; include ('include/scripts.php'); echo"</head>"; echo"<body bgcolor='#ffffff'>"; echo"<table width='100%' border='0' cellspacing='0' cellpadding='0'>"; echo" <tr> <td>"; include ('header.php'); echo" </td> </tr>"; echo" <tr> <td>"; include ('logo.php'); echo" </td> </tr>"; echo" <tr> <td>"; include ('navigation.php'); echo" </td> </tr>"; echo" <tr> <td>"; include($file); echo" </td> </tr>"; echo" <tr> <td>"; include ('footer.php'); echo" </td> </tr>"; echo"</table>"; echo"</body>"; echo"</html>"; } }?>thats my index page.... Quote Link to comment https://forums.phpfreaks.com/topic/21541-help-with-headerlocation/#findComment-96309 Share on other sites More sharing options...
obsidian Posted September 21, 2006 Share Posted September 21, 2006 ok, and since 'contact' doesn't fit any of the first conditions, it's trying to be included in the middle of the HTML, right? on this line:[code]<?phpecho "<tr><td>";include($file);echo "</td></tr>";?>[/code]is that right? if so, it's not working because you're trying to send header information AFTER HTML is being output like i mentioned above. Quote Link to comment https://forums.phpfreaks.com/topic/21541-help-with-headerlocation/#findComment-96315 Share on other sites More sharing options...
brown2005 Posted September 22, 2006 Author Share Posted September 22, 2006 so how will i combat this problem then? Quote Link to comment https://forums.phpfreaks.com/topic/21541-help-with-headerlocation/#findComment-96701 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.