I'm trying to do a simple contact form and have it send to an e-mail but its giving me an error after clicking submit. Here's my code:

    <form action="contact.php" method="post">
        <fieldset>
            <legend>Contact Information</legend>
                First Name: <input type="text" name="fname" id="fname" value="" /><br />
                Last Name: <input type="text" name="lname" id="lname" value="" /><br />
                Phone Number: <input type="text" name="number" id="number" value="" /><br />
                E-Mail Address: <input type="text" name="email" id="email" value=""  /><br />
                Confirm E-Mail Address: <input type="text" name="confemail" id="confemail" value=""  /><br />
        </fieldset><br />
        <fieldset>
            <legend>Extra Info</legend>
                <label for="youneed">Tell Us What You Need:</label><br />
                    <textarea name="youneed" value="youneed"></textarea>
        </fieldset><br />
        <fieldset>
            <legend>Submit And We'll Get Back To You</legend>
                <input type="submit" id="submit" value="Submit" />
        </fieldset>                  
    </form>




<?php

if (isset($_POST["email"])) ;
    {
        $myemail ="contact@daintydeliites.com" ;
        $subject ="Contact Form From DD Site" ;
        $mailheader ="From:" . $_POST["email"] . "\r \n" ;
        $mailheader ="Reply-To:" . $_POST["email"] . "\r \n" ;
        $mailheader ="Content-type: text/html" ;
        $MESSAGE_BODY ="First Name:" . $_POST["fname"] . " " ;
        $MESSAGE_BODY ="Last Name:" . $_POST["lname"] . " " ;
        $MESSAGE_BODY ="Phone Number:" . $_POST["number"] . " " ;
        $MESSAGE_BODY ="E-Mail Address:" . $_POST["email"] . " " ;
        $MESSGAE_BODY ="I Need:" . $_POST["youneed"] . " " ;

        mail ($myemail, $subject, $MESSAGE_BODY, $mailheader);

    }
else
    {
        die("Your email failed to send, please check your email address.");
    }


?>

Recommended Answers

All 6 Replies

Member Avatar for michelleradu

What error are you getting?

Warning: mail(): Failed to connect to mailserver at "smtp.1and1.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\webDev\DDCC\site\contact.php on line 27

P.S. those codes are in 2 seperate files. line 27 the are talking about is line 39 in the above code.

is easyphp have a sendmail packaged with it? Browsse your local server and look for mercuryMail or something about the mail. Let me know what do you have in your local server.. You also need to tell me if your local server have a directory called sendmail, and what is your server's loaded configuration file? By giving the proper answers on these questions, I can tell you which php.ini and sendmail.ini file you need to edit to make this work on your localhost..

You need to know all these stuffs and how to set them prior to executing send mail..

moi il affiche cette erreur je sais pas le sol Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in C:\Program Files\EasyPHP-12.1\www\action.php on line 15

you not append your $myheader and $MESSAGE_BODY also

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.