Westboarder Posted August 5, 2007 Share Posted August 5, 2007 I have an html form that submits to a page on an external site. It basically submits an e-mail field. I want to create a conditional statement, where if the e-mail field is empty, the page does not submit. If the field is populated, it refers the user to a page on my site. Is it possible to do this without modifying the code to which the page submits to? Can I catch the variable before the form "submits", and still submit the data? Quote Link to comment https://forums.phpfreaks.com/topic/63422-conditional-form-submission/ Share on other sites More sharing options...
AndyB Posted August 5, 2007 Share Posted August 5, 2007 You'll need a client-side (javascript) test to verify that the email field is populated before submission. Quote Link to comment https://forums.phpfreaks.com/topic/63422-conditional-form-submission/#findComment-316075 Share on other sites More sharing options...
Fadion Posted August 5, 2007 Share Posted August 5, 2007 As previosly said ull need client side validation, which needs some basic knowledge of javascript. U may consider server side validation which will need the form to submit, but this may not be your case. Quote Link to comment https://forums.phpfreaks.com/topic/63422-conditional-form-submission/#findComment-316087 Share on other sites More sharing options...
Westboarder Posted August 5, 2007 Author Share Posted August 5, 2007 my only issue with that is, I need to have the form submit still, and also refer the user to a page on my end. Quote Link to comment https://forums.phpfreaks.com/topic/63422-conditional-form-submission/#findComment-316090 Share on other sites More sharing options...
Westboarder Posted August 5, 2007 Author Share Posted August 5, 2007 can anyone provide me with code samples how you accomplish this in php? Quote Link to comment https://forums.phpfreaks.com/topic/63422-conditional-form-submission/#findComment-316164 Share on other sites More sharing options...
yarnold Posted August 5, 2007 Share Posted August 5, 2007 if(strlen($_POST['email'] > 0)) { // Process form information } else { // The length of the email field was zero, hence an e-mail address was not entered. } Quote Link to comment https://forums.phpfreaks.com/topic/63422-conditional-form-submission/#findComment-316194 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.