By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,968 Members | 1,843 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,968 IT Pros & Developers. It's quick & easy.

sendmail.php problem

P: 2
I'm new at using php.

I am creating a basic html "contact us" form using php to send the data securely via email.

I posted the form and the screen turns blank when I hit the "submit" button.

Server is running PHP 5.2 with Mysql 5 and Apache 2
Viewing the page with Mozilla Firefox Browser 2.0
Site is wrapped in a custom tailored CMS based on Cake

Code is below...

sendmail.php code...
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.   if (isset($_POST['submitted'])) {
  3.     $errors = array(); 
  4.     if (empty($_POST['name'])) {
  5.       $errors[] = 'You did not enter your name.';
  6.     }
  7.     else {
  8.       $name = $_POST['name'];
  9.     }
  10.     if (empty($_POST['email'])) {
  11.       $errors[] = 'You did not enter an email address.';
  12.     }
  13.     else {
  14.       $email = $_POST['email'];
  15.     }
  16.     if (empty($_POST['company'])) {
  17.       $errors[] = 'You enter company name.';
  18.     }
  19.     else {
  20.       $company = $_POST['company'];
  21.     }
  22.     if (empty($_POST['title'])) {
  23.       $errors[] = 'You did not enter a title.';
  24.     }
  25.     else {
  26.       $title = $_POST['title'];
  27.     }
  28.     if (empty($_POST['phone'])) {
  29.       $errors[] = 'You did not your phone number.';
  30.     }
  31.     else {
  32.       $phone = $_POST['phone'];
  33.     }
  34.     if (empty($_POST['projname'])) {
  35.       $errors[] = 'You did not enter your project name.';
  36.     }
  37.     else {
  38.       $projname = $_POST['projname'];
  39.     }
  40.     if (empty($_POST['projectpurp'])) {
  41.       $errors[] = 'You did not enter your project\'s purpose.';
  42.     }
  43.     else {
  44.       $projectpurp = $_POST['projectpurp'];
  45.     }
  46.     if (empty($_POST['operatingsys'])) {
  47.       $errors[] = 'You did not enter operating system.';
  48.     }
  49.     else {
  50.       $operatingsys = $_POST['operatingsys'];
  51.     }
  52.     if (empty($_POST['projdescript'])) {
  53.       $errors[] = 'You did not enter a proj description.';
  54.     }
  55.     else {
  56.       $projdescript = $_POST['projdescript'];
  57.     }
  58.     if (empty($_POST['howfindsite'])) {
  59.       $errors[] = 'You did not enter how you found our site.';
  60.     }
  61.     else {
  62.       $howfindsite = $_POST['howfindsite'];
  63.     }
  64.     if (empty($_POST['deploytimeframe'])) {
  65.       $errors[] = 'You did not enter a deployment timeframe.';
  66.     }
  67.     else {
  68.       $deploytimeframe= $_POST['deploytimeframe'];
  69.     }
  70.  
  71.     if (empty($errors)) { // No errors happened
  72.       $emailmessage = "The following customer inquiry was made:\n
  73.       $name\n$email\n$company\n$title\n$phone\n$projname\n$projpurpurp\n$operatingsys\n$projdescript\n$howfindsite\n$deploytimeframe";
  74.       mail( "name@name.com, name12@name.com", "Identifinder Customer Inquiry",
  75.       "$emailmessage", "From: $email" );
  76.       header( "Location: /identifinder_contact_us/identifinder_contact_form_thank_you" );
  77.     }
  78.     else {
  79.       foreach ($errors as $msg) {
  80.         echo '<li> '.$msg.'</li>';
  81.       }
  82.    }
  83. }
  84. ?>
  85.  
  86.  
