0

I have created a contact form for a website but it doesn't seem to email when I submit a form.

here is the form code

<form action="email_contact.php" method="post"> 
            <input type="text" name="name" value="" placeholder="Your Name"/><br>
            <input type="text" name="email" value="" placeholder="Your Email"/> <br>
            <textarea name="projectDetails" placeholder="Your Project Details."></textarea>
            <br>
            <button> Submit! </button>
          </form>

and here is the php code that it links to when submitted

<?php
$to="backstback@hotmail.com";
$subject = "Competition Information";
$message = "Netball:     " . $_POST['name'] . "\r\n" .
"Email:            " . $_POST['email'] . "\r\n" .
"Info              " . $_POST['projectDetails'] ."\r\n" .
$from = $_POST['email'];
$headers = "From: $from" . "\r\n";
mail($to,$subject,$message,$headers);
?>

I'm Completely stumped on this. Any help is appreciated.

4
Contributors
16
Replies
17
Views
6 Years
Discussion Span
Last Post by qazplm114477
Featured Replies
  • I've always had trouble dealing with contact forms, I usually use PHPMailer class to send my mail, you might want to check it out [url]http://phpmailer.worxware.com/[/url] If you don't like using someone else's code then make sure you have the sendmail binary installed. [url]http://www.cyberciti.biz/tips/howto-setup-sendmail-php-mail-chrooted-apache-lighttpd.html[/url] might help if you're with a hosting … Read More

0

just a small update; the Form is on my page called contact.html and the php is on a page called email_contact.php

1

I've always had trouble dealing with contact forms, I usually use PHPMailer class to send my mail, you might want to check it out http://phpmailer.worxware.com/

If you don't like using someone else's code then make sure you have the sendmail binary installed.

http://www.cyberciti.biz/tips/howto-setup-sendmail-php-mail-chrooted-apache-lighttpd.html

might help

if you're with a hosting company, they should have most of those stuff configured. All I can say from experience is that if you're hosting with goDaddy, you're screwed.

0

I was hoping i wouldn't have to install anything and could do it by generic php code

0

so i got it working with your help the only problem now is that is sends to emails, 1 with nothing contained in it and the 2nd has all the information.

any one have any ideas why?

0

yeah, I didn't want to use PHPmailer at first but this did save me a lot of headache.

So the first mail sent is empty and the second mail has all the subject, from, to, message etc ?

It could be the way your contact form handles the sent message, it's a little hard to tell with out looking at the source. make sure you check out all the properties and methods that can be used and also check out the tutorials they have.

Edited by qazplm114477: n/a

0

hmm, when I click on the link, it goes straight to the

Thank You

Thank you for your email, we have received it and will get back to you as soon as possible.

page

Maybe the message gets sent as soon as the page loads? How do you handle the form submission?

0

the email is sent when that page loads, with the script but still sends two

<?php
$to="contact@rmelnikas.host22.com";
$subject = "Competition Information";
$message = "Netball:     " . $_POST['name'] . "\r\n" .
"Email:            " . $_POST['email'] . "\r\n" .
"Info              " . $_POST['projectDetails'] ."\r\n";
$from = $_POST['email'];
$headers = "From: $from" . "\r\n";
mail($to,$subject,$message,$from,$headers);
?>
0

im not sure with this - $headers = "From: $from" . "\r\n";

i think it should be - $headers = "From:".$from."\r\n";
variable could not be include in "" or '' coz it will read as string

and create some funtion to refuine youre message e.g stripslashes.. its important if theres a special char in message..

sorry for my bad english...

0

I have figured it out, thanks for the help the code i used was this if anyone needs any help on the same issue

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_REQUEST['email'] ;
  $subject = $_REQUEST['subject'] ;
  $message = $_REQUEST['message'] ;
  mail( "someone@example.com", "Subject: $subject",
  $message, "From: $email" );
  echo "Thank you for using our mail form";
  }
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.