This is a discussion on "PHP Email with Javascript validation" within the PHP Forum section. This forum, and the thread "PHP Email with Javascript validation are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
PHP Email with Javascript validation
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
PHP Email with Javascript validation
I have a form validated by javascript with a php script to send an e-mail.
Right now though it will bypass my validation and send the e-mail. My Question: Can I validate a form with javascript then execute a php script? Let me know what code you would like to see. |
|
|
|
|||
|
Re: PHP Email with Javascript validation
ALWAYS validate with both JavaScript and at the server with PHP incase JavaScript is turned off.
Your form needs an onsubmit() function to do a JavaScript validation. Only if that passes will the form be submitted for PHP processing where it is validated again. You need to have what is known as 'sticky data' in your form fields so that if the PHP validation fails, the form is redisplayed to the user with the data previously emtered intact. |
|
|||
|
Re: PHP Email with Javascript validation
this is what I have and it is not working :
|
|
|||
|
Re: PHP Email with Javascript validation
Does using 'GET' or 'POST' matter?
|
|
|||
|
Re: PHP Email with Javascript validation
GET data is passed as part of the URL so can be seen in the browsers address bar.
POST data is passed 'unseen' to be processed and is generally considered the more secure option. I would always recommend sending form data using POST. |
![]() |
| Tags |
| javascript validation php |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] javascript from validation | eon201 | JavaScript Forum | 2 | Oct 24th, 2007 17:41 |
| Help with email validation | dbh_21 | Flash & Multimedia Forum | 0 | Aug 17th, 2007 10:29 |
| javascript and xhtml validation | nate2099 | JavaScript Forum | 9 | May 1st, 2007 22:34 |
| date, email and number or character validation | ntgcmlfu | Classic ASP | 5 | Jul 30th, 2006 15:32 |
| Email Address Validation | Smokie | Classic ASP | 1 | Aug 15th, 2003 23:52 |