contact form html code
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8. <body>
  9. <div class="textWrap">
  10.  
  11.       <h4><span class="highlight">Thank you</span> for your interest in Name Technologies.</h4>
  12.       <h6>We will be in touch with you shortly.</h6>
  13.  
  14.  
  15.  
  16.       <form method="POST" action="/php/sendmail.php">
  17.         <table border="0" cellpadding="0" cellspacing="0">
  18.             <tr>
  19.                 <td>
  20.                     <p class="formlisting">Name:&nbsp;</p>                </td>
  21.                 <td>
  22.                     <input type="text" name="name" value="" size="40" maxlength="64" autocomplete="off" />                </td>
  23.             </tr>
  24.             <tr>
  25.                 <td>
  26.                     <p class="formlisting">E-mail:&nbsp;</p>                </td>
  27.                 <td>
  28.                     <input type="text" name="email" value="" size="40" maxlength="64" autocomplete="off" />                </td>
  29.             </tr>
  30.             <tr>
  31.                 <td>
  32.                     <p class="formlisting">Company:&nbsp;</p>                </td>
  33.                 <td>
  34.                     <input type="text" name="company" value="" size="40" maxlength="64" autocomplete="off" />                </td>
  35.             </tr>
  36.             <tr>
  37.                 <td>
  38.                     <p class="formlisting">Job Title:&nbsp;</p>                </td>
  39.                 <td>
  40.                     <input type="text" name="title" value="" size="40" maxlength="64" autocomplete="off" />                </td>
  41.             </tr>
  42.             <tr>
  43.                 <td>
  44.                     <p class="formlisting">Phone:&nbsp;</p>                </td>
  45.                 <td>
  46.                     <input type="text" name="phone" value="" size="40" maxlength="40" autocomplete="off" />                </td>
  47.             </tr>
  48.  
  49.             <tr>
  50.                 <td>
  51.                     <p class="formlisting">Project Name:&nbsp;</p>                </td>
  52.                 <td>
  53.                     <input type="text" name="projname" value="" size="40" maxlength="40" autocomplete="off" />                </td>
  54.             </tr>
  55.             <tr>
  56.                 <td>
  57.                     <p class="formlisting">Project Purpose:&nbsp;</p>                </td>
  58.                 <td><select name="projectpurp">
  59.                   <option value="">&nbsp;</option>
  60.                   <option value="SEARCH">Internal company prototype</option>
  61.                   <option value="WRDMTH">Research - Academic</option>
  62.                   <option value="MAGADV">Research - Commercial</option>
  63.                   <option value="OTHER">Other - Enter Purpose</option>
  64.                 </select></td>
  65.             </tr>
  66.  
  67.  
  68.  
  69.  
  70.         </p>
  71.  
  72.             <tr>
  73.                 <td>
  74.                     <p class="formlisting">Operating System:&nbsp;</p>                </td>
  75.                 <td>
  76.  
  77.                 <select name="operatingsys">
  78.                 <option value="">&nbsp;</option>
  79.                 <option value="SEARCH">Windows XP</option>
  80.                 <option value="WRDMTH">2003</option>
  81.                 <option value="MAGADV">Linux</option>
  82.                 <option value="OTHER">Other</option>
  83.             </select>                </td>
  84.             </tr>
  85.         </table>
  86.         <p class="formlisting"><br />Please type a few sentences describing the nature of your project</p>
  87.         <p class="formlisting"><textarea name="projdescript" rows="4" cols="54" wrap="virtual"></textarea></p>
  88.         <p class="formlisting">You found our site via:</p>
  89.         <p class="formlisting">
  90.             <select name="howfindsite">
  91.                 <option value="">&nbsp;</option>
  92.                 <option value="SEARCH">Search engine</option>
  93.                 <option value="WRDMTH">Word of mouth</option>
  94.                 <option value="MAGADV">Magazine advertisement</option>
  95.                 <option value="TRDCNF">Trade show/Conference</option>
  96.                 <option value="OTHER">Other</option>
  97.             </select>
  98.         </p>
  99.  
  100.         <p class="formlisting">If a commercial entity, how long until you hope to deploy IdentiFinder commercially?</p>
  101.         <p class="formlisting">
  102.             <select name="deploytimeframe">
  103.                 <option value="">&nbsp;</option>
  104.                 <option value="NOT">not commercial entity</option>
  105.                 <option value="3">3 months</option>
  106.                 <option value="6">6months</option>
  107.                 <option value="1">1 year</option>
  108.                 <option value="unk">unknown</option>
  109.             </select>
  110.         </p>
  111.  
  112.  
  113.         <p style="text-align: center;"><input type="submit" value="Submit" /></p>
  114.     </form>
  115.  
  116. </div>
  117. </body>
  118. </html>
  119.  
May 15 '07 #1
Share this Question
Share on Google+
2 Replies


pbmods
Expert 5K+
P: 5,821
Heya, kgrenier12. Welcome to TSDN!

My initial guess would be that your script is hitting an error, but it's not set up to display errors (the usual suspect when a script turns up blank). Check out this article:

http://www.thescripts.com/forum/thread629295.html
May 15 '07 #2

P: 2
Heya, kgrenier12. Welcome to TSDN!

My initial guess would be that your script is hitting an error, but it's not set up to display errors (the usual suspect when a script turns up blank). Check out this article:

http://www.thescripts.com/forum/thread629295.html
My apologies for not doing that BEFORE I sent my message in.

I changed my php settings inside sendmail.php and still receive a blank screen.
I'm hesitant to change the global php ini settings because it's a production site.

I did notice that my file properties on the server are "RW" only not "RWX" do you think that would contribute to the problem? I am currently trying to reset the file property settings inside ftp but have been unsuccessful.

Thanks for your help,
Kgrenier12
May 16 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.