Jump to content

[SOLVED] trouble with mail() function


MainStWebGuy

Recommended Posts

hello again all, I have a form i'm wanting to use on a website but can't seem to figure out why the mail() function isn't sending the message... I'm still a newbie, and i'm hoping it's something simple, but i can't seem to find it....

 

<?php

//if the submit button is pressed
   if (isset($_POST['submit2'])) {
      //set variables from form data
      $name = htmlspecialchars($_POST['cName']);
      $phone = htmlspecialchars($_POST['cPhone']);
      $fax = htmlspecialchars($_POST['faxNumber']);
      $address = htmlspecialchars($_POST['companyAddress']);
      $city = htmlspecialchars($_POST['city']);
      $state = htmlspecialchars($_POST['state']);
      $zip = htmlspecialchars($_POST['zipCode']);
      $fedTaxId = htmlspecialchars($_POST['fedTaxId']);
      $oName = htmlspecialchars($_POST['ownersName']);
      $eCommerceManager = htmlspecialchars($_POST['eCommerceManager']);
      $email = htmlspecialchars($_POST['emailAddress']);
      $whatForm = htmlspecialchars($_POST['serviceForm']);
   //EDI variables   
      $volume = htmlspecialchars($_POST['volumePlan']);
      $ediTerms = htmlspecialchars($_POST['ediTermsOfService']);
      $ediPayment = htmlspecialchars($_POST['paymentOptions']);
      
   //Glaxis Variables
      $dispatch = htmlspecialchars($_POST['lynxDispatch']);
      $liveDate = htmlspecialchars($_POST['liveDate']);
      $ppgSetup = htmlspecialchars($_POST['ppgOnlineOrdering']);
      $glaxisTerms = htmlspecialchars($_POST['glaxisTermsOfService']);
      
      $ediMsg = "Another customer has signed up for EDI.\n\nCompany Name: $cName\nPhone: $cPhone\nFax: $fax\nAddress: $address\nCity: $city\nState: $state\nZip: $zip\nFed Tax Id: $fedTaxId\nOwners Name:$oName\neCommerce Manager: $eCommerceManager\nEmail: $email\n\nVolume Plan: $volume\nAgree to Terms: $ediTerms\nEDI Payment Type: $ediPayment\n";
      
  $glaxisMsg = "Another Customer has signed up for Glaxis.\n\nCompany Name: $cName\nPhone: $cPhone\nFax: $fax\nAddress: $address\nCity: $city\nState: $state\nZip: $zip\nFed Tax Id: $fedTaxId\nOwners Name:$oName\neCommerce Manager: $eCommerceManager\nEmail: $email\n\nPrevious Dispatch Number: $dispatch\nLive Date: $liveDate\nPPG Setup: $ppgSetup\nAgree to Terms: $glaxisTerms\n";
  
   switch ($_POST['serviceForm']) {
      case 'EDI':

         mail ("myEmailAddress1@yahoo.com","EDI Service request form", "$ediMsg");
         break;

      case 'Glaxis':
         mail("myEmailAddress2@yahoo.com@mainstreetcomp.com", "Glaxis Service request form", "$glaxisMsg");         
         break;      

      case 'EDI and Glaxis':   
         mail ("myEmailAddress1@yahoo.com", "EDI Service request form", "$ediMsg");
         mail("myEmailAddress2@yahoo.com", "Glaxis Service request form", "$glaxisMsg");    
         break;
   }

               
         //tell user that form has been submitted
         //and to check for confirmation
         echo '<p align="center">'."Your form has been submitted. Check your inbox for a confirmation message.".'</p>';
      }   else {   //if submit has not been pressed, display form 
   
?>  

<html>
<head></head>
<body>
<form name="form2" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
   <table border="0" cellspacing="0" cellpadding="2">
      <tr>
         <td>Company Name:</td>
         <td>
            <?php
            //if name has been filled in previously,
            //fill in this field
               if ($_POST['cName'] == true) {
                  echo'<input type="text" name="cName" value="'.$_POST['cName'].'" />';
               } else {
                  echo'<input type="text" name="cName" />';
               }    
            ?>  
         </td>
      </tr>
      <tr>
         <td>Phone Number:</td>
         <td>
            <?php
               if ($_POST['cPhone'] == true) {
                  echo'<input type="text" name="cPhone" value="'.$_POST['cPhone'].'" />';
               } else {
                  echo'<input type="text" name="cPhone" />';
               }    
            ?>  
         </td>
      </tr>     
      <tr>
         <td>Fax Number:</td>
         <td>
            <?php
               if ($_POST['faxNumber'] == true) {
                  echo'<input type="text" name="faxNumber" value="'.$_POST['faxNumber'].'" />';
               } else {
                  echo'<input type="text" name="faxNumber" />';
               }    
            ?>           
         </td>
      </tr>
      <tr>
         <td>Company Address:</td>
         <td>
            <?php
               if ($_POST['companyAddress'] == true) {
                  echo'<input type="text" name="companyAddress" value="'.$_POST['companyAddress'].'" />';
               } else {
                  echo'<input type="text" name="companyAddress" />';
               }    
            ?>           
         </td>
      </tr>
      <tr>
         <td>City:</td>
         <td>
            <?php
               if ($_POST['city'] == true) {
                  echo'<input type="text" name="city" value="'.$_POST['city'].'" />';
               } else {
                  echo'<input type="text" name="city" />';
               }    
            ?>           
         </td>
      </tr>  
      <tr>
         <td>State:</td>
         <td>
            <?php
               if ($_POST['state'] == true) {
                  echo'<input type="text" name="state" value="'.$_POST['state'].'" />';
               } else {
                  echo'<input type="text" name="state" />';
               }    
            ?>           
         </td>        
      </tr>
      <tr>
         <td>Zip Code:</td>
         <td>
            <?php
               if ($_POST['zipCode'] == true) {
                  echo'<input type="text" name="zipCode" value="'.$_POST['zipCode'].'" />';
               } else {
                  echo'<input type="text" name="zipCode" />';
               }    
            ?>           
         </td>        
      </tr>
      <tr>
         <td>Fed Tax ID:</td>
         <td>
            <?php
               if ($_POST['fedTaxId'] == true) {
                  echo'<input type="text" name="fedTaxId" value="'.$_POST['fedTaxId'].'" />';
               } else {
                  echo'<input type="text" name="fedTaxId" />';
               }    
            ?>           
         </td>        
      </tr>
      <tr>
         <td>Owner's Name:</td>
         <td>
            <?php
               if ($_POST['ownersName'] == true) {
                  echo'<input type="text" name="ownersName" value="'.$_POST['ownersName'].'" />';
               } else {
                  echo'<input type="text" name="ownersName" />';
               }    
            ?>           
         </td>        
      </tr>
      <tr>
         <td>E-Commerce Manager (if different from above):</td>
         <td>
            <?php
               if ($_POST['eCommerceManager'] == true) {
                  echo'<input type="text" name="eCommerceManager" value="'.$_POST['eCommerceManager'].'" />';
               } else {
                  echo'<input type="text" name="eCommerceManager" />';
               }    
            ?>           
         </td>        
      </tr>
      <tr>
         <td>Email Address:</td>
         <td>
            <?php
               if ($_POST['emailAddress'] == true) {
                  echo'<input type="text" name="emailAddress" value="'.$_POST['emailAddress'].'" />';
               } else {
                  echo'<input type="text" name="emailAddress" />';
               }    
            ?>           
         </td>        
      </tr>                                                     
      <tr>
         <td>What service form do you need to submit?</td>
         <td><select name="serviceForm" onChange="document.form2.submit();">
               <option>Select One</option>
               <option>EDI</option>
               <option>Glaxis</option>
               <option>EDI and Glaxis</option>
            </select>  
         </td>
      </tr>
  
<?php 
//depending on what the user chose from the previous drop-down,
//display appropriate fields

switch ($_POST['serviceForm']) {

//if user selected EDI, show these fields
   case 'EDI':
      ?>
      <tr>
         <td colspan="2"> </td>
      </tr>
      <tr>
         <td colspan="2"><strong>EDI Service Request</strong></td>
      </tr>     
      <tr>
         <td>EDI Volume Plan:</td>
         <td><input name="volumePlan" type="checkbox" value="low volume" /> Low Volume (10 or less invoices/month)<br />
            <input name="volumePlan" type="checkbox" value="standard volume" /> Standard Volume (10+ invoices/month)
         </td>
      </tr>
      <tr>
         <td>Do you accept the EDI Terms of Service?</td>
         <td><select name="ediTermsOfService">
               <option>Yes</option>
               <option selected="selected">No</option>
            </select>
         </td>
      </tr>     
      <tr>
         <td>How would you like to pay your monthly fees?</td>
         <td><select name="paymentOptions">
               <option>Check (adds $10/month processing fee)</option>
               <option selected="selected">Direct Debit (E.F.T.)</option>
            </select>  
         </td>
      </tr>
      <tr>
         <td> </td>
        <td valign="top"><input type="submit" name="submit2" value="Send Form" onClick="addon.value = 'go!';"  /></td>
      </tr>  
   </table>
</form>
</body>
</html>
<?php
//end fields for "EDI" choice      
      break;
//if user selected Glaxis, show these fields      
   case 'Glaxis':
      ?>
      <tr>
         <td colspan="2"> </td>
      </tr>     
      <tr>
         <td colspan="2"><strong>Glaxis Service Request</strong></td>
      </tr>     
      <tr>
         <td>Previous Lynx Dispatch Number:</td>
         <td><input type="text" name="lynxDispatch" /></td>
      </tr>
      <tr>
         <td>When would you like to go Live??</td>
         <td><input type="text" name="liveDate" /></td>
      </tr>
      <tr>
         <td>Would you like to setup PPG online ordering?</td>
         <td><select name="ppgOnlineOrdering">
               <option selected="selected">Yes</option>
               <option>No</option>
            </select>
         </td>
      </tr>
      <tr>
         <td>Do you accept the Glaxis Terms of Service?</td>
         <td><select name="glaxisTermsOfService">
               <option>Yes</option>
               <option selected="selected">No</option>
            </select>  
         </td>
      </tr>     
      <tr>
         <td> </td>
        <td valign="top"><input type="submit" name="submit2" value="Send Form" onClick="addon.value = 'go!';" /></td>
      </tr>  
   </table>
</form>
</body>
</html>
<?php
//end fields for "Glaxis" choice   
      break;
//if user selected EDI and Glaxis, show these fields      
   case 'EDI and Glaxis':
      ?>
      <tr>
         <td colspan="2"> </td>
      </tr>     
      <tr>
         <td colspan="2"><strong>EDI Service Request</strong></td>
      </tr>  
      <tr>
         <td>EDI Volume Plan:</td>
         <td><input name="volumePlan" type="checkbox" value="low volume" /> Low Volume (10 or less invoices/month)<br />
            <input name="volumePlan" type="checkbox" value="standard volume" /> Standard Volume (10+ invoices/month)
         </td>
      </tr>
      <tr>
         <td>How would you like to pay your monthly fees?</td>
         <td><select name="paymentOptions">
               <option>Check (adds $10/month processing fee)</option>
               <option selected="selected">Direct Debit (E.F.T.)</option>
            </select>  
         </td>
      </tr>
      <tr>
         <td>Do you accept the EDI Terms of Service?</td>
         <td><select name="termsOfService">
               <option>Yes</option>
               <option selected="selected">No</option>
            </select>
         </td>
      </tr>
      <tr>
      <tr>
         <td colspan="2"> </td>
      </tr>     
         <td colspan="2"><strong>Glaxis Service Request</strong></td>
      </tr>     
      <tr>
         <td>Previous Lynx Dispatch Number:</td>
         <td><input type="text" name="lynxDispatch" /></td>
      </tr>
      <tr>
         <td>When would you like to go Live??</td>
         <td><input type="text" name="liveDate" /></td>
      </tr>
      <tr>
         <td>Would you like to setup PPG online ordering?</td>
         <td><select name="ppgOnlineOrdering">
               <option selected="selected">Yes</option>
               <option>No</option>
            </select>
         </td>
      </tr>
      <tr>
         <td>Do you accept the Glaxis Terms of Service?</td>
         <td><select name="glaxisTermsOfService">
               <option>Yes</option>
               <option selected="selected">No</option>
            </select>  
         </td>
      </tr>        
      <tr>
         <td> </td>
        <td valign="top"><input type="submit" name="submit2" value="Send Form" onClick="addon.value = 'go!';" /></td>
      </tr>  
   </table>
</form>
</body>
</html>
<?php
//end fields for EDI and Glaxis   
      break;
   default:
      ?>
     
         </table>
</form>
</body>
</html>
<?php
}               

}
?>

 

