Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Dec 2004
    Posts
    21
    Member #
    8511
    Does anyone by chance know the coding for this, or a script. I've tried searching pretty much every scripting database and have had no luck.

    an example of what i want can be seen at:

    http://www.dabs.com.

    In fact would this be easier to code with php, or are there only minor differences doing it either way?
    :: Maybe We Can Do More Than Just Stare At The Bright Lights ::

  2.  

  3. #2
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    That is fairly easy to accomplish.

    In your index.php file, put the following code around the top:

    PHP Code:
    if(!isset($_COOKIE['country']))
    {
      
    header("Location: country-selection-form.html");
      exit();
    }
    else
    {
      
    // redirect user to country specific section, i.e site.com/uk
      
    header("Location: /".$_COOKIE['country']);  
      exit();

    Above code will check the $_COOKIE['country'] variable, if it is set, the user will be redirected to the subsection related to that country, otherwise a selection form is presented to the user to choose a country.
    There and Back Again :Ogre:

  4. #3
    Junior Member
    Join Date
    Dec 2004
    Posts
    21
    Member #
    8511
    Thank you so much for helping out with this.

    I still have one question though.

    I have made a form for "country-selection-form.html" just so i can test this out, but how exactly do you give individual cookies to each selection in the form?

    Does the index.php need to be updated with each cookie for each of the variables in the list.

    www.ifmicecouldmovemountains.com

    Sorry for my lack of understand, I've only been building the site since monday, and its taken lots of searching this site and others to understand it. I hav eno training in any of this whatsoever.

    The actual site (and the page i want the UK option to link to) can be seen here http://www.ifmicecouldmovemountains.com/uk.html
    :: Maybe We Can Do More Than Just Stare At The Bright Lights ::

  5. #4
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    Hi,

    Sorry I skipped the part about setting the cookie. You need another php file which will set the actual cookie. Here is the code to do so:

    HTML Form:
    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Select your country...</title>
    </head>
    <body>
    <center>
    <form name="form1" method="post" action="country.php">
    <select name="formCountry">
       <option value="00" selected></option>
       <option value="USA">USA or Canada</option>
       <option value="UK">UK or Europe</option>
       <option value="Other">Other</option>
    </select>
    <br />
    <input type="submit" value="Submit">  
    </form>
    </center>
    </body>
    </html>

    PHP Code:
    <?PHP
    $country 
    strtolower($_POST['formCountry']);
    setcookie("country"$countrytime()+604800); // cookie expires in 7 days.
    header("Location: http://www.ifmicecouldmovemountains.com/".$country.".html");
    exit();
    ?>
    There and Back Again :Ogre:

  6. #5
    Junior Member
    Join Date
    Dec 2004
    Posts
    21
    Member #
    8511
    Thank you again. Thought i had one last problem, but that was just my stupidity.

    Thank you very much.
    :: Maybe We Can Do More Than Just Stare At The Bright Lights ::

  7. #6
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    Glad to help.
    There and Back Again :Ogre:


Remove Ads

Posting Permissions

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

Search tags for this page

html cookie to remember which country

Click on a term to search for related topics.
All times are GMT -6. The time now is 09:38 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com