PHP else not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Josh Parker
    New Member
    • Nov 2011
    • 2

    PHP else not working

    Here is my code, whenever i am testing if its false (I dont type in the from box it says message sent anyway?

    Code:
    <?php
    if (isset($_REQUEST['from']))
    {
    $from = $_REQUEST['from'];
    $to = $_REQUEST['to'];
    $subject = $_REQUEST['subject'];
    $message = $_REQUEST['message'];
    mail("$to", "$subject", $message, "From:".$from);
    echo "<div align='center'>Message sent!</div>";
    }
    else
    //Else show form again
    {
    echo "<form action='cheaposend.php' method='post'>
    From:<input type='text' name='from'/><br />
    To:<input type='text' name='to'/><br />
    Subject:<input type='text' name='subject'/><br />
    Message:<input colspan='60' height='30px' type='text' name='message'/><br/>
    <input type='submit'/>
    </form>";
    }
    ?>
    I am using method="post" on other webpage
    Last edited by Dormilich; Nov 5 '11, 07:12 AM. Reason: please use [CODE] [/CODE] tags when posting code
  • zorgi
    Recognized Expert Contributor
    • Mar 2008
    • 431

    #2
    What method are you using get or post?

    The form-data can be sent as URL variables (with method="get") or as HTTP post (with method="post").

    Comment

    • Josh Parker
      New Member
      • Nov 2011
      • 2

      #3
      I am using method="post"

      Comment

      • zorgi
        Recognized Expert Contributor
        • Mar 2008
        • 431

        #4
        Did that change help?

        Comment

        Working...