Results 1 to 2 of 2

Thread: Form Problems !!!

  1. #1
    Join Date
    Jan 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Form Problems !!!

    Im trying to figure out a form to send to my e-mail after the user fills it out.

    here's my mail.html file code

    ===========================<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body>
    <form action="mail.php" method="post">
    Your Name: <input type="text" name="name"><br>
    E-mail: <input type="text" name = "email"><br><br>
    Comments<br>
    <textarea name="comments"></textarea><br><br>
    <input type="submit" value="Submit">
    </form>
    </body>
    </html>
    =========================================

    then my mail.php file is
    =========================================
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    <?
    function checkOK($field)
    {
    if (eregi("\r",$field) || eregi("\n",$field)){
    die("Invalid Input!");
    }
    }

    $name=$_POST['name'];
    checkOK($name);
    $email=$_POST['email'];
    checkOK($email);
    $comments=$_POST['comments'];
    checkOK($comments);
    $to="php@gowansnet.com";
    $message="$name just filled in your comments form. They said:\n$comments\n\nTheir e-mail address was: $email";
    if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
    echo "Thanks for your comments.";
    } else {
    echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
    }
    ?>
    <body>
    </body>
    </html>

    ======================================

    Im trying to figure out why it doesnt work. Everytime i click the submit button a thing pops up asking me if i want to download the mail.php file.
    Is there something wrong with this or what do i need to change?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Sounds to me like your server doesn't suppot PHP.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •