Jump to content

Recommended Posts

Hello

 

I have a php page called potato for.php with 3 different submit buttoms on it

which are called auction, sell and cancel.

 

At the bottom of the page i have this for each of the 3 submit buttoms:

To tell the code what to do after the user selects one of the forrms buttons

 

If (isset($_post["auction"])) {

 

Now that i have this my question is with these how do i redirect the user to

a page like auction.php or to barn.php without using a javascript to do so

 

Thanks

I

Link to comment
https://forums.phpfreaks.com/topic/266404-using-php-to-redirect-after-a-form/
Share on other sites

Do all of the PHP parsing at the very top of the page, and then use variables to store the output.

Doing it this way will ensure that you don't get the dreaded "headers already sent" error message, and it will make it a lot easier to write code.

 

Once you've done that, it's just a matter of using following:

header ('Location: new_file.php');
die ();

 

Remember the "die ()" after a redirect, otherwise PHP will continue parsing the script and potentially create problems.

I have the session_start() posted at the very top of the

page where the form is located and when i went to click on

the link i got the cannot modify headers ...

 

The session_start is before any othwr code is even started including

where i tell the script the database name and info.

 

Im not sure now what the problem iis

The exact error message iis:

 

Warning: cannot send header information - headers already sent by (output startpotato.phped at potato.php:60) in potato.php on line 118.

 

If its refering to line 60 this line has a <?php to start

a new batch of php code

 

Line 118 has this:

header("location: sell.php"); die();

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.