Forum Moderators: coopster

Message Too Old, No Replies

Page displays error message Wrongly

help fixing simple problem

         

djtwo

2:30 am on May 27, 2006 (gmt 0)

10+ Year Member



Hi again,

alright my signup forms fuctionability is working as needed BUT, ackwardly a PHP function message error displays before the script is even sent to execute (via submit button), on the top of the page (where the php error message would normally appear if data was missing or incorrect). In PHP it states the error message which the following code would display, I dont get any ERROR messages from the actual script:

The code that displays the Error Message is:

-------------------
if (!ereg("^[0-9]{5,5}(\-[0-9]{4,4})?$",$zip)) #88
{
unset($_GET['do']);
$message_new = "$zip is not a valid zip code.
Please try again.";
include('login_form.php');
exit();
}
----------------------------

I hope my problem question makes sense. I could send you a link of the full code or demo of the form page where the error message displays, but I am not allowed to post URL's in the forums.

To simiplify, "This Message error appears and looks annoying and inprofessional (you know, since the error appears above the form, before the customer even feels out any info and clicks submit).

Is there any reason from what you can see with the code above as to why this error message appears beforehand?

Please feel free to ask me any question if it don't make sense. Thanks ahead of time for your help and time. Have a good night and wonderful weekend.

Regards,
Djtwo

eelixduppy

3:22 am on May 27, 2006 (gmt 0)



Are you sure its an error and not a notice or warning. To turn off these, use error_reporting(0); at the top of the script.

djtwo

3:57 am on May 27, 2006 (gmt 0)

10+ Year Member



Thanks for replying eelixduppy, it is not ERROR, it is the message error that I programmed it to make. Just imagine, a login form on a page that you go to for the first time during a view session of a website, BUT above the login form "where my PHP script will display if there was an error in one of the fields" the error read "Password and Login combination is not valide, please try again".

Well that is what is happening to my form, except it says "Invalid Zip code".

If you want I can PM or IM you the link to a demo site so you can see what I mean?

Thanks! Have a good night.

eelixduppy

4:20 am on May 27, 2006 (gmt 0)



I'm sorry; I read your post too fast. You are going to have to check the included file for how you echo $message_new because i don't see any reason why it would echo before the table, considering that i cannot see the code for the table. If you want, post some of the code of the included file where the error message is printed out, then i will be able to further help you. And have a good weekend yourself :)

grandpa

4:21 am on May 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It looks more like a logic error, and not a code error, to me.

What is the purpose for your code snippet? I know you're testing for a valid zip code, but is this supposed to be part of a validation routine when the form is submitted?

dreamcatcher

6:57 am on May 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it because you aren`t checking the state of the variable?

Try changing:

if (!ereg("^[0-9]{5,5}(\-[0-9]{4,4})?$",$zip))

to:

if (isset($zip) &&!ereg("^[0-9]{5,5}(\-[0-9]{4,4})?$",$zip))

dc

djtwo

5:58 pm on May 27, 2006 (gmt 0)

10+ Year Member



Thanks for the Help everyone! Dreamcatcher, I tried your advice, and it took the error away but now when a customer goes to the page it automatically forwards them to the "New Member page" I am going to put that piece of code back as it was, and look for another solution.

I hope you all don't mind but I have sent a link so you can look at the source code via Sticky Email. Thanks for all your help.

And as to your question Grandpa, Yes, the Error message should ONLY display after the Submit button is pressed and ONLY if there is actually an error.

Thanks you for your time, help and advice.

Regards,
Djtwo