First PHP script, need your help to debug

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DonLi

    #1

    First PHP script, need your help to debug

    Hello,

    I tested a PHP script with a FORM of 2 element and it delivered the
    mail but then when I added more FORM elements, it failed to deliver.
    Following is the content of the PHP script that I'm talking about, it
    is my first PHP script. Please advise what's wrong. The mail server,
    kind of unlikely, the first try it sent the mail (beginner's luck?),
    all of sudden, it went down? it's not on my box.

    Thanks.


    <?php

    $to_addr = 'donli@yahoo.co m';

    if (isset($_REQUES T['submit'])) {
    $mail_body .= "WHYSELLING : ".$_REQUEST['WHYSELLING'];
    $mail_body .= "\nHOUSEADDRESS : ".$_REQUEST['HOUSEADDRESS'];
    $mail_body .= "\nLOANOUTSTAND ING: ".$_REQUEST['LOANOUTSTANDIN G'];
    mail($to_addr,' Form One');
    print "Thank you for your submission.";
    } else {
    print<<<_HTML_
    <form method="POST" action="$_SERVE R[PHP_SELF]">
    <table width="65%" border="4" cellpadding="2" cellspacing="0"
    bgcolor="" align="center">
    <tr><td>
    <table border="0" cellspacing="0" cellpadding="0" bgcolor="">
    <tr>
    <td>Address of house you are selling:</td>
    <td><font size="2" face="Arial">
    <input name="HouseAddr ess" type="text" id="HouseAddres s"
    size="35">
    </font></td>
    </tr>
    <tr>
    <td>Why are you selling?</td>
    <td><textarea name="WhySellin g" cols="26" rows="3"
    id="WhySelling" ></textarea></td>
    </tr>
    <tr>
    <td>Are there outstanding loans?</td>
    <td><font size="2" face="Arial">
    <input type="radio" value="Yes" name="LoanOutst anding">
    Yes
    <input type="radio" name="LoanOutst anding" value="No">
    No</font></td>
    </tr>

    <p align="center">
    <input TYPE="submit" NAME="submit" VALUE="Send Form">
    </td>
    </tr>
    </table>

    </td></tr>
    </table>

    </form>
    _HTML_;
    }

    ?>
  • Sandman

    #2
    Re: First PHP script, need your help to debug

    In article <9a172893.04022 11340.3d1e69d4@ posting.google. com>,
    donli@yahoo.com (DonLi) wrote:
    [color=blue]
    > Hello,
    >
    > I tested a PHP script with a FORM of 2 element and it delivered the
    > mail but then when I added more FORM elements, it failed to deliver.
    > Following is the content of the PHP script that I'm talking about, it
    > is my first PHP script. Please advise what's wrong. The mail server,
    > kind of unlikely, the first try it sent the mail (beginner's luck?),
    > all of sudden, it went down? it's not on my box.
    >
    > Thanks.
    >
    >
    > <?php
    >
    > $to_addr = 'donli@yahoo.co m';
    >
    > if (isset($_REQUES T['submit'])) {
    > $mail_body .= "WHYSELLING : ".$_REQUEST['WHYSELLING'];
    > $mail_body .= "\nHOUSEADDRESS : ".$_REQUEST['HOUSEADDRESS'];
    > $mail_body .= "\nLOANOUTSTAND ING: ".$_REQUEST['LOANOUTSTANDIN G'];[/color]

    Variable names are case sensitive. $_REQUEST['WHYSELLING'] and
    $_REQUEST['whyselling'] isn't the same variable.
    [color=blue]
    > mail($to_addr,' Form One');[/color]

    You didn't include the third required argument to mail() - the actual message
    to send. Presumably, you want something like:

    $msg = "
    Why he is selling: $_REQUEST[whyselling]
    The address: $_REQUEST[houseaddress]
    Loans outstanding: $_REQUEST[loadoutstanding]
    ";
    mail($to_addr, "A subject line", $msg);

    [color=blue]
    > print "Thank you for your submission.";
    > } else {
    > print<<<_HTML_
    > <form method="POST" action="$_SERVE R[PHP_SELF]">
    > <table width="65%" border="4" cellpadding="2" cellspacing="0"
    > bgcolor="" align="center">
    > <tr><td>
    > <table border="0" cellspacing="0" cellpadding="0" bgcolor="">
    > <tr>
    > <td>Address of house you are selling:</td>
    > <td><font size="2" face="Arial">
    > <input name="HouseAddr ess" type="text" id="HouseAddres s"
    > size="35">
    > </font></td>
    > </tr>
    > <tr>
    > <td>Why are you selling?</td>
    > <td><textarea name="WhySellin g" cols="26" rows="3"
    > id="WhySelling" ></textarea></td>
    > </tr>
    > <tr>
    > <td>Are there outstanding loans?</td>
    > <td><font size="2" face="Arial">
    > <input type="radio" value="Yes" name="LoanOutst anding">
    > Yes
    > <input type="radio" name="LoanOutst anding" value="No">
    > No</font></td>
    > </tr>
    >
    > <p align="center">
    > <input TYPE="submit" NAME="submit" VALUE="Send Form">
    > </td>
    > </tr>
    > </table>
    >
    > </td></tr>
    > </table>
    >
    > </form>
    > _HTML_;
    > }
    >
    > ?>[/color]

    --
    Sandman[.net]

    Comment

    • Pedro Graca

      #3
      Re: First PHP script, need your help to debug

      DonLi wrote:[color=blue]
      > <?php
      >
      > $to_addr = 'donli@yahoo.co m';
      >
      > if (isset($_REQUES T['submit'])) {
      > $mail_body .= "WHYSELLING : ".$_REQUEST['WHYSELLING'];
      > $mail_body .= "\nHOUSEADDRESS : ".$_REQUEST['HOUSEADDRESS'];
      > $mail_body .= "\nLOANOUTSTAND ING: ".$_REQUEST['LOANOUTSTANDIN G'];
      > mail($to_addr,' Form One');[/color]

      You need to put $mail_body in the mail() call
      mail($to_addr, 'Form one', $mail_body);
      [color=blue]
      > print "Thank you for your submission.";
      > } else {[/color]
      (snip)[color=blue]
      > }
      >
      > ?>[/color]

      But PHP should have complained about that.
      Have you changed the error_reporting level?


      Put

      error_reporting (E_ALL);

      at the top of every script you make to see all errors, warnings and
      notices in the browser.
      --
      --= my mail box only accepts =--
      --= Content-Type: text/plain =--
      --= Size below 10001 bytes =--

      Comment

      Working...