Jump to content

Form Submission


billybob8

Recommended Posts

Hi everyone, cheers for reading.

 

I am creating a card processing system;

 

1/  User completes a form on my site/server (signup.php)

2/  Javascript validation

3/  The PHP script validates the inputs and merges them into $_SESSION for storage

4/  The url is redirected to another page on the server (start_payment.php), they select the currency here and submit this form which has a post action to a script not on my server

5/  User is taken to the page on the payment processors server

 

 

-----------------------

 

Now this is a working signup process, but its not very slick, what I would like to do is:

 

user completes a form on my server (signup.php)

javascript validation

php validation

a little php maths work

 

then I would like all the form variables sent to the script not hosted on my server, I dont want to have to have the start_payment.php page to exist, i just want one form, which validates then sends data to another URL as if it were a form action...  Then people would only need to be on one page on my site!

 

 

Does that make sense?  If someone could point me in the right direction that would be great - and please note the information passed is going to need to be sent to a HTTPS link

 

the current form method on start_payment.php is similar to <form action="https://example.domain.com/start" method="post">

 

 

Link to comment
https://forums.phpfreaks.com/topic/97953-form-submission/
Share on other sites

I have tried this out

 

if ($valid) {

 

// if these details work, go to the next page

//header ('Location: payment_start.php');

$url  = "https://example.domain.com/payment";

$data = "wah=bob&test=yes";

$ch = curl_init();    // initialize curl handle

curl_setopt($ch, CURLOPT_URL,$url); // set url to post to

curl_setopt($ch, CURLOPT_FAILONERROR, 1);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable

curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s

curl_setopt($ch, CURLOPT_POST, 1); // set POST method

curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // add POST fields

$result = curl_exec($ch); // run the whole process

curl_close($ch); 

echo $result;

exit();

}

 

This does seem to work, but the URL it sends you to "https://example.domain.com/payment" which is hosted on another server isnt quite right, any ideas how I can improve this code?

 

 

The problem seems to be the page is still signup.php rather than the URL specified in $url is my method wrong? Is there a better way?

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/97953-form-submission/#findComment-501341
Share on other sites

The problem seems to be the page is still signup.php rather than the URL specified in $url

That's right yes. I really don't know if this page on the other server is that strict that it doesn't work properly. The only other way you could do is an autosubmitting form with hiddenfields, only then changes the url and the method is POST. The problem is that you can't do a POST request with header("Location: ...

Link to comment
https://forums.phpfreaks.com/topic/97953-form-submission/#findComment-501357
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.