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

My Form

the mail() function

Moderators: macek, egami, gesf

My Form

Postby GSC412 » Tue Dec 13, 2011 7:40 pm

PHP Code:
Code: Select all
<?php
                                    $emailSubject = 'Get A Quote';
                                    $webMaster = 'xxxxxxxxxxx@gmail.com';

                                    /* Gathering data vars */
      $compNm = $_REQUEST['compNm'];
      $contEmail = $_REQUEST ['contEmail'];
      $selService = $_REQUEST['selService'];
      $demo1 = $_REQUEST['demo1'];
      $chkYes = $_REQUEST['chkYes'];
      $chkNo = $_REQUEST['chkNo'];
      $selQty = $_REQUEST['selQty'];
      $cmntBox = $_REQUEST['cmntBox'];

        /*determine if printing required*/
      if(isset($_REQUEST['chkYes'])){
          $printing = 'yes';       
       }
        else
            $printing = 'no';

$body = <<<EOD
<br><hr><br>
Company Name: $compNm<br>
Contact E-mail: $contEmail<br>
Service: $selService<br>
Deadline: $date<br>
Printing: $printing<br>
Comments: $cmntBox<br>
EOD;
         
         $headers = "From: $contEmail\r\n";
         $headers .="Content-type: text/html\r\n";
         $success = mail($webMaster, $emailSubject, $body, $headers);

/* Results rendered as html */
         $theResults = <<<EOD
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Success Message</title>
<style type = "text/css">
   body{
            width: 640px;
            height: 480px;
                           background-color: #408080;
                           color: #ffffff;
                           font-family: "Arial Narrow", "sans-serif";
           }      
</style>
</head>
<body>
   <div>
        <div align = "left"> "Thank you very much for requesting a quote from GS Creations. 
                       We will get back to you shortly."
        </div>   
                 </div>
</body>
</html>
EOD;
echo "$theResults";



?>

I'm new to PHP coding, but I'm pulling my hair out over this. This code doesn't show up with any errors, but my variables don't return the input data within the email body. It shows up as...

Company Name:
Contact E-mail:
Service:
Deadline:
Printing:no
Comments:

Can you help me please?
GSC412
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue Dec 13, 2011 7:17 pm

Re: My Form

Postby egami » Wed Dec 14, 2011 7:12 am

Change REQUEST to either GET or POST.
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2197
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: My Form

Postby GSC412 » Wed Dec 14, 2011 9:58 am

Thanks a lot! I could have sworn I tried that yesterday and it didn't work. I feel super dumb now, but I did clear stored data today, so that might have helped. It works perfectly!
GSC412
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue Dec 13, 2011 7:17 pm


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 2 guests

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