Need help with redirecting in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: Need help with redirecting in PHP

Post by JKM »

Warning: Cannot modify header information - headers already sent by (output started at /home/xx/index.php:1) in /home/xx/index.php on line 2
stevoo
Forum Newbie
Posts: 9
Joined: Tue Aug 26, 2008 3:58 pm

Re: Need help with redirecting in PHP

Post by stevoo »

Code: Select all

<?
     if($_POST['submit'] == TRUE) 
             header("Location: http://google.com/");
         else 
             echo 'not Yet!';
         
       
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>LOLL</title>
  </head>
  <body>
  
  <form enctype="multipart/form-data" action="" method="post">
      <input type="submit" name="submit" value="GO!" />
  </form>
  </body>

As i said this works ....
now copy paste it and click GO

If it still doesnt work , then try http://www.amazon.com/PHP-5-Dummies-Jan ... 0764541668
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: Need help with redirecting in PHP

Post by JKM »

It doesn't work. And what is it to learn here, when the most simple examples from php.net won't work?
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Need help with redirecting in PHP

Post by jayshields »

Make sure you have absolutely no white space before your PHP tags too. Including line breaks.
User avatar
Ziq
Forum Contributor
Posts: 194
Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh

Re: Need help with redirecting in PHP

Post by Ziq »

deleted
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: Need help with redirecting in PHP

Post by JKM »

jayshields: No whitespaces.
What's mean? Any errors? I'm not telepath.
If any other errors than the one I've pasted some times now, I would have noticed you about it.[/quote] ;-)
User avatar
Ziq
Forum Contributor
Posts: 194
Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh

Re: Need help with redirecting in PHP

Post by Ziq »

Ok, i don't know... attached your file this code

this file /home/xx/index.php
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: Need help with redirecting in PHP

Post by JKM »

...?
User avatar
Ziq
Forum Contributor
Posts: 194
Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh

Re: Need help with redirecting in PHP

Post by Ziq »

Upload file /home/xx/index.php in forum.

P.S. Then you click "post a reply" "Upload attachment" header
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: Need help with redirecting in PHP

Post by JKM »

index.rar
(519 Bytes) Downloaded 35 times
User avatar
Ziq
Forum Contributor
Posts: 194
Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh

Re: Need help with redirecting in PHP

Post by Ziq »

You have output information before send headers ("п»ї")

Try this
Attachments
index.rar
(510 Bytes) Downloaded 54 times
stevoo
Forum Newbie
Posts: 9
Joined: Tue Aug 26, 2008 3:58 pm

Re: Need help with redirecting in PHP

Post by stevoo »

for the below commnenct



Actually me neither i cant see a difference but i can see that there is a size differece of 8 bytes ...

what exactly did you change ?

and how come the first one was working for me....
Last edited by stevoo on Tue Aug 26, 2008 5:24 pm, edited 1 time in total.
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: Need help with redirecting in PHP

Post by JKM »

wtf, it worked. Can you tell me exactly what you did? Because when I set the two documents next to each other - I can't see any difference. Thx alot! :-)
User avatar
Ziq
Forum Contributor
Posts: 194
Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh

Re: Need help with redirecting in PHP

Post by Ziq »

You are use UTF-8 in your file. I don't know how exactly PHP work this UTF-8 files, but better don't use it.
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: Need help with redirecting in PHP

Post by JKM »

Okay, but which changes did you make from my version of index.php to yours?
Post Reply