What is wrong with my code ?

Discussion in 'PHP' started by bengaluru, Sep 5, 2007.

  1. #1
    I created a simple Email form and although the results are fine, one of the items is not displayed.

    This is my form

    <p align="center"><font size="4" face="Book Antiqua"><b>Update your
    Contact Information </b></font>
    <form action="feedback.php" method="post">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td valign="top" height="18" colspan="2">
    <div align="center"></div>
    </td>
    </tr>
    <tr>
    <td height="28" width="158" valign="top"><b><font face="Garamond" size="3">Your
    Name:</font></b></td>
    <td valign="top" width="249">
    <input type="text" name="name" size="41" "style="background-color: #FFFFFF; color: #336699; border-style: inset; border-color: #B8CDDC">
    </td>
    </tr>
    <tr>
    <td height="28" valign="top"><b><font size="3" face="Garamond">Your
    Email:</font></b></td>
    <td valign="top">
    <input type="text" name="email" size="41" "style="background-color: #FFFFFF; color: #336699; border-style: inset; border-color: #B8CDDC">
    </td>
    </tr>
    <tr>
    <td height="38" valign="top"><b><font size="3" face="Garamond">Your
    Phone</font></b></td>
    <td valign="top">
    <input type="number" name="Phone" size="41" "style="background-color: #FFFFFF; color: #336699; border-style: inset; border-color: #B8CDDC">
    </td>
    </tr>
    <tr>
    <td height="97" valign="top">
    <p>&nbsp;</p>
    <p><b><font size="3" face="Garamond">Your Address for updation.</font></b></p>
    </td>
    <td valign="top">
    <textarea name="comments" cols="35" rows="4" id="comments" "style="background-color: #FFFFFF; color: #336699; border-style: inset; border-color: #B8CDDC"></textarea>
    </td>
    </tr>
    <tr>
    <td height="51" valign="top">&nbsp;</td>
    <td valign="top"><br>
    <input type="submit" name="Submit" value="Send this form" style="background-color: #304C60; color: #FFFFFF; border-style: solid; border-color: #C5D6E2">
    <INPUT TYPE=RESET NAME=RESET VALUE="Reset" style="background-color: #304C60; color: #FFFFFF; border-style: solid; border-color: #C5D6E2">
    </td>
    </tr>
    </table>
    </form>

    And this is my feedback.php referenced above

    <?if (($name == "") && ($email == "") && ($comments == "")) {
    header("Location: http://www.12345.com/contactus.php");
    exit;}

    $msg = "E-MAIL SENT FROM $email\n";
    $msg .= "Sender's Name: $name\n";
    $msg .= "Sender's E-Mail: $email\n";
    $msg .= "Sender's Phone : $phone\n";
    $msg .= "Message: $comments\n\n";

    $date = date("m/d/Y H:i:s");

    $visitor_IP = $_SERVER['REMOTE_ADDR'];


    if ($REMOTE_ADDR == "") $ip = "no ip";
    else $ip = getHostByAddr($REMOTE_ADDR);

    $to = "12345@gmail.com;
    $subject = " Feedback";
    $mailheaders = "From: Response Forms <> \n";
    $mailheaders .= "Reply-To: $email\n\n";

    mail($to, $subject, $msg, $mailheaders);
    ?>
    <HTML>
    <HEAD><TITLE> Thank You</TITLE>


    </HEAD>

    <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" marginwidth="2">
    <font size="2" face="Arial, Helvetica, sans-serif"><b><font color="#FFFFFF">
    <form action="feedback.php" method="post">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="207" height="260" valign="top">
    <div align="center">
    <p><font face="Fine Hand">Thank you for your response</font></p>
    <P><strong>Your Name:</strong>
    <? echo "$name"; ?>
    <P><strong>Your E-Mail Address:</strong>
    <? echo "$email"; ?>
    <P><strong>Your Phone Number:</strong>
    <? echo "$phone"; ?>
    <P><strong>Message/Information:</strong>
    <? echo "$comments"; ?>
    <H3>Please wait and you will be taken back to the page you were
    viewing<br>
    </H3>
    </div>
    </td>
    </tr>
    </table>
    </form>
    </font></b></font></div>
    </td>
    </tr>
    </table>
    </body>
    </html>


    And now the Problem

    When the results are displayed in the E Mail, the Phone field is Blank. the field is also blank when the user gets a Thank You confirmation.

    Why is this happening. What is wrong with my Code ??

    Thanks for your help.
     
    bengaluru, Sep 5, 2007 IP
  2. killerj

    killerj Active Member

    Messages:
    765
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    95
    #2
    open feedback.php
    on top of
    <?if (($name == "") && ($email == "") && ($comments == "")) { 
    Code (markup):
    add
     
    <?php 
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['Phone'];
    $comments = $_POST['comments'];
    ?> 
    PHP:
    that should fix your problem.
    good luck.

    Note:
    Currently , the problem is caused by
    <input type="number" name="Phone" size="41" "style="background-color: #FFFFFF; color: #336699; border-style: inset; border-color: #B8CDDC">
    Code (markup):
    The Posted values of this field or any other fields are not grabbed correctly by feedback.php
     
    killerj, Sep 5, 2007 IP
  3. bengaluru

    bengaluru Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks Killerj for your help.

    Can you tell me what should I replace to the above code which is causing the problem.

    Take care
     
    bengaluru, Sep 5, 2007 IP
  4. killerj

    killerj Active Member

    Messages:
    765
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    95
    #4
    read my post again , I gave you the fixed codes :)
     
    killerj, Sep 6, 2007 IP