spinner0205 Posted September 8, 2011 Share Posted September 8, 2011 I needed a server side PHP validation script for my form to use on top of client side Javascript as a backup. I found a nice package where I just include the validator and set a few options then it does the rest. However it doesn't seem to work with the action="whateveraction.php" for the form. It will skip all the validation and immediately go to the action script. So I left that blank as you can see in the form below and figured I would send the post data somehow to the script using PHP when the validation is successful. However I am stumped on how to do that can I get some coding help? This is the small validation script. I will attach the formvalidator.php in this post. <?php require_once "formvalidator.php"; if(isset($_POST['submit'])) { $validator = new FormValidator(); $validator->addValidation("age","req","Please fill in your Age"); $validator->addValidation("mcid","req","Please fill in your Minecraft Username"); $validator->addValidation("description","req","Please fill in a Description"); if($validator->ValidateForm()) { //need something here to have it send the post data to /mcbuildapp/form_submit.php } else { echo "<div class=blockrow><b><font size=5>Form Errors:</font><b></div>"; $error_hash = $validator->GetErrors(); foreach($error_hash as $inpname => $inp_err) { echo "<div class=blockrow><p><font color=red>$inp_err</font></p>\n</div>"; } } } Then the form if it matters.... <div class="blockrow"> <font size=4><b>Minecraft Building Rights Application</b></font> <br /> <br /> <b>Failing to fill in any of these fields sufficiently will result in an automatic denial of your application!</b><br /> <b>Think of it this way, being lazy and applying wrong is only wasting your time. Take the time to do it correctly the first time.</b> <br /> <br /> <b><font color=red>To ensure proper user authentication and security you must first join the server at least once before applying for your building rights to work!</font></b> <br /> <br /> <form action="" id="mcbuilderapp" name="mcbuilderapp" method="post"> <label><b>Your Minecraft Username (required)</b><br /> Use exact capitalization and punctuation that matches your Minecraft.net account!</label> <br /> <br /> <input type="text" name="mcid" id="mcid" maxlength="25"/> <br /> <br /> <label><b>Your Age (required)</b></label> <br /> <br /> <input type="text" name="age" id="age" maxlength="3"/> <br /> <br /> <label><b>Describe Yourself (required)</b><br /> Describe yourself in <b>no less</b> than 3 sentences using <b>correct grammar</b>.</label> <br /> <br /> <textarea name="description" id="description" minlength="10" maxlength="1000" cols=60 rows=5 wrap="physical"> </textarea> <br /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </div> MOD EDIT: PHP manual tags changed to code tags . . . [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/246747-send-post-form-data-through-php/ Share on other sites More sharing options...
jcbones Posted September 8, 2011 Share Posted September 8, 2011 //need something here to have it send the post data to /mcbuildapp/form_submit.php //add this line: include('mcbuildapp/form_submit.php'); Quote Link to comment https://forums.phpfreaks.com/topic/246747-send-post-form-data-through-php/#findComment-1267184 Share on other sites More sharing options...
xyph Posted September 8, 2011 Share Posted September 8, 2011 You need to move the validation code chunk to the page the processes the data. Otherwise, you're going to need to use sessions to store the variables temporarily, which is completely redundant. Move the FormValidator(); stuff to the page that does the processing, then in the processing page, if everything goes alright, use a header('Location: http://yoursite.com/success.php') to redirect them to a success page, otherwise redirect them back to the form page. There's no need to pass the errors back, because the only way they'll get here is if they're trying to bypass your JavaScript checks, in which case we don't need to tell them what's going wrong. If you want to do that anyways, you could use a bitwise method of returning your errors, and on your form page, translate them. Quote Link to comment https://forums.phpfreaks.com/topic/246747-send-post-form-data-through-php/#findComment-1267189 Share on other sites More sharing options...
spinner0205 Posted September 8, 2011 Author Share Posted September 8, 2011 Actually jcbones had it right on the money. Never thought about just including the file. Duh. Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/246747-send-post-form-data-through-php/#findComment-1267193 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.