simple web form help

Discussion in 'PHP' started by tmos_ash, Sep 29, 2007.

  1. #1
    OK I have created a simple form that I want to email me the results... but is doen't work. I also would like a thankyou.html to load upon submital. Can someone please tell me what is wrong with my html form or php file? I am very new to the world of server side scripting. Here's the details:

    HTML FORM CODE:

    <td style="width:220px;"><table border="0" cellpadding="0" cellspacing="0" style="width:185px;">
    <tr>
    <td style="height:233px;"><form action="http://www.mywebpage.com/cgi-bin/contactx.php" id="form"><table border="0" cellpadding="0" cellspacing="0" style="margin:12px 0 0 18px; width:181px;">
    <tr><td><img src="images/7title4.jpg" alt="" style="margin-bottom:17px;"></td></tr>
    <tr>
    <td><label>
    <input name="name" type="text" id="name" value="Name:">
    </label></td>
    </tr>
    <tr><td><img src="images/spacer.gif" width="1" height="8" alt=""></td></tr>
    <tr>
    <td><label>
    <input name="email" type="text" id="email" value="Email:">
    </label></td>
    </tr>
    <tr><td><img src="images/spacer.gif" width="1" height="8" alt=""></td></tr>
    <tr>
    <td><label>
    <textarea name="message" id="message" cols="45" rows="5">Message:

    </textarea>
    </label></td>
    </tr>
    <tr>
    <td><table border="0" cellpadding="0" cellspacing="0" style="margin:5px 0 0 80px;" class="kn">
    <tr>
    <td width="60" style="width:60px;"><a href="#" onclick="document.getElementById('form').reset()">clear</a><img src="images/ch_1.jpg" style="margin-left:4px; margin-top:5px;" alt=""></td>
    <td width="39"><a href="#" onclick="document.getElementById('form').submit()">send</a>

    <img src="images/ch_1.jpg" style="margin-left:4px; margin-top:5px;" alt=""></td>
    </tr>
    </table></td>
    </tr>
    </table></form></td>
    </tr>
    </table></td>
    </tr>
    </table></td>


    AND THE PHP:

    <?php


    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];


    $to = "myemail@mail.com";
    $subject = $_POST['subject'];
    $msg = $message . $_POST['name'] . $getip;
    $headers = "From: " . $_POST['sender_email'] . "\r\nReply-To:" . $_POST['sender_email'];


    mail("$to", "$subject", "$msg", "$headers");

    ?>
     
    tmos_ash, Sep 29, 2007 IP
  2. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #2
    To save time, tell us What error do you get on your browser when you click submit?
     
    nabil_kadimi, Sep 29, 2007 IP
  3. tmos_ash

    tmos_ash Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks for the fast reply... here is what is says:

    Notice: Undefined index: name in C:\Accounts\ashworth\wwwRoot\cgi-bin\contactx.php on line 5

    Notice: Undefined index: email in C:\Accounts\ashworth\wwwRoot\cgi-bin\contactx.php on line 6

    Notice: Undefined index: message in C:\Accounts\ashworth\wwwRoot\cgi-bin\contactx.php on line 7

    Notice: Undefined index: subject in C:\Accounts\ashworth\wwwRoot\cgi-bin\contactx.php on line 12

    Notice: Undefined index: name in C:\Accounts\ashworth\wwwRoot\cgi-bin\contactx.php on line 13

    Notice: Undefined variable: getip in C:\Accounts\ashworth\wwwRoot\cgi-bin\contactx.php on line 13

    Notice: Undefined index: sender_email in C:\Accounts\ashworth\wwwRoot\cgi-bin\contactx.php on line 14

    Notice: Undefined index: sender_email in C:\Accounts\ashworth\wwwRoot\cgi-bin\contactx.php on line 14
     
    tmos_ash, Sep 29, 2007 IP
  4. foreststone

    foreststone Peon

    Messages:
    1,355
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hi guy, you forgot subject text box on your html, so your php file can not find it, shows error
     
    foreststone, Sep 29, 2007 IP
  5. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #5
    replace 1 with 2:

    1
    <form action="http://www.mywebpage.com/cgi-bin/contactx.php" id="form">
    HTML:
    2
    <form method="post" action="http://www.mywebpage.com/cgi-bin/contactx.php" id="form">
    HTML:
     
    nabil_kadimi, Sep 29, 2007 IP
  6. tmos_ash

    tmos_ash Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thank you very much for your help... I can now recieve the email but it doesn't show a sender or subject.

    Here are the remaning errors that occur

    Notice: Undefined index: subject in C:\Accounts\ashworth\wwwRoot\cgi-bin\contactx.php on line 12

    Notice: Undefined variable: getip in C:\Accounts\ashworth\wwwRoot\cgi-bin\contactx.php on line 13

    Notice: Undefined index: sender_email in C:\Accounts\ashworth\wwwRoot\cgi-bin\contactx.php on line 14

    Notice: Undefined index: sender_email in C:\Accounts\ashworth\wwwRoot\cgi-bin\contactx.php on line 14
     
    tmos_ash, Sep 30, 2007 IP
  7. tmos_ash

    tmos_ash Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    OH and I added a subject... thanks foreststone
     
    tmos_ash, Sep 30, 2007 IP