Help with Contact Form

chronic420

Newbie
Joined
Jul 7, 2013
Messages
30
Reaction score
5
Gday peeps.. im fairly new around here and slowly building a few websites, was wondering if any1 can help with sum issues im having with my contact submit page it wont email..

im sure i need a extra php or sumthing.. anyways if any1 can help me ill be very gratefull can return the favour with yelp reviews or what not..cheers n beers;) pm me me
 
See this for example....
Code:
<?php
if (isset($_POST['submit_button'])) {

    $yourname = isset($_POST['yourname']) ? $_POST['yourname'] : '';
    $youremail = isset($_POST['youremail']) ? $_POST['youremail'] : '';
    $yourcomment = isset($_POST['yourcomment']) ? $_POST['yourcomment'] : '';

    $total_content = "A new contact received from {$yourname}. \r\n";
    $total_content .= "email address :  {$youremail}\r\n";
    $total_content .= "Comment :  {$yourcomment}\r\n";

    $to = '[email protected]';
    $subject = "Your cool subject!";
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
    $headers .= 'From: <[email protected]>' . "\r\n";

   // @ supresses the error. You can still have the return in status
    $status = @mail($to, $subject, $total_content, $headers);
}
?>
<html>
    <form name="yourform" action="" method="post">
<?php if (isset($status)) {
    if ($status) {
        ?>
                Message sent successfully
                <?php } else {
                ?>
                Could not send the mail. Are you sure, the mail function is enabled on your server?

    <?php }
}
?>
        <br/>
        Email: <input type="text" name="youremail"/> <br/>
        Name:<input type="text" name="yourname"/><br/>
        Comments:<textarea name="yourcomment"></textarea>
    <br/><input type="submit" value="mailme" name="submit_button"/>
    </form>
</html>

Obviously, you need validations and all, but this is the barebone that you can use. Hope it helps you and all others searching how to send a mail. Enjoy...
 
Last edited:
Back
Top