1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Additional data attached to .php file

Discussion in 'Web Design & Development' started by NegativeKelvin, Feb 2, 2013.

Thread Status:
Not open for further replies.
Advertisement
  1. NegativeKelvin

    NegativeKelvin Thread Starter

    Joined:
    Apr 11, 2012
    Messages:
    298
    I'm experimenting with the syntax of a bot.
    http://bot.pidude.com/resources/get.php?a=type&data=

    get.php?a=
    can be

    weather, define

    get.php?a=blahblah&data
    the data part can equal a term to be searched on Urban Dictionary for 'define'; City,Country for 'weather'

    Anyways, I'm terrible with forms, how would I make a form that inserts the term searched into the &data thing. Sorry if this is an inexperienced question, I'm better with programming the computer itself rahter that the web...
     
  2. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,331
    First Name:
    Jim
    Hi BC:)
    The form itself is straightforward enough (place example below in your html <body>). It's whether (pun unintentional) or not you want to provide country and city/town drop-down lists that may prove problematic. Countries you can get from here Cities within each country - that's the problem...
    Personally I would start by offering the drop-down country list and a free form city/town box, as per the example...
    HTML:
    <FORM action="" method="Get">
    <INPUT Type=Hidden Name=Command Value=Search>
    Search For Country: 
    <SELECT id=Country Name=Country>
    <option value="AF">Afghanistan</option>
    <option value="AL">Albania</option>
    <option value="DZ">Algeria</option>
    <option value="AS">American Samoa</option>
    <option value="">Etc.,</option>
    </SELECT>
    City/Town: <input type="text" name="citown">
    </FORM>
    
    But if you want a situation where you auto-populate the second drop-down box depending upon the first box selection, then it's a whole new ball-game;)
     
  3. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,331
    First Name:
    Jim
    You will obviously need to verify the form before constructing your url and the php page you use for this is what you would put into the first line of your html, thus
    HTML:
    <FORM action="scripts/verify.php" method="Get">
    ... if you need help with the php, just give us a shout;)
     
  4. NegativeKelvin

    NegativeKelvin Thread Starter

    Joined:
    Apr 11, 2012
    Messages:
    298
    No, right now I'm just looking for something where it's like

    Where it doesn't really verfiy anything, as it just searches the string on Urban Dictionary, then outputs the data retrieved.
    But would this be the correct form syntax?
     
  5. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,331
    First Name:
    Jim
    Ok Kyle, I am getting the picture now...
    We need to know exactly how pidude's get.php expects to receive the Country and City/Town data in the url - I imagine it would be something like http://bot.pidude.com/resources/get.php?a="weather"&data="Afghanistan|Kabul" - but we need to be certain of the required format, before we can expect a response.
    So if you could try to contact them to find this out, we can go from there...;)
    Your proposed url wouldn't work in that format, it should look more like this
    HTML:
    <form action="http://bot.pidude.com/resources/get.php?a='define'&method='get'">
    but let's find out what they need...
     
  6. NegativeKelvin

    NegativeKelvin Thread Starter

    Joined:
    Apr 11, 2012
    Messages:
    298
    The code for gettign the weather info looks like:
    (90210 is a zip code)
    which returns:
    Weather for: santa monica municipal airport Temperature: 68 °F (20 °C) Humidity: 46% Current Condition: Sunny



    or
    (Hollywood,US) is City,Country
    Which returns:
    Weather for: fort lauderdale/hollywood Temperature: 66 °F (19 °C) Humidity: 46% Current Condition: Mostly Clear
     
  7. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,331
    First Name:
    Jim
    Catering for the US States makes it somewhat easier - you can tailor the following rough code to suit your needs (it's very basic);)
    PHP:
    <?php
    if(isset($_REQUEST["submit"])) 

    // Put your url build code in here e.g.
    $data $_REQUEST["citown"] . "," $_REQUEST["state"];
    echo 
    "Submit $data to weather site?";
       
    header"Location: http://bot.pidude.com/resources/get.php?a=weather&data=$data) ;
    }
    ?>
    <html>
    <body>
    <form method="post" action="BCForm.php">

    City/Town: <input type="text" name="citown">
    State: 
    <select name="state">
    <option value="" selected="selected">Select A State</option>
    <option value="AL">Alabama</option>
    <option value="AK">Alaska</option>
    <option value="AZ">Arizona</option>
    <option value="AR">Arkansas</option>
    <option value="CA">California</option>
    <option value="CO">Colorado</option>
    <option value="CT">Connecticut</option>
    <option value="DE">Delaware</option>
    <option value="DC">District Of Columbia</option>
    <option value="FL">Florida</option>
    <option value="GA">Georgia</option>
    <option value="HI">Hawaii</option>
    <option value="ID">Idaho</option>
    <option value="IL">Illinois</option>
    <option value="IN">Indiana</option>
    <option value="IA">Iowa</option>
    <option value="KS">Kansas</option>
    <option value="KY">Kentucky</option>
    <option value="LA">Louisiana</option>
    <option value="ME">Maine</option>
    <option value="MD">Maryland</option>
    <option value="MA">Massachusetts</option>
    <option value="MI">Michigan</option>
    <option value="MN">Minnesota</option>
    <option value="MS">Mississippi</option>
    <option value="MO">Missouri</option>
    <option value="MT">Montana</option>
    <option value="NE">Nebraska</option>
    <option value="NV">Nevada</option>
    <option value="NH">New Hampshire</option>
    <option value="NJ">New Jersey</option>
    <option value="NM">New Mexico</option>
    <option value="NY">New York</option>
    <option value="NC">North Carolina</option>
    <option value="ND">North Dakota</option>
    <option value="OH">Ohio</option>
    <option value="OK">Oklahoma</option>
    <option value="OR">Oregon</option>
    <option value="PA">Pennsylvania</option>
    <option value="RI">Rhode Island</option>
    <option value="SC">South Carolina</option>
    <option value="SD">South Dakota</option>
    <option value="TN">Tennessee</option>
    <option value="TX">Texas</option>
    <option value="UT">Utah</option>
    <option value="VT">Vermont</option>
    <option value="VA">Virginia</option>
    <option value="WA">Washington</option>
    <option value="WV">West Virginia</option>
    <option value="WI">Wisconsin</option>
    <option value="WY">Wyoming</option>
    <input type="submit" name="submit" value="Submit For Weather"><br>
    </select>
    </form>
    </body>
    </html>
    just bare in mind that in order for this to work it must be a .php file (I called this one BCForm.php but yours can be what you like)...
    Why not do the same kind of thing for a Zip Code? Just Google "US Zip Code drop-down" to get the select option list and play play play:)
     
  8. NegativeKelvin

    NegativeKelvin Thread Starter

    Joined:
    Apr 11, 2012
    Messages:
    298
    Lol, that'd be a long list of zip codes.
     
  9. NegativeKelvin

    NegativeKelvin Thread Starter

    Joined:
    Apr 11, 2012
    Messages:
    298
  10. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1087872

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice