This topic is locked

REDIRECT - whilst keeping the original page open

3/21/2008 11:35:22 AM
PHPRunner General questions
J
jack knowles author

Hi Forum,
I created some logic that redirects the user to an error page.

However, i would like the original ADD Page to be left open, whilst redirecting the user to the new error.php page.
Currectly, i have the following syntax.
if

... blah blah

header("Location: http://www.mywebsite.com/error.php");;)
Not sure how to amend the code.
Any help would be appreciated.
JK

S
spintz 3/21/2008

You don't want to redirect then. You might want to do a popup page with the error. But redirect, by definition, means to change the current page the user is viewing.

J
jack knowles author 3/21/2008

Thank you for your reply.
How would i code a popup window?
Any help would be appreciated
Thank you
JK

J
Jane 3/24/2008

Hi,
here is a sample:

if (...)

{

?><script>

alert('error message');

</script><?php

}

J
jack knowles author 3/25/2008

Thanks Jane,
I have tried the code and it produces a popup.
My only problem is that whilst the popup is displayed, the actual data entry screen is blanked out. My thoughts are that the end user might find this an issue.
Is there a way to overcome this or simply open another HTML page, whilst leaving the original page open.
JK

J
Jane 3/25/2008

Hi,
just return false in the condition. In this case record would not be added and user can edit enetered data.

if (...)

{

?><script>

alert('error message');

</script><?php

}

return false;

J
jack knowles author 3/25/2008

Hi Jane,
I've applied the code as advised, but still seeing the background as a blank white page with a popup dialog box.
What i need to see the entered details on the page and a popup dialog box.
To give you an example, imagine your at the add page and you click the calendar icon. This will keep the original page intact whilst opening a calendar dialog box.
Look forward to your comments
JK

J
Jane 3/26/2008

Hi,
to open new window use window.open JavaScript mathos.

Here is a sample:

?><script>

window.open("error.htm",null,"height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");

</script><?php



where error.htm is your html file with error message.

J
jack knowles author 3/26/2008

Hi Jane,
Still cannot get it to work.
Here is my code:
if ($end_counter<$start_counter){

echo "Error has occurred" . "<br />";

?><script>

window.open("error.htm",null,"height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");

</script><?php

return false;

}else{

return true;

}
When executed and the condition is met the "Error has occurred" message displays. However the window.open script does not run. I've even tried to supply a non existant dummy.htm page to see if the script throws up an error. Again no error.
Not sure why this is not running correct.
Your help would be appreciated.
JK

J
Jane 3/26/2008

Please make sure error.htm file exists in the output directory.