FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


HomeWatched TopicsRegisterSearchDirectory
FAQMemberlistUsergroupsLog inStoresItemsBank
Google

Reply to topic Page 1 of 1
using meta http-equiv in php
Message  

Reply with quote
Post using meta http-equiv in php 
i have a registration page which is a se;f submitting form <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST"

id="test2" name="registrationform">

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=$firstname'> "); 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() function ONLY if the refresh is disabled by the user

thanks.

View user's profile Send private message

Reply with quote
Post validate and redirect before echoing anything... 
A good practice for form validations would be to run the validations before displaying the form or any echo statements.

<?php

if (isset($_POST)) {

     // only if post has been set run the validations:
     // validation code would go here. example:

     if (!empty($_POST['somevalue'])) {
          $value = TRUE;
     } else {
          $errorArray[] = "This value wasn't submitted properly";
          $value = FALSE;
     }

     // once the validations are done, check all of the values in case some failed.

     if ($value1 && $value2 && $value3) {
          // everything passed, redirect the user!
          header(Location: thankyou.php);
          exit(); // call this to kill the script at this point
     } else {
          // there were some errors, loop through the $errorsArray to display the errors.
          foreach ($errorArray as $errorValue) {
               echo "$errorValue <br />";
          }
     }

}

// now display the form, since the script made it this far, $_POST hasn't been set yet.

?>

<!-- HTML AND FORM GOES HERE -->


_________________
somewhere a clock is ticking...
View user's profile Send private message Visit poster's website
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  



Google

FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


Web Design by PlatinumShore.com & Web Hosting by TradeWebHosting.com