[RESOLVED] Concatenating a URL and redirecting to this
Results 1 to 5 of 5

Thread: [RESOLVED] Concatenating a URL and redirecting to this

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    5

    resolved [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).

    Tony Hills

  2. #2
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,413
    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?

  3. #3
    Junior Member
    Join Date
    Jul 2014
    Posts
    5
    Quote Originally Posted by bradgrafelman View Post
    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?
    Hi

    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
    Code:
    ?Tobacco=N&Age=65&Premium=56&ref_code=CB255RF1&Title=Mr&FName=Fred&SName=Flintstone&Gender=M&Charity=RSPCA&LogoURL=http://www.rspca.org.uk/ptl2014DefaultTheme/images/rspca/rspca.gif&Address1=Charity%20Line%201&Address2=Charity%20Line%202&Address3=Charity%20Line%203&Town=Harrogate&County=North%20Yorkshire&Country=United%20Kingdom&Postcode=HG28ND&Percent=5
    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.

    Tony
    Last edited by bradgrafelman; 08-27-2014 at 06:43 PM. Reason: bbcode tags modified

  4. #4
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,413
    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.

  5. #5
    Junior Member
    Join Date
    Jul 2014
    Posts
    5
    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.

    Tony

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •