RE: [PHP-WIN] Redirect

From: Date: Tue, 20 Aug 2002 16:38:24 +0000
Subject: RE: [PHP-WIN] Redirect
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-15365@lists.php.net to get a copy of this message
It may sound rather obvious, but don't send any header information :) The error you are getting means that you have echoed or printed something to the output, and have already started generating the HTML page. Don't do this. Jump into the php code straight away (no introductory HTML code) and test the conditions you want to test. Observe: <?php if (user_and_pass_ok) { set a cookie or session var to log them in; header("Location: home.html"); } else { either print an error message OR; header("Location: login.html"); but not both. Print an error or redirect. } ?> > -----Original Message----- > From: Rodrigo San Martin [mailto:rodrigo@stud.ntnu.no] > Sent: 20 August 2002 07:46 > To: php-windows@lists.php.net > Subject: [PHP-WIN] Redirect > > > Halo. > > I need som help with my script. I need to find a way to redirect my script > to another file. I start with the login file, which is a html > file, and send > variables through it to a file I call do_login. This checks if > username and > password is correct. On the top of this file I have a if statement that > checks if the user has writen on the username and password box. > If not, they > get sent back to the login.html by a header("location:login.html"); > > Now, if username and password checks out i want to sent them to the start > page. The problem is the I already have sent header information > and cant use > Header() anymore. > > Can someone tell me an easy way to solve this problem > > Thanks... > > > > ------------------------------------------ > Rodrigo San Martin > Institutt for datateknologi og informatikk > > http://www.idi.ntnu.no/~rodrigo > > > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.windows (#15365) next »