0

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"; }

?>

Edited by pritaeas: Moved.

5
Contributors
9
Replies
16
Views
4 Years
Discussion Span
Last Post by joseph.akinadewo
0
<?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.

0

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>
1

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

1

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"

Edited by EvolutionFallen

0

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

0

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.

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.