SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast NewDimension's Avatar
    Join Date
    Feb 2007
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Data Pre-Population Help Please :)

    Hi,

    I am very new to this and am a little confused. I am trying to pre-populate a field on a website using information entered on a webpage before it.

    So far I can only do it like this:

    The URL will be www.example.com/l=2&z=XYZ
    When I do it like this then on the next page XYZ appears in the field that I want to be pre-populated.

    What I want is in place of XYZ there be data that was entered into a form. So that the data that was entered into the form will be carried forward onto the next webpage.

    Please help.

    Thanks.
    = + = = = =

  2. #2
    SitePoint Addict buildakicker's Avatar
    Join Date
    Jun 2005
    Location
    NorCal
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    Check out this page:

    http://www.w3schools.com/PHP/php_get.asp

    You want to use PHP GET
    SKILEASES.COM - FREE rental listings!
    WILDFIREBLOG.COM - Wildland Fire microblog!

  3. #3
    SitePoint Enthusiast NewDimension's Avatar
    Join Date
    Feb 2007
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by buildakicker View Post
    Hello,

    Check out this page:

    http://www.w3schools.com/PHP/php_get.asp

    You want to use PHP GET
    OK I think I get it.

    But what would be in the welcome.php file? How do I get this to redirect to an URL?

    Thanks.
    = + = = = =

  4. #4
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Are you going to use a form or just a link to send the data over to the next page?
    "Don't you just love it when you solve a programming bug only to create another."

  5. #5
    SitePoint Enthusiast NewDimension's Avatar
    Join Date
    Feb 2007
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spence_noodle View Post
    Are you going to use a form or just a link to send the data over to the next page?
    At the end of the link I need some data from a form to be present and then this will transfer it to the next page.

    Using http://www.w3schools.com/PHP/php_get.asp I am almost there.

    The problem is the URL I get is: www.example.com/?z=XYZ (and XYZ this time is taken from the form)
    I need the URL to be www.example.com/z=XYZ (again XYZ taken from the form).

    Just need to get rid of the ? (question mark lol)
    = + = = = =

  6. #6
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    I see, it should really be something like this: www.example.com/nextpage.php?x=xyz

    The questionmark is to help look for data when collecting it by a script or form.

    So now within the php file you would have something like:

    PHP Code:
    $x $_GET['x'];

    echo 
    the form with $x in a field 
    "Don't you just love it when you solve a programming bug only to create another."

  7. #7
    SitePoint Enthusiast NewDimension's Avatar
    Join Date
    Feb 2007
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spence_noodle View Post
    I see, it should really be something like this: www.example.com/nextpage.php?x=xyz

    The questionmark is to help look for data when collecting it by a script or form.

    So now within the php file you would have something like:

    PHP Code:
    $x $_GET['x'];

    echo 
    the form with $x in a field 
    Thanks for that but it wont work for what im trying to do.

    The thing is www.example.com/l=2 is an affiliate link.

    The requirement of pre-populating a field on the website that www.example.com/l=2 redirects to is that at the end of the URL I have &z=XYZ where the XYZ is what will be populated into the field.

    So the URL in end will be www.example.com/l=2&z=XYZ
    I just need the XYZ taken from a form on my page.

    Thanks again
    = + = = = =

  8. #8
    SitePoint Enthusiast NewDimension's Avatar
    Join Date
    Feb 2007
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone else with some input?
    = + = = = =

  9. #9
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Is this what you are trying to do, make a form, one of whose elements is appended to a redirect?
    PHP Code:
    <?php
    if( isset( $_POST['z'] )  ){ 

    $location "http://www.example.cpm/l=2&z=" $_POST["z"] ;

    //this line is debug, comment it out
    echo $location;  

    //these 2 lines do the redirect, uncomment them out 
    // header( "Location: ". $location );
    // exit;
    }
    ?>

    <form action ="" method=POST>
    <input type=text id="z" name="z" value="" />
    <input type=submit />
    </form>
    Fill in the form with xyz and the user then gets redirected here:
    http://www.example.cpm/l=2&z=xyz

    NB, to keep the example simple I have not filtered that POST value, make sure it only contains the things you expect, eg letters.
    Last edited by Cups; Dec 18, 2008 at 05:14. Reason: 2 lines to comment out


Bookmarks

Posting Permissions

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