benyates1 Posted August 21, 2014 Share Posted August 21, 2014 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 https://forums.phpfreaks.com/topic/290568-creating-a-url-based-on-form-data/ Share on other sites More sharing options...
gristoi Posted August 21, 2014 Share Posted August 21, 2014 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 https://forums.phpfreaks.com/topic/290568-creating-a-url-based-on-form-data/#findComment-1488499 Share on other sites More sharing options...
benyates1 Posted August 21, 2014 Author Share Posted August 21, 2014 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 https://forums.phpfreaks.com/topic/290568-creating-a-url-based-on-form-data/#findComment-1488502 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.