Jump to content


Photo

help with header(location: )


  • Please log in to reply
13 replies to this topic

#1 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 21 September 2006 - 02:52 PM

hi i want to use

header('location http://www.randomhom...k/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

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 21 September 2006 - 02:55 PM

use double quotes like any other time you would be interpreting variables:
<?php
header("Location: $config_website_url/$config_website_url_topic/index.php?page=faq");
?>

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 21 September 2006 - 02:58 PM

omg, i feel so stupid... i think the day is catching up with me..

lol

thanks alot

#4 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 21 September 2006 - 03:02 PM

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...

#5 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 21 September 2006 - 03:05 PM

echo out the string you're creating to make sure that it is correct.

Info: PHP Manual


#6 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 21 September 2006 - 03:06 PM

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 any HTML is output to the browser
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#7 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 21 September 2006 - 03:09 PM

<?php

session_start();
     
header("Location: http://www.randomhom...x.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

#8 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 21 September 2006 - 07:46 PM

can anybody help on this please?


#9 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 21 September 2006 - 07:49 PM

where are you actually including the content of your contact.php page?
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#10 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 21 September 2006 - 07:57 PM

sorry i dont understand what u mean?

<?php

session_start();
     
header("Location: http://www.randomhom...x.php?page=faq");

?>

that bit

#11 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 21 September 2006 - 08:05 PM

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.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#12 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 21 September 2006 - 08:17 PM

<?php

session_start();

include('include/include.php');
include('include/hits.php');

$page = $_GET['page'];

if($page == "")
{
 
header("location: http://www.randomhom....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...l1-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....

#13 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 21 September 2006 - 08:28 PM

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:
<?php
echo "<tr><td>";
include($file);
echo "</td></tr>";
?>

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.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#14 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 22 September 2006 - 01:22 PM

so how will i combat this problem then?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users