PHP form submission

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 13
Joined: Thu Sep 27, 2012 10:55 am

Fri Feb 01, 2013 5:01 am


You need to close your textarea tag.

Code: Select all

<textarea name="message" rows="5" cols="40"></textarea>
Consider using an email framework, I prefer PEAR. Make sure PEAR::Mail is installed on your server first, however most PHP/apache distro's are installed with PEAR.


Here is how you implement PEAR::Mail

Code: Select all

//assign path(required) to sendmail in parameter array
//set additional options here, if needed
$params['sendmail_path'] = '/usr/sbin/sendmail';

//instantiate the Mail object
$mail_object =& Mail::factory('sendmail',$params);

//send the mail	
$success = $mail_object->send($address,$headers,$body); //set earlier in script
   if (PEAR::isError($mail_object)) {print($mail_object->getMessage());}
   	if ($success==true){
          $mes="The email successfully sent";
   		header("Location: message.php?mes=$mes");
Using a framework (like PEAR::Mail) will optimize your email making sure it is "well formed". That means less of your emails will get bounced or dropped due to mail filtering.

Post Reply