johnstamos Posted April 22, 2014 Share Posted April 22, 2014 Hello everyone, I'm been racking my brain for far too long, and I need help. I'm just not as advanced in PHP yet to get this. Here is what I am trying to do: - A user submits a simple form from form.php - Form data is sent to validateform.php - Form data is validated - If there's an error: display the error to the user back on form.php, otherwise: - Include a few more bits of information (I'm not supposed to keep them as hidden fields on the form page) - Send it all to a process.do script on some other server It should be easy enough, but I can't wrap my head around it all yet. Here is roughly what I got, cleaned up and trimmed down to exclude all of the messy incorrect code I've been messing around with. // Code for form.php // <form action="validateform.php" method="post"> <input type="text" name="field1" placeholder="Field1 Data"> <input type="text" name="field2" placeholder="Field2 Data"> <input type="text" name="field3" placeholder="Field3 Data"> <input type="text" name="field4" placeholder="Field4 Data"> <input type="submit" value="Submit Form"> </form> // Code for validateform.php // $field1 = $_POST['field1']; $field2 = $_POST['field2']; $field3 = $_POST['field3']; $field4 = $_POST['field4']; // if/else validation script code goes here // // Somehow add in the following data // // It was orignaly in the form.php page as hidden text fields, but I've been told I'm not supposed to do that for secureity reasons) name="hiddendata1" value="Data" name="hiddendata2" value="Data" name="hiddendata2" value="Data" // Code that sends all the data to process.do // If you guys could give me any help on this I would really appreciate it. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/287951-validate-form-add-data-post-to-url/ Share on other sites More sharing options...
bsmither Posted April 22, 2014 Share Posted April 22, 2014 (edited) // Somehow add in the following data // $field5 = $hiddenDataValue1; How is process.do supposed to receive it? My experience suggests that to send data off to another place can be solved by using cURL. Edited April 22, 2014 by bsmither Quote Link to comment https://forums.phpfreaks.com/topic/287951-validate-form-add-data-post-to-url/#findComment-1477011 Share on other sites More sharing options...
johnstamos Posted April 23, 2014 Author Share Posted April 23, 2014 (edited) // Somehow add in the following data // $field5 = $hiddenDataValue1; How is process.do supposed to receive it? My experience suggests that to send data off to another place can be solved by using cURL. Hello! process.do was originally receiving the data by <form method="post" action="somewebsite.com/whatever.process.do" and the data is key/value pairs. I'm setting up a simple credit card payment form and sending the data to a service called Virtual Merchant that will process the payment after I have collected the data, validated it, and sent it off to them. I would simply set the form action to that process.do url, but I first need to validate it and add in some info like virtual merchant account id and account pin and such. I will look into using cURL This should be a helpful bit of info for anyone who's taking the time to read this! Number 4 is where Im stuck kind of! Create a form on your website. Set the action of the form to a script on your server that will send a POST request to the process.do URL using cURL or an equivalent. Refer to the URLS section to set your URL for either the demo or production environment. Collect as much or as little transactional data on the website as needed and pass the values through the POST to your servier-side script. Example: Pass an amount to your script, but allow the customer to fill out the VirtualMerchant hosted payment form with their contact and shipping information and credit card data. On the server-side script, collect the information from the POST request (typically using $_POST variables or an equivalent) and include the ssl_merchant_id, ssl_user_id, and ssl_pin. Note: Do not include your ssl_merchant_id, ssl_user_id, andssl_pin in hidden fields on the website. Set the transaction type you wish to perform ssl_transaction_type to ccsale to perform a sale or ccauthonly for an authorization. Call VirtualMerchant’s process.do through cURL or the equivalent and VirtualMerchant will return the source code for your payment form, or the response as indicated by the ssl_show_form value to the customer’s browser. Set the value of the ssl_amount so that it is unable to be changed on the payment form (unless you are accepting donations). Add a Submit button on your website. This dev guide has been a real struggle https://www.myvirtualmerchant.com/VirtualMerchant/download/developerGuide.pdf Edited April 23, 2014 by johnstamos Quote Link to comment https://forums.phpfreaks.com/topic/287951-validate-form-add-data-post-to-url/#findComment-1477094 Share on other sites More sharing options...
cyberRobot Posted April 23, 2014 Share Posted April 23, 2014 Is there any documentation available from Virtual Merchant which describes how the information should be sent? Quote Link to comment https://forums.phpfreaks.com/topic/287951-validate-form-add-data-post-to-url/#findComment-1477097 Share on other sites More sharing options...
johnstamos Posted April 23, 2014 Author Share Posted April 23, 2014 (edited) Is there any documentation available from Virtual Merchant which describes how the information should be sent? Oh yes, I just edited that in to my post there. And thank you so much for helping out! Edited April 23, 2014 by johnstamos Quote Link to comment https://forums.phpfreaks.com/topic/287951-validate-form-add-data-post-to-url/#findComment-1477099 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.