Contact Form PHP Mail

Discussion in 'Free Hosting' started by markleye, Feb 7, 2018.

  1. markleye

    markleye New Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Hi:

    On my site (http://nathanmarkley.net), I have a contact form for users to send a message to me. I also have a PHP file that handles/sends the message to my email address. But, it seems not to be working. I set up an email forwarder, in cpanel, that is the same email address in the PHP file, to go to my other email. But, nothing comes through; and yes, I checked the spam folder.

    This is the start of the contact form on the HTML page (where the form is)
    <form action="/email-form.php?do=send" method="POST" name="contact form">

    Here is what I put in the php file: (some reason can't attach the file as text or pdf.)

    <?php
    switch (@$_GET['do'])
    {

    case "send":

    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['comments'];
    $secretinfo = $_POST['info'];

    if (!preg_match("/\S+/",$name))
    {
    unset($_GET['do']);
    $message = "Name required. Please try again.";
    break;
    }
    if (!preg_match("/^\S+@[A-Za-z0-9_.-]+\.[A-Za-z]{2,6}$/",$email))
    {
    unset($_GET['do']);
    $message = "Primary Email Address is incorrect. Please try again.";
    break;
    }

    if ($secretinfo == "")
    {
    $to = "support@nathanmarkley.net";
    $emess = "Name: ".$name."\n";
    $emess.= "Email: ".$email."\n";
    $emess.= "Message: ".$message;
    $ehead = "From: ".$email."\r\n";
    $subj = "An Email from ".$name." ".$email;
    $mailsend = mail("$to","$subj","$emess","$ehead");
    $message = "Email was sent.";
    }
    unset($_GET['do']);
    header("Location: index.html");
    break;

    default: break;
    }
    ?>

    Any help is great.
    Thanks
    -Nathan
     

Share This Page