[RESOLVED] Concatenating a URL and redirecting to this
Any help with the following coding issue will be greatly appreciated.
Current position: I have a page (mypage1.php) on which is a form where there are a number of text areas for the viewer to complete. For this example we will say just two – for age (name=age) and premium (name=premium). There is a ‘submit’ button which takes the viewer to the next page by calling the form action function. This new page is mypage2.php.
However, in the future I now have to pass this information to an insurance company and they can only accept the data by including it in their URL.
Here’s the problem I am unable to solve due to my limited knowledge of PHP.
If I put the URL of the insurer in place of the original form action ‘mypage2.php’ it is too early to include the answers to the two questions.
I have spent a lot of time trying to find various sequences to get a solution and failed.
As I understand it I first need to concatenate the answers to $age and $premium with the insurer’s URL. But what order do I use to get the viewer to press the submit button only once? Where do I place the concatenation (within the form or after, before the submit button or after etc)?
Then I need to redirect the page to this concenated URL – but only on the action of the submit button – not when the viewer accesses ‘mypage1.php’.
Do I concatenate the insurer URL which then goes to an intermediate page which is redirected to the extended URL. If so, where do I place the concatenation (within the form or after)?
Or do I create an intermediate page which accepts the answers to $age and $premium, then concatenates the URL and then redirects to this extended URL?
As I say, any help would be much appreciated (particularly some sample coding).
You keep mentioning concatenation, but I don't think you've ever clarified what the pieces are. Concatenation is simply joining string pieces together to form a single string, after all.
Can you give us an example of what the resulting URL should look like for this external website?
Originally Posted by bradgrafelman
Thanks for your response. The insurer URL is for a landing page dedicated to the product I am offering and requires the viewer's information together with other data concerning a charity associated with the viewer.
The basic URL is https://secure.insurancecompany.com/...ol-landing.asp
The data which follows each ‘=’ is concatenated from the returns of each variable on the form entered in the text areas or variables already on the page.
As I say, the real issue is how and where I code the creation of this full URL and then use this to transfer the viewer to this URL. At the moment, the submit button takes the viewer to the current ‘mypage2.php’ rather than this data rich URL.
Last edited by bradgrafelman; 08-27-2014 at 07:43 PM.
Reason: bbcode tags modified
Unless I'm missing something... it sounds like you just need to set the 'method' attribute of the <form> element to 'get' and the browser will create that URL for you.
You are a genius! Such a simple solution compared to the complexity I was getting involved in. Thanks. The insurance company has accepted the URL so problem solved.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)