We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Handling Form Submission Errors - Best Practice

Development and Programming

Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

Hey guys,

What is the best practice for handling form submission errors?

I know there is the old purple screen of death 😊, but is there a way to pass the errors back to the original page?

Cheers

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Hi Leevi,

Try looking at Live Validation. Using this will stop you from ever seeing the purple screen of death!! 😊

Hope that helps.

Best wishes,

Mark

P.S. Alternatively you could change the CSS so that you get a nice pink screen of death!! 😊 😊
       
Brian M.'s avatar
Brian M.
529 posts
17 years ago
Brian M.'s avatar Brian M.

Javascript validation can be great as long as you aren’t relying on that as your only line of defense. In the end you have to validate twice using javascript…

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

Hey guys,

I will be using some javascript validation on my form but like Brian said it shouldn’t be the only line of defense. I think if I use Javascript first which will be a fair chunk of users and then back it up with a pink/purple screen of death for others.

So on a more technical level which method call brings up the purple screen of death?

Cheers

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen
So on a more technical level which method call brings up the purple screen of death?

Hi Leevi,

Well at this point I will gracefully bow out I’m afraid. I’m not too sure what calls that screen but I’m sure that one of the clever bods in here will do though. Sorry I couldn’t help further but my coding knowledge is a bit limited at this stage I’m afraid.

That said Live Validation really is one of the simplest Javascript validation routines out there as even I can use it!!

Hope it all goes well for you.

Best wishes,

Mark

       
Jamie Poitra's avatar
Jamie Poitra
409 posts
17 years ago
Jamie Poitra's avatar Jamie Poitra
So on a more technical level which method call brings up the purple screen of death?

What do you mean by the purple screen of death?

Jamie

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

@Jamie: It was just a toung in cheek remark about the default error message page that EE renders when you use the $OUT-> methods.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

I think Leevi means the standard EE template that appears when you haven’t filled out a form correctly or completely. Purple as it is the standard EE install CSS. With Live Validation this would not be a problem as the user wouldn’t be able to submit the form until everything is filled out correctly but I think (if my understanding is correct) that Leevi is also worried in case people have Javascript turned off then Live Validation isn’t going to be of much use.

Best wishes,

Mark

       
Jamie Poitra's avatar
Jamie Poitra
409 posts
17 years ago
Jamie Poitra's avatar Jamie Poitra

Leevi

Thought that might be what you meant but wanted to be sure before I opened my mouth.

You obviously know how to call it. And calling it due to a form validation error that is due to user input is obviously a valid usage for the Output error functions.

You can certainly combine a live validation technique with validation on the PHP end. And that is probably the best way to handle it if you want to do both you simply need to make sure that the live validation doesn’t prevent the form from being submitted normally when javascript is inactive. Most javascript libraries provide for that kind of functionality by default now (jQuery certainly does).

It would not be advisable to not provide PHP validation on a form. You don’t want there to be a way for badly formed data to make it through if javascript isn’t active or if something stops it from running as expected.

Jamie

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

I cannot echo Jamie’s advice strongly enough. Javascript validation is to benefit your user, making a pleasant and friendly experience using your form. Server side validation is necessary for security and validity of data. Some of the more common security holes in web applications these days are caused by programmers expecting that there is only one way for data to be sent to their application: from a page and form that they designed and intended for that purpose. And that could not be more far from the truth.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.