This topic is locked

Error using ListOnLoad event with a page redirect

3/7/2006 9:21:33 AM
PHPRunner General questions
I
ipreedy author

Hi,
I'm getting an error using the page redirect option in the ListOnLoad event. After checking the templates and looking at the generated code, it appears that the HTML header has already been created when this event fires. Any ideas on a work around?
Here is my code
function ListOnLoad($strSQL)

{

//** Redirect to another page ****

if (!isset($_SESSION["AuctionDetail_masterkey"])){

header("Location: ./Auction_list.php");

exit();

}
}
And the error
PHP error happened
Technical information

Error type 2

Error description Cannot modify header information - headers already sent by (output started at /data/apache/htdocs/iap/auction/include/jsvariables.php:23)

URL 192.168.42.89/iap/auction/AuctionDetail_list.php?

Error file /data/apache/htdocs/iap/auction/include/AuctionDetail_events.php

Error line 54

SQL query select `ID_AuctionDetail`, `ID_Auction`, `Item`, `ReservePrice`, `LastUpdated`, `LotNumber` From `AuctionDetail` ORDER BY `ID_AuctionDetail` ASC

HomeModulesHelpLogout

Sergey Kornilov admin 3/7/2006

Ian,
Redirect option don't work for ListOnLoad event.

You can do it using JavaScript.

See my example below:

function ListOnLoad($strSQL)

{

if (!isset($_SESSION["AuctionDetail_masterkey"])){

?>

<script>

window.location='./Auction_list.php';

</script>

<?php


exit();

}

}

I
ipreedy author 3/7/2006

Hi Serg,
Thanks for the quick response. This did the trick.

T
thesofa 9/4/2006

Ian,

Redirect option don't work for ListOnLoad event.

You can do it using JavaScript.

See my example below:



I am sorry to re-awaken this dormant thread, I have a similar problem. I too wish to avoid the list page and jump straight to the Add New Record page.

SO I tried the code above, thank you, it worked well.

However, I have yet to find a way out of the code, back to the main menu.

I see Ian had some code to check for the existance of a record masterkey before the code was called.

I need to be able to go straight to the add record page, add one or more records, then return to the main menu.

What would you suggest, should I put another button on the page, or can I do it with an event?

J
Jane 9/5/2006

Hi,
you can add link to menu on the ADD page.

Open ..._add.php file, find following line:

echo "<div align=left><hr width=300 noshade size=1></div>";



and add your code after it.

Here is a sample code:

echo "<a href = \"menu.php\">MENU</a>
";

T
thesofa 9/5/2006



I am sorry to re-awaken this dormant thread, I have a similar problem. I too wish to avoid the list page and jump straight to the Add New Record page.

SO I tried the code above, thank you, it worked well.

However, I have yet to find a way out of the code, back to the main menu.

I see Ian had some code to check for the existance of a record masterkey before the code was called.

I need to be able to go straight to the add record page, add one or more records, then return to the main menu.

What would you suggest, should I put another button on the page, or can I do it with an event?



Spot on yet again, the support on this site is brilliant.

Is it possible to add this link through the add a message event?

Or can I just add it to some custom code without borking the application.

I seem to have it running at the moment, so all changes are a fragile thing now.

Many Many thanks for all your efforts in helping me sort this application.

J
Jane 9/6/2006

George,
if you want to add your code to AddOnLoad event you can use following code:

function AddOnLoad()

{

echo "<a href=\"menu.php\">menu</a>";

}

T
thesofa 9/6/2006

George,

if you want to add your code to AddOnLoad event you can use following code:



thank you once again.

I was doubtful about buying this product when I first started.

It has been the best value for money software I have EVER bought.

Many thanks again. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=10923&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />