PHP Email with Javascript validation

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.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Dec 22nd, 2006, 17:08
Junior Member
Join Date: May 2006
Location: A Place Far Away
Age: 26
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Dec 22nd, 2006, 18:18
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Dec 22nd, 2006, 20:19
Junior Member
Join Date: May 2006
Location: A Place Far Away
Age: 26
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Email with Javascript validation

this is what I have and it is not working :
Code: Select all
<form name="AForm" runat="server" onsubmit="return VerifyForm(AForm)" method="get" enctype="text/html">
    &nbsp;
    <div id="MainForm" style="width: 552px; height: 384px; left: 0px; position: relative; top: -22px; text-align: center;">
   My Electronical Approval Request<br />
    For Invoice
    <br />
    See attachment for details<br />
<br />
<input visible=false name="subject" id="subject" value="Nothing" type="hidden" style="width: 32px"/>
<input id="Radio1" type="radio" name="WhatAction"/>
Approve Invoice<br />
<input id="Radio2" type="radio" name="WhatAction"/>
Decline Invoice<br />
<br />
Comments :<br />
<textarea id="TextArea1" name="body" style="width: 304px; height: 152px"></textarea><br />
<br />
<input id="Submit1" type="submit" value="submit" onclick="http://www.mysite.com/sendmymail.php" /><br />
    *After you click submit this will send an automatic response to here<br />
    *Any questions or comments reply to <a href="mailto:MyMail@somewhere.com?subject=My%20Electronic%20Approval">Our IT Department</a></div>
    &nbsp; &nbsp;
    <a href="mailto:MyMail@somewhere.com?subject=My%20Electronic%20Approval"></a>
</form>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Dec 22nd, 2006, 20:19
Junior Member
Join Date: May 2006
Location: A Place Far Away
Age: 26
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Email with Javascript validation

Does using 'GET' or 'POST' matter?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Dec 23rd, 2006, 13:34
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
javascript validation php

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 14:59.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42