Page 1 of 1
Redirection problem
Posted: Mon Jul 19, 2004 10:25 am
by raziel666
Hi
I'm using a form to insert some data on a database. After the data is inserted I have added an if {} statement (which is working) and I want (depending on the result of the if) to go to some other page. I haven't found any way yet (except one that shows both pages in one - apparently this is not wanted!). Any ideas?
Posted: Mon Jul 19, 2004 10:26 am
by kettle_drum
Check out header() in the php manual. It will show you an exmaple of how to redirect to another page. Just use this to redirect to whichever page you need to.
Posted: Mon Jul 19, 2004 10:26 am
by feyd

[php_man]header[/php_man]
Posted: Mon Jul 19, 2004 10:27 am
by kettle_drum
Oh and if you dont want to use that then you can always use meta tags or javascript.
Posted: Mon Jul 19, 2004 10:39 am
by raziel666
thanks
I'll try with header()
Posted: Mon Jul 19, 2004 10:57 am
by raziel666
I've tried with header() and I get :
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\add_question.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\add_question.php on line 68
The code near is:
... --> code for inserting data from a form to a database
Code: Select all
<?php if ($alts ==8)
{
header("add_answer_w_5_alt.php"); ----> This is line 68
}
?>
Any ideas why this might happen?
Posted: Mon Jul 19, 2004 11:02 am
by feyd
you've got text output starting at line 2 of the file C:\Program Files\Apache Group\Apache2\htdocs\add_question.php
Posted: Mon Jul 19, 2004 11:04 am
by markl999
And shouldn't that be header("Location: add_answer_w_5_alt.php");
Posted: Mon Jul 19, 2004 5:57 pm
by WaldoMonster
Code: Select all
<?php
if (some condition)
{
echo '<meta http-equiv="refresh" content="0;URL=another_page.php">';
exit();
}
?>
The header can only be used before any HTML or other output!
Refresh can be used after some HTML or other output.