kinaski Posted June 16, 2009 Share Posted June 16, 2009 Hi all, I would appreciate some help considering my php form validation script. The code goes like this: if (isset($_POST['Submit'])) { $validator = new FormValidator(); $validator->addValidation("first_name","req","Please fill in Name"); $validator->addValidation("email","email","The input for Email should be a valid email value"); if($validator->ValidateForm()) { echo "<h2>Validation Success!</h2>"; $show_form=false; } else { echo "<B>Please fix folowing errors in the form:</B>"; $error_hash = $validator->GetErrors(); foreach($error_hash as $inpname => $inp_err) { echo "<p class=\"form_phperror\">$inpname : $inp_err</p>\n"; } } } <form name="test-form" id="test-form" action="http://other-server.com/submited-form.php" method="POST"> <div> <label for="first_name">Contact Person - First Name <span class="req">*</span></label> <input id="first_name" class="textfield required" maxlength="40" name="first_name" size="20" type="text" title="Please enter your first name." /> </div> <div> <label for="email">Email <span class="req">*</span></label> <input id="email" class="textfield required email" maxlength="80" name="email" size="20" type="text" title="Please enter your valid email address." /> </div> </form> By the way I'm using http://www.html-form-guide.com/php-form/php-form-validation.html for the validation part. What I'm not sure how to achieve is to stop the form from submitting before validation process finishes and is successful . Now it immediately goes to the form action page http://other-server.com/submited-form.php not validating the script. I want this to be a completely php server validation if possible, and not client javascript one. The thing that I need this functionality is that I'm submitting a form into an external server (a CRM system) and I dont ave an access there, to modify the receiving script. Thank you! Quote Link to comment Share on other sites More sharing options...
haku Posted June 16, 2009 Share Posted June 16, 2009 I'm guessing that the processing page is expecting posted values - as a result, this isn't really possible. You can validate, or you can post the info to the next page, but you can't validate then post the info to the next page. You can send data to the next page, either in a cookie, or in the URL, but if the processing page isn't set up to deal with that info, then you are out of luck. Quote Link to comment Share on other sites More sharing options...
kinaski Posted June 16, 2009 Author Share Posted June 16, 2009 I'm guessing that the processing page is expecting posted values - as a result, this isn't really possible. You can validate, or you can post the info to the next page, but you can't validate then post the info to the next page. You can send data to the next page, either in a cookie, or in the URL, but if the processing page isn't set up to deal with that info, then you are out of luck. Thanks, I was actually afraid of that ... But I hoped there was a solution... Quote Link to comment 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.