Jump to content


Photo

php redirect


  • Please log in to reply
6 replies to this topic

#1 desithugg

desithugg
  • Members
  • PipPipPip
  • Advanced Member
  • 281 posts
  • LocationScarborough

Posted 20 July 2006 - 04:14 PM

okay im using php to redirect pages
<?php
header("Location: index.php?action=1");
?>
but that doesnt work ive tried almost everything i've tried puttng the full url removing the get variable..but it still doesnt work.it's very odd because the redirect function works in some script while it doesnt work in oter it works perfect in my login script.and also here it works.
<?php $location = "http://tpfrpg.byethost32.com/pic/$user1.png"; ?>
<?php
header("Location: {$location}");
?>


i tried doing the same thing but it still doesnt work its quite odd.im not sure what to do.I really need a fast method to redirect and this is the fastest i know.Js/Meta tags slow the process down too much and the users will get frustrated

#2 micah1701

micah1701
  • Members
  • PipPipPip
  • Advanced Member
  • 613 posts
  • LocationEllington, CT USA

Posted 20 July 2006 - 04:16 PM

the code snippet you posted looks fine... what error message are you receiving. it could be an output buffer issue.

whats the error you receive?
"Confidence in the face of risk."

#3 treilad

treilad
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts

Posted 20 July 2006 - 04:17 PM

What error are you getting?

#4 desithugg

desithugg
  • Members
  • PipPipPip
  • Advanced Member
  • 281 posts
  • LocationScarborough

Posted 20 July 2006 - 04:20 PM

im not recieving any errors.It does everything in the script echo what i want but after that when the redirect part comes in it just stops

#5 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 20 July 2006 - 04:22 PM

You cant echo anything before redirecting without using output buffering, and I suggest turning error_reporting on to show you such problems.

There is a sticky thread around here somewhere about header problems I suggest you read it.

#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 20 July 2006 - 04:22 PM

You cannot output anything to the browser before the use of header.

EDIT: Thorpe, beat me :(

FYI there is an FAQ on this too.

#7 desithugg

desithugg
  • Members
  • PipPipPip
  • Advanced Member
  • 281 posts
  • LocationScarborough

Posted 20 July 2006 - 04:27 PM

o i have found the probleam i was using an include file layout which output stuff to the browser.Thanks for you're help.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users