Ask a Question related to PHP Development, Design and Development.
-
iceking #1
How to redirect after (header) after sending an alert message
Hi,
I have a php script that checks whether the user is allowed to perform an
action. If he is not allowed; I display a warning; using the alert function.
After clicking away this function, I want to redirect the user to the
original page using the header function.
However, I get the normal message " headers already sent"... I know what
the problem is.
But how do you normally deal with this situation? use a html/php for the
warning instead of alert message? or is there another way?
Thanks
iceking Guest
-
How To Supress Acrobat Error Message And Alert Message
Is there any way to supress those pop up message? If can't, is there any way to catch it? -
Error Message When Sending Message In Windows Mail
Am I the only one getting an error message when replying to a posted message using Windows Mail. Every time I send a message I get a popup error... -
warning message (alert)
Hi, I want to create the alert message ' You are about to over writte the acct, do you wish to continue?'). I need two buttons here, YES/ NO. If... -
Regarding to alert message
Hi If our text contains only characters but wrongly we add the number so alert message will come. In that we want only to remove the number not... -
alert or message box?
I am not clear ... whether to use alert of JavaScript or messagebox of VBScript in ASP. But what I want is that when a user has some error I want... -
Alvaro G Vicario #2
Re: How to redirect after (header) after sending an alert message
*** iceking wrote/escribió (Thu, 16 Sep 2004 10:07:37 +0200):
There's no point in displaying info for the user at the same time you're> I have a php script that checks whether the user is allowed to perform an
> action. If he is not allowed; I display a warning; using the alert function.
> After clicking away this function, I want to redirect the user to the
> original page using the header function.
> However, I get the normal message " headers already sent"... I know what
> the problem is.
> But how do you normally deal with this situation? use a html/php for the
> warning instead of alert message? or is there another way?
redirecting the user out of the page where that info is.
Unless you have very specific needs I can't see a reason to avoid Really
Simple Solutions:
<p>Action not allowed</p>
<p><a href="<?=htmlspecialchars($previous_page)?>">Retur n</a></p>
(Is is necessary to crosspost?)
--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Alvaro G Vicario Guest
-
Daniel Tryba #3
Re: How to redirect after (header) after sending an alert message
"iceking" <iceking_e <nospam>@yahoo.com> wrote:
You are confused:> I have a php script that checks whether the user is allowed to perform an
> action. If he is not allowed; I display a warning; using the alert function.
> After clicking away this function, I want to redirect the user to the
> original page using the header function.
-the alert function is clientside javascript
-header is serverside php
These can't work together in the way you describe above since by the
time the alert gets to the client, the php script is long gone.
The solution you might be looking for is the javascript location.href
property...
--
Daniel Tryba
Daniel Tryba Guest
-
Good Man #4
Re: How to redirect after (header) after sending an alert message
"iceking" <iceking_e<nospam>@yahoo.com> wrote in
news:41494a1f$0$48933$e4fe514c@news.xs4all.nl:
i have built this php function which does exactly what you want - create> Hi,
> I have a php script that checks whether the user is allowed to perform
> an action. If he is not allowed; I display a warning; using the alert
> function. After clicking away this function, I want to redirect the
> user to the original page using the header function.
> However, I get the normal message " headers already sent"... I know
> what the problem is.
> But how do you normally deal with this situation? use a html/php for
> the warning instead of alert message? or is there another way?
a javascript warning, and direct them to a new page when they click 'ok':
<?php
function popup($vMsg,$vDestination) {
echo("<html>\n");
echo("<head>\n");
echo("<title>System Message</title>\n");
echo("<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=iso-8859-1\">\n");
echo("<script language=\"JavaScript\" type=\"text/JavaScript\">\n");
echo("alert('$vMsg');\n");
echo("window.location = ('$vDestination');\n");
echo("</script>\n");
echo("</head>\n");
echo("<body>\n");
echo("</body>\n");
echo("</html>\n");
exit;
}
?>
So, you call it like this:
<?php
//they made an error
popup('Hey, you made a mistake, jackass.','retry.php');
?>
Good Man Guest
-
Rainmaker #5
Re: How to redirect after (header) after sending an alert message
iceking <iceking_e wrote:
Although it has no real use to send headers after your output, as> Hi,
> I have a php script that checks whether the user is allowed to perform an
> action. If he is not allowed; I display a warning; using the alert function.
> After clicking away this function, I want to redirect the user to the
> original page using the header function.
> However, I get the normal message " headers already sent"... I know what
> the problem is.
> But how do you normally deal with this situation? use a html/php for the
> warning instead of alert message? or is there another way?
>
>
> Thanks
>
>
mentioned in the other posts, you can use
[url]http://nl2.php.net/manual/en/function.ob-start.php[/url] ob_start if you
really want to. Dirty solution btw. Better not use it.
Rainmaker Guest
-
Charles Pelkey #6
Re: How to redirect after (header) after sending an alert message
If using a javascript ALERT, try using a javascript redirection... ie:
top.location.href= "url";
-Charles
"Rainmaker" <Rainmaker526NO@SPAMhotmail.com> wrote in message
news:7Jy3d.104657$C7.79323@amsnews05.chello.com...an> iceking <iceking_e wrote:> > Hi,
> > I have a php script that checks whether the user is allowed to performfunction.> > action. If he is not allowed; I display a warning; using the alertwhat> > After clicking away this function, I want to redirect the user to the
> > original page using the header function.
> > However, I get the normal message " headers already sent"... I know>> > the problem is.
> > But how do you normally deal with this situation? use a html/php for the
> > warning instead of alert message? or is there another way?
> >
> >
> > Thanks
> >
> >
> Although it has no real use to send headers after your output, as
> mentioned in the other posts, you can use
> [url]http://nl2.php.net/manual/en/function.ob-start.php[/url] ob_start if you
> really want to. Dirty solution btw. Better not use it.
>
Charles Pelkey Guest
-
Unregistered #7
How to redirect after (header) after sending an alert message
"iceking" <iceking_e<nospam>@yahoo.com> wrote in
news:41494a1f$0$48933$e4fe514c@news.xs4all.nl:
I have built this php function which does exactly what you want - create
a javascript warning, and direct them to a new page when they click 'ok':
<?php
function popup($vMsg,$vDestination) {
echo("<html>\n");
echo("<head>\n");
echo("<title>System Message</title>\n");
echo("<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=iso-8859-1\">\n");
echo("<script language=\"JavaScript\" type=\"text/JavaScript\">\n");
echo("alert('$vMsg');\n");
echo("window.location = ('$vDestination');\n");
echo("</script>\n");
echo("</head>\n");
echo("<body>\n");
echo("</body>\n");
echo("</html>\n");
exit;
}
?>
So, you call it like this:
<?php
//they made an error
popup('Hey, you made a mistake, jackass.','retry.php');
?>[/QUOTE]
Thanks,exactly what I also needed :)Unregistered Guest
-
Unregistered #8
Re: How to redirect after (header) after sending an alert message
Thanks a lot your script helped me a lot!!!
Unregistered Guest



Reply With Quote

