Jump to content

machupicchu

Members
  • Posts

    20
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

machupicchu's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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.
  2. cooldude isn't it true that if our immune system is extremely strong we don't need to sanitize our $_POSTs?
  3. yeah, that would be the next thing to check, but first things first
  4. 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!
  5. max_execution_time I understand is how long the script can run for until it is terminated. if the client loses connection or goes to another page then the script execution is terminated right there in my understanding
  6. are you looking for something like ths: $to = "recipient@example.com"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } Search this forum or Google php email for more examples
  7. do similar like you have here: <select name="serviceForm" onchange="document.form2.submit();"> this seems to work: <input type="submit" name="submit2" value="Send Form" onclick="addon.value = 'go!';"/> you can get to the addon value like this also: document.form2.addon.value, but it seems to be optional. make sure to do this for every submit button that you have, and this being the very first lines of your php: echo $_POST['addon']."!!!!!!"; //test the addon value like this, remove this when everything is working as it should if (isset($_POST['addon'])) { if ($_POST['addon'] == 'go!') { // proccess form, send mail, display thank you message exit; } } I'm glad I've helped you
  8. onchange="document.form2.submit(); and onchange="document.forms['form2'].submit(); seem to do the same thing, the problem was this: <input type="submit" name="submit" value="Send Form" /> it seemed to have been interfering with the above, so notice I added a 2 to the name, <input type="submit" name="submit2" value="Send Form" /> to have this be name something other than submit, and voila, it works.
  9. you could do it like this: in each add on form, create a hidden input: <input type="hidden" name="addon" value=""> then on top of your php code check if this exists if (isset($_POST['addon'])) { if ($_POST['addon'] == 'go!') { // proccess form, send mail, display thank you message exit; ) } // otherwise, just show the form ok so so far, we should be able to change the subforms, but not send the form. to send the form and not break the form selection in this setup, use javascript to change the value of addon to "go!" when submit button is clicked (onclick). hope this helps
  10. <?php //if the submit button is pressed if ($_POST['submit'] == true) { //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']); /*switch statement will go here to send the email to the appropriate administrator */ //tell user that form has been submitted //and to check for confirmation echo "Your form has been submitted. Check your inbox for a confirmation message."; } 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>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>Direct Debit (E.F.T.)</option> </select> </td> </tr> <tr> <td> </td> <td valign="top"><input type="submit" name="submit2" value="Send Form" /></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>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>No</option> </select> </td> </tr> <tr> <td> </td> <td valign="top"><input type="submit" name="submit2" value="Send Form" /></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>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>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>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>No</option> </select> </td> </tr> <tr> <td> </td> <td valign="top"><input type="submit" name="submit2" value="Send Form" /></td> </tr> </table> </form> </body> </html> <?php //end fields for EDI and Glaxis break; default: ?> </table> </form> </body> </html> <?php } } ?> this should fix #1 as for #2 Google php send mail, you'll find many examples
  11. yeah, to demonstrate \n: echo "Line\nBreak"; should output: Line Break (in source of course)
  12. you should use an array for rank, and use a for loop to calculate how many 3's and 7's there are. $rank = array(3, 7, 7, 7); $rank[4] = 7; // user either way to assign values to the array // then to count 3's and 7's use a loop $size = sizeof($rank); $threes = 0; $sevens = 0; for ($i = 0; $i < $size; $i++) { if ($rank[$i] == 3) $threes++; // add 1 to $threes if ($rank[$i] == 7) $threes++; // add 1 to $sevens } echo "Threes = $threes and Sevens = $sevens";
  13. also, next time you should post this in one of the SQL / Database Forums
×
×
  • 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.