Jump to content

Validate form, add data, POST to url


johnstamos

Recommended Posts

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.

 

Link to comment
Share on other sites

// 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 by bsmither
Link to comment
Share on other sites

// 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!

  1. Create a form on your website.

  2. 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.

  3. 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.

  4. 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_idssl_user_id, andssl_pin in hidden fields on the website.

  5. Set the transaction type you wish to perform ssl_transaction_type to ccsale to perform a sale or ccauthonly for an authorization.

  6. 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.

  7. Set the value of the ssl_amount so that it is unable to be changed on the payment form (unless you are accepting donations).

  8. Add a Submit button on your website. 

 

This dev guide has been a real struggle https://www.myvirtualmerchant.com/VirtualMerchant/download/developerGuide.pdf

Edited by johnstamos
Link to comment
Share on other sites

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 by johnstamos
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.