Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Form wont submit

the mail() function

Moderators: macek, egami, gesf

Form wont submit

Postby linardzb » Sat Nov 03, 2012 3:37 pm

Hi,

my php seems to be not working with this code
Code: Select all
<?php //Make sure that PATH_INFO is set, and not ORIG_PATH_INFO as some hosts seem to use.
if (isset ($_SERVER['ORIG_PATH_INFO']) && $_SERVER['ORIG_PATH_INFO'] != $_SERVER['PHP_SELF']) {
   $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
}


if (!empty ($_SERVER['PATH_INFO']) && strrpos ($_SERVER['PHP_SELF'], $_SERVER['PATH_INFO'])) {
   $_SERVER['PHP_SELF'] = substr ($_SERVER['PHP_SELF'], 0, -(strlen ($_SERVER['PATH_INFO'])));
}
?>

<?php
      $error = false;
      $sent = false;
      
      if(isset($_POST['name'])) {
         if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comments'])) {
            $error = true;
         } else {
         
         $to = "pamella@origin-designs.co.uk";
         
         $name = trim($_POST['name']);
         $email = trim($_POST['email']);
         $comments = trim($_POST['comments']);
         
         
         $subject = "Contact Form";   
            
         $messages =  "Name: $name \r\n Email: $email \r\n Comments: $comments";
         $headers .= 'From: '.$name.' <'.$email.'>' . "\r\n";   
         $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
         $headers .= "From:" . $name . "\r\n";
         
         
         
         
         $mailsent = mail($to, $subject, $messages, $headers);
         
         if($mailsent) {
            $sent = true;
         }
      }
   }
?>


Can someone spot the problem here?

Many thanks
linardzb
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Aug 29, 2012 1:09 pm

Re: Form wont submit

Postby seandisanti » Tue Nov 13, 2012 1:38 pm

Is it throwing an error? Typically the error text or a description of how it's failing is the best way to get help.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 787
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron