close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Server validation not checking errors

Thread began 6/20/2016 2:20 pm by mrs | Last modified 2/28/2017 11:14 pm by Ray Borduin | 1364 views | 8 replies |

mrs

Server validation not checking errors

I've got a contact form on a page and the code I am checking validation with is on the same page as once it is validated, I want to enter the form contents into my DB, then email the contents of the form, however, the validation isn't working when I purposely make errors in data entry. I am checking email and captcha form fields.

I have got the validation code on the page being submitted (bike-enquiry.php) and I have left the 'Failed redirect' blank because the form and validation are on the same page.

I have two Validation show ifs (one for email, one for captcha) and the validation page is set as bike-enquiry.php.

My form action is set to bike-enquiry-thanks.php with a method of post and an id of enquiry.

I don't know why it's not working with this all on the one page!

What am I missing? I've attached the page in question for you to check for errors if you need to.

Thanks.

Attached Files
bike-enquiry.php
Sign in to reply to this post

Ray BorduinWebAssist

The server validation has to be on the page specified as the action of the form. Try cutting and pasting the validation code to that page and add a redirect in the server validation back to the form page.

Sign in to reply to this post
Did this help? Tips are appreciated...

mrs

Sorry Ray, I don't fully understand what you're saying there. What am I cutting and where am I pasting it?

Are you saying validate on the thanks page and then redirect back if there are errors? If so, wouldn't the page with the form on it insert into the database and trigger emails to send (once I've added that code) even if there were errors because it is a page before and separate to the thanks page with the validation code?

Sign in to reply to this post

mrs

Hi Ray, I have added the validation code to the thanks page, but I am now getting errors in the process of what I am trying to achieve.

WITH THIS THE FORM VALIDATES BUT RECORD INSERT NOT WORKING WITH THIS LINE OF CODE
<form action="bike-enquiry-thanks.php?id=<?php echo($rs_bike->getColumnVal("fld_bid")); ?>" method="post" id="enquiry" name="enquiry">-->

WITH THIS THE FORM WON'T VALIDATE BUT RECORD WILL INSERT WITH THIS LINE OF CODE
<form action="<?php echo (htmlentities($_SERVER["PHP_SELF"], ENT_QUOTES)); ?>" method="post" id="enquiry" name="enquiry">

I was hoping to add all the code to one page (bike-enquiry.php) so it would be easier to troubleshoot rather than have to do it across several pages. I am still to add in code for sending emails yet. By having code on two separate pages seems to kill off one or the other processes.

I assume I need to do it in this order:
1. Validate form entries
2. Enter form contents onto DB
3. Trigger email of form contents

However, by having the validation on a subsequent page seems to be breaking that process, so how do I ensure that all processes are on one page in a sequential order?

Why is my validation on the page with the form not working? Why do I need to move it to the thanks page as this seems to be the crux of the problem? And if I need to move validation to the subsequent page, how do I then do the insert and send email?

Thanks.

Attached Files
bike-enquiry-thanks.php
bike-enquiry.php
Sign in to reply to this post

Ray BorduinWebAssist

Move the validation back to the bike-enquiry.php page... change the form action to just action="" and that will automatically post the form to itself.

Apply the send email message server behavior to the bike-enquiry.php page as well.

Remove the redirect from the insert record server behavior and add it to the email so that the redirect only takes place after both have run (make sure the email code is lower than the insert code on the page).

Sign in to reply to this post
Did this help? Tips are appreciated...

mrs

Thanks for that Ray, it was the form action that was causing all the issues, so thanks for highlighting it. Everything is working as I need it now.

Sign in to reply to this post

stephen287384

I am having a similar issue, validations are not showing, just get "please fill out this field" on each of the fields not the actual validation message. What am I missing here?

Sign in to reply to this post

Ray BorduinWebAssist

That is because you have the "required" attribute on the form itself. That will cause the browser to use html5 validation on the field before it is submitted. If you remove that from each <input> tag it will not validate in the browser and your server validation will pick it up instead.

If you use the webassist jquery html5 validation you can use custom validation messages and styles with the client validation as well.

Sign in to reply to this post
Did this help? Tips are appreciated...

stephen287384

Thanks Ray, that was the issue.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...