Jump to content

Creating a URL based on Form data


benyates1
Go to solution Solved by gristoi,

Recommended Posts

I have a multi-step form that offers different options of membership to users with the e-mail domain 'vip.co.uk' I finally have it working but have hit a wall with pulling the variables together to form an URL that can be submitted to the payment gateway in the final step.

 

The variables I need to pass are username, password, email, subscription id (a value attached to a radio button in step 2 - not yet built it).

 

I have a JS fiddle at http://jsfiddle.net/zsasvoo4/15/.

 

The final form will be in PHP and I'd prefer to use that language.

Link to comment
Share on other sites

  • Solution

I would say you shouldnt bother submitting it directly in php. use ajax in the

$(".submit").click(function(){

$.ajax({
   type:'POST',
   data: $('#joinform').serialize(),
  url: 'url to your backend php script / controller''
});

}) 

 

then in the backend just pull out the form vars

$username = $_POST['username'];
$pass = $_POST['pass'];

//do your data santizing .....

//build a string and sent using curl / guzzle / http client

$url = 'http://gatewayaddress?username='.$username.'&password='.$pass ........ etc
Link to comment
Share on other sites

 

I would say you shouldnt bother submitting it directly in php. use ajax in the

$(".submit").click(function(){

$.ajax({
   type:'POST',
   data: $('#joinform').serialize(),
  url: 'url to your backend php script / controller''
});

}) 

 

then in the backend just pull out the form vars

$username = $_POST['username'];
$pass = $_POST['pass'];

//do your data santizing .....

//build a string and sent using curl / guzzle / http client

$url = 'http://gatewayaddress?username='.$username.'&password='.$pass ........ etc

 

Thanks for the response, its the building of the string I guess taht i'm having trouble with. I should have been clearer - I'm familiar with PHP variables and passing them in URLs. It's the taking of form fields and making them usable as parameters in an URL.

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.