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: form processing

  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    UK
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    form processing

    how can i submit an option to a php form that brings up a particular sentence.

    e.g
    if option = 1 then print"you have selected option 1"
    if option = 2 then print"you have selected option 2"
    and so on.

    this is the form im using
    -------------------------------

    <form action="eg.php" method="POST">
    <select name="products">
    <option>1
    <option>2
    <option>3
    <option>4
    </select>
    <br>
    <input type="submit" value="Go">
    </form>

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Location
    East Side/West Side
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You may want this:

    <option value=1>
    <option value=2>
    <option value=3>

    etc..

    The PHP script:

    PHP Code:
    <?
    if(isset($products)) {
    if(
    $products == '1') {
    echo 
    "You have selected Product 1<br>";
    } elseif(
    $products == '2') {
    echo 
    "You have selected Product 2<br>";
    } elseif(
    $products == '3') {
    echo 
    "You have selected Product 3<br>";
    } elseif(
    $products == '4') {
    echo 
    "You have selected Product 4<br>";
    }
    // and so on
    Lemme know if this is what you need

  • #3
    New Coder
    Join Date
    Jul 2002
    Location
    UK
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    cheers but ive just solved it.

    i used option instead of product

    <? if($option == 1){ ?>
    <p>hello option 1</p>
    <? } ?>
    <? if($option == 2){ ?>
    <p>hello option 2</p>
    <? } ?>
    <? if($option == 3){ ?>
    <p>hello option 3</p>
    <? } ?>

  • #4
    Regular Coder
    Join Date
    Feb 2003
    Location
    East Side/West Side
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Never thought of that to work, but either way


  •  

    Posting Permissions

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