Re: using meta http-equiv in php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a small function to redirect in cases where you cannot use header.

This is how I have used it.


 if (!headers_sent())
             {
                 header("Location: your url here");
                 exit;
             }
             else
                redirect("your url");


function redirect($filename) {
   if (!headers_sent())
       header('Location: '.$filename);
   else {
       echo '<script type="text/javascript">';
       echo 'window.location.href="'.$filename.'";';
       echo '</script>';
       echo '<noscript>';
       echo '<meta http-equiv="refresh" content="0;url='.$filename.'" />';
       echo '</noscript>';
   }
}

Hope this helps you.

Priya

----- Original Message ----
From: Krishna Srikanth <krishna.srikanth@xxxxxxx>
To: php-objects@xxxxxxxxxxxxxxx
Sent: Monday, March 10, 2008 12:17:34 PM
Subject: Re:  using meta http-equiv in php

Alternatively, you can provide a link to the thank you page in the 
redirecting page, if you think meta refresh is restricted.

one.php:
//form elements.. etc

two.php:
//db operations
<meta tag>
echo 'Details entered in database';
echo '<a href="thankyou. php">Click here if you are not redirected within 5 
seconds</a>' ;

thankyou.php
//your message.

Regards,
Manda Krishna Srikanth
http://www.krishnas rikanth.com

php-objects@ yahoogroups. com wrote on 03/09/2008 06:34:43 PM:

> 
> i have a registration page which is a self submitting form <form 
> action="<?php echo $_SERVER["PHP_ SELF"]; ?>" method="POST" 
> 
> id="test2" name="registrationf orm"> 
> 
> where in a user fill a form, after the data has been inserted to a 
> database i would like to redirect the user to a different 
> 
> page. i am not able to use header(Location: filename.html) as i have 
> echo statements before and i get a message that headers 
> 
> have already been sent. so due to this i am using 
> 
> echo (" <meta http-equiv=' refresh' content='0;url= thankyou. php?
> firstname=$firstnam e'> "); this works perfectly fine.
> 
> however if a user disables meta refresh which is a very small 
> possibility the above meta tag would not execute to avoid such 
> 
> a situation i would like to use echo statements to create a new page 
> which would have html tags and display a similar page to 
> 
> thankyou.php
> 
> in my case the php code is placed in the middle of the page which 
> displays messages that a user did not enter in the form.
> 
> the page is so structured that there is some information written 
> using html tags followed by the registration questions where 
> 
> the php code is present to validate. i have used 
> 
> echo (" <meta http-equiv=' refresh' content='0;url= thankyou. php?
> fname=$fname' > ");
> redirectingthepage( ); 
> exit;
> 
> i have used the above code so that even if the echo (" < ;meta http-
> equiv='refresh' content='0;url= thankyou. php?fname= $fname'> 
> 
> "); is not executed the redirectingthepage( ) function will be 
> executed.
> 
> my question is due to the structure of the page whatever text is 
> present before the form that text is appearing again 
> 
> followed by the text i have inside redirectingthepage( ) function, i 
> do not want this to happen. i would like what is written 
> 
> in redirectingthepage( ) function only to appear. i have defined 
> redirectingthepage( ) function in a separate file and i am 
> 
> calling the file which has redirectingthepage( ) function by using 
> include statement in the registration page.
> 
> please advice how i can display what is defined in redirectingthepage
&g t; () function ONLY if the refresh is disabled by the user
> 
> thanks.
=====-----== ===-----= ====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you

[Non-text portions of this message have been removed]






You are managing the php-objects group through Grouply.
You subscribe to individual emails for this group. | Update your Subscription settings
3 messages in this conversation, including this one | Add a comment
View this message on Grouply so you can rate, tag, bookmark, and see what others thi nk about it.Yahoo! Finance
It's Now Personal
Guides, news,
advice & more.
New web site?
Drive traffic now.
Get your business
on Yahoo! search.
Do-It-Yourselfers
on Yahoo! Groups
How-to ideas,
projects and more.


      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux