Jump to content

[SOLVED] redirecting echo messages


tqla

Recommended Posts

I know why Headers Already Sent errors occur and I have put my processing at the top of the page to avoid this. However, the processing includes echo messages that will show if certain fields are not filled in or incorrect like this:

	      } else {
        echo "<font color=\"#FF0000\">The Promotional code that you have entered does not exists or has already been
                 redeemed.</FONT><BR><BR>";
      }

 

The problem is these messages get echo'd at the top of the page and under a header graphic.

 

Is there a way to take the echo message and move them lower on the page? Like maybe have the echo kick in an error message that's just above the form?

Link to comment
Share on other sites

So basically what your saying is that at the top of your script, you are checking for errors - which if there are any you want to echo the result. Further down, you also might redirect someone(presumably if there are no errors?)

 

If so, i would store the error text in a variable, and perhaps set another variable, $errors for example to the value yes:

else {
        $error_text .= "<font color=\"#FF0000\">The Promotional code that you have entered does not exists or has already been
                redeemed.</FONT><BR><BR>";
$errors = 'yes';
      }

 

Then, wherever you would want to show these errors, you would use:

<?php
if($errors =='yes'){
echo $error_text;
}
?>

 

Meh, beaten to it - ill post anyway since ive typed out the example.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.