Form submission

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
greatme
Forum Newbie
Posts: 14
Joined: Fri Jul 09, 2010 10:55 am

Form submission

Post by greatme »

I need somebody to come to my rescue. I have a contact page of my website that handles form from the users but when users submit submit the form from the contact page i don't get to recieve it in the designated webmail account. here is the form_handler code.

<?php
error_reporting(E_ALL - (E_NOTICE + E_WARNING));
$first_name= $_POST["firstname"];
$last_name= $_POST["lastname"];
$email= $_POST["mail"];
$address= $_POST["address"];
$phone= $_POST["mobile"];
$textdata= nl2br($_POST["user_comment"]);
$to = "info@seapmicrofinance.org";
$from = "".$_POST["mail"]."";
$subject = "Online Form";

$message = "Online Form
Hello,
First Name: $first_name
Last Name: $last_name
Email: $email
Address: $address
Phone: $phone
Comment: $textdata ";

$headers = "<info@successpalace.com>\r\n";
$headers .= "Content-type: text/html\r\n";

mail($to, $subject, $message, $headers);

?>
zyntrax
Forum Commoner
Posts: 32
Joined: Wed Apr 13, 2011 2:23 am
Location: Sweden

Re: Form submission

Post by zyntrax »

Well it seams you arn't sending it, do you have a smtp server to use?

$from = "Sandra Sender <sender@example.com>";
$to = "Ramona Recipient <recipient@example.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "smtp server";
$username = "smtp_username";
$password = "smtp_password";

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Form submission

Post by social_experiment »

Any error messages when you send the message?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: Form submission

Post by fugix »

also i would make $from = $email
Post Reply