Can someone help me with this php script for form processing. I use the script for processing my contact form, but I could not received a reply from my contacts. instead whosever contact me, the system returns back to me the followings thereby making it impossible for me to actually identified my contact and the message:

From:
Name:
Email:
Message:

Below is the script that I used for the processing:

<?php
$to = "info@vineyardgroupofschool.org";
$subject = "Site Contact" ;
$email = $_REQUEST['email'] ;
$message = "Name: ".nl2br($_POST["name"]. "\r\n");
$message .= "Email: ".nl2br($_POST["email"]. "\r\n");
$message .= "Message: ".nl2br($_POST["message"]);
$headers = "From: $email";
$headers .= "\nContent-Type: text/html; charset=UTF-8";
$headers .= "\nMIME-Version: 1.0";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }

?>

Show your form too.

<?php
$to = "info@vineyardgroupofschool.org";
$subject = "Site Contact";
$email = $_POST['email']; // Changed to $_POST['']
$message = "Name: ".nl2br($_POST["name"]. "\r\n");
$message .= "Email: ".nl2br($_POST["email"]. "\r\n");
$message .= "Message: ".nl2br($_POST["message"]);
$headers = "From: $email";
$headers .= "\nContent-Type: text/html; charset=UTF-8";
$headers .= "\nMIME-Version: 1.0";
$sent = mail($to, $subject, $message, $headers); // Had a space where the ';' is
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>

Try that.

below is my HTML form:

<form method="post" autocomplete="on" action="send_form_email.php">
    <div>
        Your name:
        <input type="text" name="Name" />
    </div>

    <div>
        Your email address:
        <input type="text" name="Email" />
    </div>

    <div>
        Details about your Request: <br />
        <textarea name="Message" cols="45" rows="4"></textarea>
    </div>

    <div>
        <input type="submit" value="Submit" />


    </div>
  </form>

POST values are case sensitive, just like all associative arrays, so you have to use $_POST['Name'], Email and Message.

In your PHP code your keys for the $_POST var are all lower-case (e.g., $_POST['email']). In your HTML though, the names of the fields are all capitalized (e.g., name="Email"). You should change all the name attributes to lowercase, like name="email"

Hi Djmann 1013,I tried your scripts, still did not work. I need held from someone please on the above form processing.

Did you follow the information the other two posters gave you? Your $_POST array keys need to have the same capatalization as the form $_POST['Name'] $_POST['Email'] $_POST['Message'] Without that it will not work.

I did not see the code for the post the last time I posted. $_POST['']; values are case-sensitive. Here is an example:

<?php
// Post values are Case-sensitive

$to = "info@vineyardgroupofschool.org";
$subject = "Site Contact";
$email = $_POST['Email']; // Changed to $_POST['']
$message = "Name: ".nl2br($_POST["Name"]. "\r\n");
$message .= "Email: ".nl2br($_POST["Email"]. "\r\n");
$message .= "Message: ".nl2br($_POST["Message"]);
$headers = "From: $email";
$headers .= "\nContent-Type: text/html; charset=UTF-8";
$headers .= "\nMIME-Version: 1.0";
$sent = mail($to, $subject, $message, $headers); // Had a space where the ';' is
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>

The code should now work.

Thanks everybody, the code is now working perfectly.

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.