why i am not getting any output??

Discussion in 'PHP' started by prashant50388, Nov 6, 2011.

  1. #1
    html file:

    <html>
    <head></head>
    <body>
    <form method="post" action="message.php">
    <input type="button" name="press1" value="send this"> &nbsp;
    <input type="button" name="press2" value="send that">
    </form>
    </body>
    </html>




    php file (message.php):

    <?php
    if (($_POST['press1'] == "send this") && ($_post['press2'] == "")){
    $input = "you pressed send this button";
    }elseif (($_POST['press2'] == "send that") && ($_post['press1'] == "")){
    $input = "you pressed send that button";
    }
    echo "$input";
    ?>
     
    prashant50388, Nov 6, 2011 IP
  2. bogi

    bogi Well-Known Member

    Messages:
    482
    Likes Received:
    16
    Best Answers:
    2
    Trophy Points:
    140
    #2
    It would be great to know what you're trying to do. Why do you check for an empty input in your statements? The value is the same in both cases.
    You should check "if ( isset($_POST['press1']) )" or "if ( isset($_POST['press2']) )".

    But... Please note, <input type="button" defines a clickable button that doesn't do anything. It's most often used to activate a JavaScript.
     
    bogi, Nov 6, 2011 IP
  3. dixcoder

    dixcoder Member

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    26
    #3
    change your input type="button" from input type="submit" then it will work

    for example

    from
    <input type="button" name="press1" value="send this"> &nbsp;
    <input type="button" name="press2" value="send that">


    to

    <input type="submit" name="press1" value="send this"> &nbsp;
    <input type="submit" name="press2" value="send that">

    thanks
     
    dixcoder, Nov 7, 2011 IP
  4. prashant50388

    prashant50388 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thank you guys!!its working by both methods.
     
    prashant50388, Nov 7, 2011 IP