FORUMS: list search recent posts

A simple problem with forms

COW Forums : Web Design

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Paxson WoelberA simple problem with forms
by on Apr 30, 2010 at 7:33:42 am

Hello all. I've recently tried my hand at building a form in Dreamweaver(I know, I said this was simple stuff, right?). This is obviously the easy part - getting some CGI to actually deal with the form data is proving very, very tricky (at least for me..). I'm trying to post the information to a php file, which then should send an e-mail to a gmail account. There's a hitch somewhere, but I'm not sure what it is.

The page with the form is:

http://www.votemia.com/volunteer/

The PHP code, on the file contact.php, is:

$to = "costellovolunteer@gmail.com";
$subject = "Volunteer Request";
$name = $_REQUEST['name'];
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'];
$yesnewsletter = $_REQUEST['yesnewsletter'];
$event = $_REQUEST['event'];
$admin = $_REQUEST['admin'];
$sign = $_REQUEST['sign'];
$comments = $_REQUEST['comments'] ;
$headers = "From: $email" . "rn";
$headers .= "Phone : $phone" . "rn";
$headers .= "Newsletter : $yesnewsletter" . "rn";
$headers .= "Host an event : $event" . "rn";
$headers .= "Administrative work : $admin" . "rn";
$headers .= "Hold a sign : $sign" . "rn";
$headers .= "Comments : $phone" . "rn";
$sent = mail($to, $subject, $comments, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>

When I try to post the form, I get this error message:

Warning: mail() [function.mail]: SMTP server response: 550 No such user here in E:inetpubvhostsvotemia.comhttpdocscontact.php on line 19
We encountered an error sending your mail

Thanks for any guidance/help/advice!


Return to posts index

Curtis ThompsonRe: A simple problem with forms
by on Apr 30, 2010 at 3:27:11 pm

hello...

i'd guess it's because you are sending your form info as mail headers as opposed to in the body of the email - here's the php doc page:

http://php.net/manual/en/function.mail.php

that has some samples of what types of mail headers you could use (they are optional, though) - things like Cc, Bcc, Reply-To, etc...

you should put all your info in the message param, which is the 3rd one...so something like this:

$to = "costellovolunteer@gmail.com";
$subject = "Volunteer Request";
$name = $_REQUEST['name'];
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'];
$yesnewsletter = $_REQUEST['yesnewsletter'];
$event = $_REQUEST['event'];
$admin = $_REQUEST['admin'];
$sign = $_REQUEST['sign'];

$mail_body = "From: $email" . "\n";
$mail_body .= "Phone : $phone" . "\n";
$mail_body .= "Newsletter : $yesnewsletter" . "\n";
$mail_body .= "Host an event : $event" . "\n";
$mail_body .= "Administrative work : $admin" . "\n";
$mail_body .= "Hold a sign : $sign" . "\n";
$mail_body .= "Comments : $phone" . "\n";
$mail_body .= $_REQUEST['comments'] ;

$sent = mail($to, $subject, $mail_body) ;

if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }


give that a shot and see if it works for you!

sitruc





Return to posts index

Kelly JohnsonRe: A simple problem with forms
by on May 5, 2010 at 4:05:28 am

I realize this is starting over, but after about 10 minutes of reading, 10 more of using this, you'll be done:

http://www.tectite.com/



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]