Forum Moderators: coopster

Message Too Old, No Replies

PHP Redirection

Asking PHP to exit on error

         

x9183

10:11 am on Sep 5, 2007 (gmt 0)

10+ Year Member



Can anybody help? I am using "MAINMENU" built in HTML forms to get to get me to where I want to be (Add, Update or Print record) and of course I cannot update or print a record that does not exist. Here is a snippet of the coding.

<?PHP session_start(); PHP?>
<HTML>
HTML coding
more HTML coding

<?PHP>
PHP coding
more PHP coding
.
$q="Select SQL_CALC_FOUND_ROWS * FROM test_table
WHERE customer = 99999990 ORDER BY invoices LIMIT $cps, $rpp";
.
PHP coding
more PHP coding
more coding
.
if ($number_of_records == 0)
{$link = "http://www.example.com/mainmenu.php";}

I want to return to the mainmenu, if invalid operation. For this test I am using 99999990 as the dummy customer

I have also tried
header('Location: http://www.example.com/mainmenu.php);
With this PHP really gets hacked-off pointing me to a line which contains the following coding.
<script language="JavaScript" type="text/javascript"> As to why, I haven't a clue.

[edited by: dreamcatcher at 10:26 am (utc) on Sep. 5, 2007]
[edit reason] Use example.com, thanks. [/edit]

Habtom

10:34 am on Sep 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you getting "headers already sent" error?

If yes, you might need to make sure that there is no output (not even a space) sent to the browser before this line
header('Location: http://www.example.com/mainmenu.php);

and, welcome to WebmasterWorld.

Habtom

[edited by: Habtom at 10:34 am (utc) on Sep. 5, 2007]