Question

I have created a simple checkout form for use with a mobile website:

<form action="" method="GET">
        First Name:<br />
        <input type="text" name="firstname" />
        <br /><hr />
        Last Name:<br />
        <input type="text" name="lastname" />
        <br /><hr />
        Phone Number:<br />
        <input type="text" name="phonenumber" />
        <br /><hr />
        Address:<br />
        <input type="text" name="address" />
        <br /><hr />
        Town:<br />
        <input type="text" name="town" />
        <br /><hr />
        County:<br />
        <input type="text" name="county" />
        <br /><hr />
        Postcode:<br />
        <input type="text" name="postcode" />
        <br /><hr />
        Email:<br />
        <input type="text" name="email" />
        <br /><hr />
        <input type="submit" value="Submit" />
        </form>

The information created needs to pass in a URL only. The base URL is given, in this case, domain.com. The URL that is created and navigated to should look like: domain.com/p=firstname+lastname+123+456+7890+123+address+street+etc.....

Because this is for a mobile site, JavaScript cannot be used. PHP would be ideal as I have some knowledge, but other solutions may be possible.

Any guidance on where to start or what to research?

Was it helpful?

Solution

Anders,

If you are needing to post this to another site, then you should use a redirect.

Here are the steps needed ->

  1. Post the above form to your own PHP page
  2. On that page, do a redirect to the page you need to post to with the URL string being the format you need with your variables inserted.

To do a redirect in PHP:

header( 'Location: http://www.yoursite.com/new_page.html' ) 

OTHER TIPS

If it's an Apache server you're working with, you could use mod_rewrite to regex-craft the URL to anything you'd like.

Use method="GET" (rather than POST) to cause the browser to pass form data as part of the URL (in the form action?fieldName=value&fieldName2=value2).

Do you have to have that exact URL format? Can't you get just change the form method to GET and use the standard query string format? If you really want that format, you can redirect on the server. Frankly, I think the regular query string is better (what if you add a field?)

Not entirely sure what you're asking, but it seems you want the form above to submit itself to a URL with all of the variables being in the URL string. IF this is the case, you must change the method to GET. As for pulling those variables into your receiving page, PHP is fine. The syntax in PHP for grabbing get var is

$_GET["fname"]; 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top