How to go to a URL

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

Post Reply
Jerome
Forum Newbie
Posts: 5
Joined: Sun May 25, 2003 3:10 pm
Location: Santiago, Chile

How to go to a URL

Post by Jerome »

Hello all,

I'm very new to PHP. I have studied the manual but I can't find the function that I need. How do I make the browser go to a specific page (or URL)? To be more precise, I want to do the following. I have page1.php with a form, that goes to page2.php when the submit button is pressed. In page2.php the script adds a record to a MySQL database. I then want it to return to page1.php when it's finished. How do I do that?

Please tell me if you want me to supply the code.

Thanks in advance,

Jerome Smith
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Yeah it's not too obvious, but it is quite simple...

Code: Select all

<?php
Header ("Location: url.php");
?>
It must be at the top and html headers will most likely cause errors if mixed with this.
Jerome
Forum Newbie
Posts: 5
Joined: Sun May 25, 2003 3:10 pm
Location: Santiago, Chile

Error Message

Post by Jerome »

Hi Sami,

Thanks. Yes I tried that, and I got the following error message:

Warning: Cannot modify header information - headers already sent by (output started at /home/ftp/uploads/pruebas/FormIdiomaPrg23.php:4) in /home/ftp/uploads/pruebas/FormIdiomaPrg23.php on line 15

I would be really grateful if you can help me with this.

Jerome
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Since the page you have the header() function on is only going to handle a query there is no need for any html headers or html code (if it's going to be an automatic forwarding).
Jerome
Forum Newbie
Posts: 5
Joined: Sun May 25, 2003 3:10 pm
Location: Santiago, Chile

Post by Jerome »

OK Sami, thanks. I'll try that.
Post Reply