My echo statement is working after the form is submitted, but the messages aren't sending (that i can tell) i've been testing with my yahoo email account but haven't been getting anything... What am i overlooking?

 

thanks in advance!

 

Link to comment
Share on other sites

first tool in debugging php is your echo statement.

 

how do I know that the mail function is even getting called?  well let's place echo statements there to find out!

 

<?php

//if the submit button is pressed
   if (isset($_POST['submit2'])) {
      //set variables from form data
      $name = htmlspecialchars($_POST['cName']);
      $phone = htmlspecialchars($_POST['cPhone']);
      $fax = htmlspecialchars($_POST['faxNumber']);
      $address = htmlspecialchars($_POST['companyAddress']);
      $city = htmlspecialchars($_POST['city']);
      $state = htmlspecialchars($_POST['state']);
      $zip = htmlspecialchars($_POST['zipCode']);
      $fedTaxId = htmlspecialchars($_POST['fedTaxId']);
      $oName = htmlspecialchars($_POST['ownersName']);
      $eCommerceManager = htmlspecialchars($_POST['eCommerceManager']);
      $email = htmlspecialchars($_POST['emailAddress']);
      $whatForm = htmlspecialchars($_POST['serviceForm']);
   //EDI variables   
      $volume = htmlspecialchars($_POST['volumePlan']);
      $ediTerms = htmlspecialchars($_POST['ediTermsOfService']);
      $ediPayment = htmlspecialchars($_POST['paymentOptions']);
      
   //Glaxis Variables
      $dispatch = htmlspecialchars($_POST['lynxDispatch']);
      $liveDate = htmlspecialchars($_POST['liveDate']);
      $ppgSetup = htmlspecialchars($_POST['ppgOnlineOrdering']);
      $glaxisTerms = htmlspecialchars($_POST['glaxisTermsOfService']);
      
      $ediMsg = "Another customer has signed up for EDI.\n\nCompany Name: $cName\nPhone: $cPhone\nFax: $fax\nAddress: $address\nCity: $city\nState: $state\nZip: $zip\nFed Tax Id: $fedTaxId\nOwners Name:$oName\neCommerce Manager: $eCommerceManager\nEmail: $email\n\nVolume Plan: $volume\nAgree to Terms: $ediTerms\nEDI Payment Type: $ediPayment\n";
      
  $glaxisMsg = "Another Customer has signed up for Glaxis.\n\nCompany Name: $cName\nPhone: $cPhone\nFax: $fax\nAddress: $address\nCity: $city\nState: $state\nZip: $zip\nFed Tax Id: $fedTaxId\nOwners Name:$oName\neCommerce Manager: $eCommerceManager\nEmail: $email\n\nPrevious Dispatch Number: $dispatch\nLive Date: $liveDate\nPPG Setup: $ppgSetup\nAgree to Terms: $glaxisTerms\n";
  
   switch ($_POST['serviceForm']) {
      case 'EDI':
      	echo 'EDI email sent!';
         //mail ("myEmailAddress1@yahoo.com","EDI Service request form", "$ediMsg");
         break;

      case 'Glaxis':
      	echo 'Glaxis email sent!';
         //mail("myEmailAddress2@yahoo.com@mainstreetcomp.com", "Glaxis Service request form", "$glaxisMsg");         
         break;      

      case 'EDI and Glaxis':
      	echo 'EDI and Glaxis email sent!';
         //mail ("myEmailAddress1@yahoo.com", "EDI Service request form", "$ediMsg");
         //mail("myEmailAddress2@yahoo.com", "Glaxis Service request form", "$glaxisMsg");    
         break;
   }

               
         //tell user that form has been submitted
         //and to check for confirmation
         echo '<p align="center">'."Your form has been submitted. Check your inbox for a confirmation message.".'</p>';
      }   else {   //if submit has not been pressed, display form 
   
?>  

<html>
<head></head>
<body>
<form name="form2" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
   <table border="0" cellspacing="0" cellpadding="2">
      <tr>
         <td>Company Name:</td>
         <td>
            <?php
            //if name has been filled in previously,
            //fill in this field
               if ($_POST['cName'] == true) {
                  echo'<input type="text" name="cName" value="'.$_POST['cName'].'" />';
               } else {
                  echo'<input type="text" name="cName" />';
               }    
            ?>  
         </td>
      </tr>
      <tr>
         <td>Phone Number:</td>
         <td>
            <?php
               if ($_POST['cPhone'] == true) {
                  echo'<input type="text" name="cPhone" value="'.$_POST['cPhone'].'" />';
               } else {
                  echo'<input type="text" name="cPhone" />';
               }    
            ?>  
         </td>
      </tr>     
      <tr>
         <td>Fax Number:</td>
         <td>
            <?php
               if ($_POST['faxNumber'] == true) {
                  echo'<input type="text" name="faxNumber" value="'.$_POST['faxNumber'].'" />';
               } else {
                  echo'<input type="text" name="faxNumber" />';
               }    
            ?>           
         </td>
      </tr>
      <tr>
         <td>Company Address:</td>
         <td>
            <?php
               if ($_POST['companyAddress'] == true) {
                  echo'<input type="text" name="companyAddress" value="'.$_POST['companyAddress'].'" />';
               } else {
                  echo'<input type="text" name="companyAddress" />';
               }    
            ?>           
         </td>
      </tr>
      <tr>
         <td>City:</td>
         <td>
            <?php
               if ($_POST['city'] == true) {
                  echo'<input type="text" name="city" value="'.$_POST['city'].'" />';
               } else {
                  echo'<input type="text" name="city" />';
               }    
            ?>           
         </td>
      </tr>  
      <tr>
         <td>State:</td>
         <td>
            <?php
               if ($_POST['state'] == true) {
                  echo'<input type="text" name="state" value="'.$_POST['state'].'" />';
               } else {
                  echo'<input type="text" name="state" />';
               }    
            ?>           
         </td>        
      </tr>
      <tr>
         <td>Zip Code:</td>
         <td>
            <?php
               if ($_POST['zipCode'] == true) {
                  echo'<input type="text" name="zipCode" value="'.$_POST['zipCode'].'" />';
               } else {
                  echo'<input type="text" name="zipCode" />';
               }    
            ?>           
         </td>        
      </tr>
      <tr>
         <td>Fed Tax ID:</td>
         <td>
            <?php
               if ($_POST['fedTaxId'] == true) {
                  echo'<input type="text" name="fedTaxId" value="'.$_POST['fedTaxId'].'" />';
               } else {
                  echo'<input type="text" name="fedTaxId" />';
               }    
            ?>           
         </td>        
      </tr>
      <tr>
         <td>Owner's Name:</td>
         <td>
            <?php
               if ($_POST['ownersName'] == true) {
                  echo'<input type="text" name="ownersName" value="'.$_POST['ownersName'].'" />';
               } else {
                  echo'<input type="text" name="ownersName" />';
               }    
            ?>           
         </td>        
      </tr>
      <tr>
         <td>E-Commerce Manager (if different from above):</td>
         <td>
            <?php
               if ($_POST['eCommerceManager'] == true) {
                  echo'<input type="text" name="eCommerceManager" value="'.$_POST['eCommerceManager'].'" />';
               } else {
                  echo'<input type="text" name="eCommerceManager" />';
               }    
            ?>           
         </td>        
      </tr>
      <tr>
         <td>Email Address:</td>
         <td>
            <?php
               if ($_POST['emailAddress'] == true) {
                  echo'<input type="text" name="emailAddress" value="'.$_POST['emailAddress'].'" />';
               } else {
                  echo'<input type="text" name="emailAddress" />';
               }    
            ?>           
         </td>        
      </tr>                                                     
      <tr>
         <td>What service form do you need to submit?</td>
         <td><select name="serviceForm" onChange="document.form2.submit();">
               <option>Select One</option>
               <option>EDI</option>
               <option>Glaxis</option>
               <option>EDI and Glaxis</option>
            </select>  
         </td>
      </tr>
  
<?php 
//depending on what the user chose from the previous drop-down,
//display appropriate fields

switch ($_POST['serviceForm']) {

//if user selected EDI, show these fields
   case 'EDI':
      ?>
      <tr>
         <td colspan="2"> </td>
      </tr>
      <tr>
         <td colspan="2"><strong>EDI Service Request</strong></td>
      </tr>     
      <tr>
         <td>EDI Volume Plan:</td>
         <td><input name="volumePlan" type="checkbox" value="low volume" /> Low Volume (10 or less invoices/month)<br />
            <input name="volumePlan" type="checkbox" value="standard volume" /> Standard Volume (10+ invoices/month)
         </td>
      </tr>
      <tr>
         <td>Do you accept the EDI Terms of Service?</td>
         <td><select name="ediTermsOfService">
               <option>Yes</option>
               <option selected="selected">No</option>
            </select>
         </td>
      </tr>     
      <tr>
         <td>How would you like to pay your monthly fees?</td>
         <td><select name="paymentOptions">
               <option>Check (adds $10/month processing fee)</option>
               <option selected="selected">Direct Debit (E.F.T.)</option>
            </select>  
         </td>
      </tr>
      <tr>
         <td> </td>
        <td valign="top"><input type="submit" name="submit2" value="Send Form" onClick="addon.value = 'go!';"  /></td>
      </tr>  
   </table>
</form>
</body>
</html>
<?php
//end fields for "EDI" choice      
      break;
//if user selected Glaxis, show these fields      
   case 'Glaxis':
      ?>
      <tr>
         <td colspan="2"> </td>
      </tr>     
      <tr>
         <td colspan="2"><strong>Glaxis Service Request</strong></td>
      </tr>     
      <tr>
         <td>Previous Lynx Dispatch Number:</td>
         <td><input type="text" name="lynxDispatch" /></td>
      </tr>
      <tr>
         <td>When would you like to go Live??</td>
         <td><input type="text" name="liveDate" /></td>
      </tr>
      <tr>
         <td>Would you like to setup PPG online ordering?</td>
         <td><select name="ppgOnlineOrdering">
               <option selected="selected">Yes</option>
               <option>No</option>
            </select>
         </td>
      </tr>
      <tr>
         <td>Do you accept the Glaxis Terms of Service?</td>
         <td><select name="glaxisTermsOfService">
               <option>Yes</option>
               <option selected="selected">No</option>
            </select>  
         </td>
      </tr>     
      <tr>
         <td> </td>
        <td valign="top"><input type="submit" name="submit2" value="Send Form" onClick="addon.value = 'go!';" /></td>
      </tr>  
   </table>
</form>
</body>
</html>
<?php
//end fields for "Glaxis" choice   
      break;
//if user selected EDI and Glaxis, show these fields      
   case 'EDI and Glaxis':
      ?>
      <tr>
         <td colspan="2"> </td>
      </tr>     
      <tr>
         <td colspan="2"><strong>EDI Service Request</strong></td>
      </tr>  
      <tr>
         <td>EDI Volume Plan:</td>
         <td><input name="volumePlan" type="checkbox" value="low volume" /> Low Volume (10 or less invoices/month)<br />
            <input name="volumePlan" type="checkbox" value="standard volume" /> Standard Volume (10+ invoices/month)
         </td>
      </tr>
      <tr>
         <td>How would you like to pay your monthly fees?</td>
         <td><select name="paymentOptions">
               <option>Check (adds $10/month processing fee)</option>
               <option selected="selected">Direct Debit (E.F.T.)</option>
            </select>  
         </td>
      </tr>
      <tr>
         <td>Do you accept the EDI Terms of Service?</td>
         <td><select name="termsOfService">
               <option>Yes</option>
               <option selected="selected">No</option>
            </select>
         </td>
      </tr>
      <tr>
      <tr>
         <td colspan="2"> </td>
      </tr>     
         <td colspan="2"><strong>Glaxis Service Request</strong></td>
      </tr>     
      <tr>
         <td>Previous Lynx Dispatch Number:</td>
         <td><input type="text" name="lynxDispatch" /></td>
      </tr>
      <tr>
         <td>When would you like to go Live??</td>
         <td><input type="text" name="liveDate" /></td>
      </tr>
      <tr>
         <td>Would you like to setup PPG online ordering?</td>
         <td><select name="ppgOnlineOrdering">
               <option selected="selected">Yes</option>
               <option>No</option>
            </select>
         </td>
      </tr>
      <tr>
         <td>Do you accept the Glaxis Terms of Service?</td>
         <td><select name="glaxisTermsOfService">
               <option>Yes</option>
               <option selected="selected">No</option>
            </select>  
         </td>
      </tr>        
      <tr>
         <td> </td>
        <td valign="top"><input type="submit" name="submit2" value="Send Form" onClick="addon.value = 'go!';" /></td>
      </tr>  
   </table>
</form>
</body>
</html>
<?php
//end fields for EDI and Glaxis   
      break;
   default:
      ?>
     
         </table>
</form>
</body>
</html>
<?php
}               

}
?>

 

