Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: PHP Form

  1. #1
    New Coder
    Join Date
    Feb 2011
    Posts
    39
    Thanks
    8
    Thanked 1 Time in 1 Post

    PHP Form

    This is bothering me, the solution seems so simple yet I can't find it.

    I have a form, and when they click submit I want to put whatever they selected into the url. See below..

    Code:
    <?php
    $airport = $_POST['airport'];
    ?>
    <form action="animaltypes?id=<?php echo $PHP_SELF;?>&cost=50" method="post">
    
                    <select class="select" name="animal">
    <option value="Dog">Dogs</option>
    <option value="Cats">Cats</option>
    <option value="Cattle">Cattle</option>
    </select> 
    
    <input type="submit" name="submit" value="Submit">
    
    </form>
    As you can see I just want to simply put the selected item in the URL. Real simple...yet I can't get it to work. I have to be doing something wrong. If I hit submit it goes to /animaltypes?=cost?= and if I put the animal in with static text everything works..

  • #2
    New Coder
    Join Date
    Nov 2013
    Posts
    20
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Code:
    <form action="animaltypes?id=<?php echo $grab;?>&" method="GET">
    
                    <select class="select" name="results">
    <option value="Dog">Dogs</option>
    <option value="Cats">Cats</option>
    <option value="Cattle">Cattle</option>
    </select> 
    
    <input type="submit" name="submit" value="Submit">
    
    </form>
    
    <?php
    $grab = $_GET[results];
    ?>
    Tell me if it works, if it works please go to my search engine I created it's located at gojavo[dot]com I need the traffic be sure to click an ad.

    Thanx

  • Users who have thanked PluginDropout for this post:

    flynryan692 (11-03-2013)

  • #3
    New Coder
    Join Date
    Nov 2013
    Posts
    20
    Thanks
    0
    Thanked 2 Times in 2 Posts
    PS you' have to put cost=50 at the end of the form action url forgot to add that would have but can't edit post yet.

    "animaltypes?id=<?php echo $grab;?>&"

    To

    "animaltypes?id=<?php echo $grab;?>&cost=50"


  • Users who have thanked PluginDropout for this post:

    flynryan692 (11-03-2013)

  • #4
    New Coder
    Join Date
    Feb 2011
    Posts
    39
    Thanks
    8
    Thanked 1 Time in 1 Post
    There we go, it was "that easy".


  •  

    Posting Permissions

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