Jump to content

Archived

This topic is now archived and is closed to further replies.

brown2005

help with header(location: )

Recommended Posts

hi i want to use

header('location http://www.randomhomepage.co.uk/index/faq.php');

but how can i write it using it like

header('location: $config_website_url/$config_website_url_topic/index.php?page=faq');

because the above doesnt work...

thanks

Share this post


Link to post
Share on other sites
use double quotes like any other time you would be interpreting variables:
[code]
<?php
header("Location: $config_website_url/$config_website_url_topic/index.php?page=faq");
?>
[/code]

Share this post


Link to post
Share on other sites
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=faq

but doesnt...

Share this post


Link to post
Share on other sites
echo out the string you're creating to make sure that it is correct.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
<?php

session_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

Share this post


Link to post
Share on other sites
where are you actually including the content of your contact.php page?

Share this post


Link to post
Share on other sites
sorry i dont understand what u mean?

<?php

session_start();
     
header("Location: http://www.randomhomepage.co.uk/index/index.php?page=faq");

?>

that bit

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
<?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....

Share this post


Link to post
Share on other sites
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]
<?php
echo "<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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.