Jump to content

help with Contact Form please :)


php_newbie7z4

Recommended Posts

Hi

 

this is my first time doing this  - im having a problem with my contact form ,

 

when i fill in the form on the website it sends me the email but it doesn't send the info entered in the 'email' field, only get the info in from and message...

 

ie: in my email i get

 

From: test

E-Mail:

Message: test

 

here is the php code

 

 

<?php

if(isset($_POST['submit'])) {

 

$to = "my@emailaddress.com.au";

$subject = "CONTACT FORM";

$name_field = $_POST['name'];

$email_field = $_POST['email'];

$message = $_POST['message'];

 

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

 

mail($to, $subject, $body);

 

print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";

 

} else {

 

echo "blarg!";

 

}

?>

 

do you have any ideas on how i can fix this

 

Thanks

 

David

Link to comment
Share on other sites

I've had just a quick thought, maybe it doesn't like the @ sign or maybe the dots in the email.

 

my sight uses

 

$to = "email@site.com";
$re = "Web Site - Contact Request";

$msg  = "<p><b>Contact Request</b></p>";
$msg .= "<p><b>Message received from:</b> " . $name . "</p><p><b>" . "Email to Reply:</b> " . $email . "</p><p>";
$msg .= "<b>Regarding:</b><br /> " . $why . "</p><b>Message:</b><br /> " . $comments . "</p>";

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; ";
$headers .= "charset=iso-8859-1\r\n";
$headers .= "From: $email \r\n";

mail($to,$re,$msg,$headers);

 

Sometimes using . to join stuff behaves better, and I've also got $headers this might encode the @ sign better.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.