now I run this, I choose a form, click send form, but nowhere do I see anything saying an email was sent.  well that's weird, we expected otherwise.  well if we never saw the debug echo message, that means mail() was never even called in the first place!

 

let's trace back our steps to find out where the problem originates.

 

well maybe something is wrong with the switch statement?

 

maybe $_POST['serviceForm'] has no value?  let's check.

 

let's add an echo statement right before the place where $_POST['serviceForm'] is used

 

   echo 'value of serviceForm: ' . $_POST['serviceForm']; // debug
   switch ($_POST['serviceForm']) 

 

I run this, and I see that $_POST['serviceForm'] never equals 'EDI' or 'Glaxis'.

 

Infact, its value is always just 'Select One'.

 

Well we tracked down the first problem, it turns out that $_POST['serviceForm'] has a different value than we expected.  That means we never know which form was chosen!

 

See if you can figure out what can we do to tell php what form it's receiving.

Possibly one way could be placing a hidden input field in each of the addon form, all having the same name, but a value that equals that of the addon form.  then, when you need to determine the form, it should be the value of that hidden input field.

 

Good luck! ;)

Link to comment
Share on other sites

I would even step back 1 further and just verify you have the mail function setup right.

 

Create a 1 line php file with just

 

<?php

mail ("myEmailAddress1@yahoo.com","EDI Service request form", "Message", "FROM:youremail.com");

?>

 

Replace both the TO and FROM emails to a valid email on the domain.

Link to comment
Share on other sites

This is a side note to save you time.

 

To sanitize your whole POST input don't do it like you did try something like

 

<?php
function input_clean($var){
return htmlspecialcharacters(trim($var));
}
foreach($_POST as $key=>$value){
$post_dat[$key] = input_clean($value);
}
?>

You can always add additional affects to the data or you can use the supergobal $_POST to get uncleaned inputs.

Link to comment
Share on other sites

My post would be "first things first" since there is no point in sending variables if the mail function isn't even enabled.

 

Once we get the basic functionality that we need, then we can work on the mail() function, and on enabling it if it's not enabled.

 

He never even got to test it because his code wasn't even reaching the function.

 

My opinion was to fix that first.

 

I think it shouldn't be a question of "is my mail() enabled?" but "do I want to send mail?" and if mail() is not doing anything then then make it send mail.

 

It comes down to opinion and programming style of what should be fixed first.

 

@MainStWebGuy if your server is running Linux it should already have mail() configured.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.