Jump to content

Insert data in Mysql and move to another page


md7dani

Recommended Posts

if only you wants to move to next page after hitting submit you can use headers

 

like:

 

if(isset($_POST['submit'])) {
//process datbase and use some statement if all goes well move to next page,
// and if you need those variables in your next page you can use sessions  
header('Location: nextpage.php')
}

I'm using a session on the same page so I can't use header, too bad..

??  you can use sessions and header() on the same page.  where'd you get that piece of information from?

 

I allways get this when I do that:

 

Warning: Cannot modify header information - headers already sent by (output started at /mail_send.php:10) in /mail_send.php on line 38

 

 

Hi,

 

For the below code.  Make sure that there is no code before header("Location: nextpage.php") that outputs any text or errors.  Also try putting the code above all html code on the page, basically the first lines on the page above the HEAD, TITLE, BODY DOCTYPE...

 

Also are you sure your mail_send.php is not outputting a message or error.  That would stop the header location from working potentially?

 

if(isset($_POST['submit']))
{
    // PROCESS DATA POST TO DB e.g. execute function here...
    if(!mysql_error())
    {
       header('Location: nextpage.php');
    }
}
else
{
   //do the funky chicken
}

 

I allways get this when I do that:

 

Warning: Cannot modify header information - headers already sent by (output started at /mail_send.php:10) in /mail_send.php on line 38

 

That error has nothing to do with sessions and a header() on the same page. It has to do with your code sending output before doing something that requires the use of a header - output started at /mail_send.php:10 (line 10)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.