PHP - Form Mailer Help Needed!
I'd truly appreciate any help you can give me with the following PHP form mailer. I get the following error: Parse error: syntax error, unexpected T_ELSE in testcontact.php on line 31
Any ideas on how to fix the error? Also, I need to sanitize the data, but I don't understand how to. Everything I've googled doesn't seem to work. Code: [Select] <?php $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $mailinglist = $_POST['mailinglist']; $companyname = $_POST['companyname']; $address = $_POST['address']; $city = $_POST['city']; $zip = $_POST['zip']; $countrycode = $_POST['countrycode']; $areacode = $_POST['areacode']; $citycode = $_POST['citycode']; $number = $_POST['number']; $fcountrycode = $_POST['fcountrycode']; $fareacode = $_POST['fareacode']; $fcitycode = $_POST['fcitycode']; $fnumber = $_POST['fnumber']; $industry = $_POST['industry']; $product = $_POST['product']; $productnumber = $_POST['productnumber']; $comments = $_POST['comments']; if ($mailinglist != yes) $mailinglist = no; $mail_to = 'example@isp.com'; $subject = 'Webform Data'; $body = "First Name: $firstname \n Last Name: $lastname: \n Email: $email \n Mailing List: $mailinglist \n Company Name: $companyname \n Address: $address \n City: $city \n Zip: $zip \n Phone: $countrycode $areacode $citycode $number \n Fax: $fcountrycode $fareacode $fcitycode $fnumber \n Industry: $industry \n Product: $product \n Number of Packaged Products: $productnumber \n Comments/Questions: $commments "; if (isset($_POST['Submit'])) { mail($to, $subject, $body); echo "You will be contacted shortly."; }; ?> <!DOCTYPE html PUBLIC "/W3C/DTD XHTML 1.0 Transitional/EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="main.css" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Contact Us</title> </head> <form action="testcontact.php" method="post">* represents required field<br /> *First Name:<input name="firstname" type="text" maxlength="50" value="<?php echo $_POST['firstname']; ?>" /><br /> *Last Name:<input name="lastname" type="text" maxlength="50" value="<?php echo $_POST['lastname']; ?>" /><br /> *E-mail:<input name="email" type="text" maxlength="50" value="<?php echo $_POST['email']; ?>" /><br /> Join Mailing List(check if yes):<input name="mailinglist" type="checkbox" value="<?php echo $_POST['mailinglist']; ?>"/><br /> Company Name:<input name="companyname" type="text" maxlength="100" value="<?php echo $_POST['companyname']; ?>" /><br /> Address:<input name="address" type="text" maxlength="100" value="<?php echo $_POST['address']; ?>" /><br /> City:<input name="city" type="text" maxlength="100" value="<?php echo $_POST['city']; ?>" /><br /> Zip<input name="zip" type="text" maxlength="10" value="<?php echo $_POST['zip']; ?>" /><br /> Phone Number:<input name="countrycode" type="text" size="3" maxlength="3" value="<?php echo $_POST['countrycode']; ?>" />-<input name="areacode" type="text" size="3" maxlength="3" value="<?php echo $_POST['areacode']; ?>" />-<input name="citycode" type="text" size="3" maxlength="3" value="<?php echo $_POST['citycode']; ?>" />-<input name="number" type="text" size="4" maxlength="4" value="<?php echo $_POST['number']; ?>" /><br /> Fax:<input name="fcountrycode" type="text" size="3" maxlength="3" value="<?php echo $_POST['fcountrycode']; ?>" />-<input name="fareacode" type="text" size="3" maxlength="3" value="<?php echo $_POST['fareacode']; ?>" />-<input name="fcitycode" type="text" size="3" maxlength="3" value="<?php echo $_POST['fcitycode']; ?>" />-<input name="fnumber" type="text" size="4" maxlength="4" value="<?php echo $_POST['fnumber']; ?>" /><br /> Industry:<input name="industry" type="text" maxlength="50" value="<?php echo $_POST['industry']; ?>" /><br /> Product Packaged:<input name="product" type="text" maxlength="100" value="<?php echo $_POST['product']; ?>" /><br /> Number of Packaged Products:<input name="productnumber" type="text" maxlength="100" value="productnumber" /><br /> Comments/Questions:<br /><textarea name="comments" rows="5" cols="50" maxlength="10000"><?php echo $_POST['comments']; ?></textarea><br /> <input type="submit" value="submit" /> </form> </body> </html> Thanks! Similar Tutorialsi want to send products to resellers so they can show it to their clients but to show it not on my domain i thought of sending an email with html designed as my product details page BUT the problem here is that the forwarding action by my reseller will ruin the html mailer i thought of using php to pdf any other solutions thanks Hi guyz. I need to create a Booking System using form. same like this: https://www.theorytest.net/book-your-theory-test.php Information will be sent to Email. I know the form creation and sending to Email as well! But i this form is divided into pages how can i collect information that will be available to send through email at the end. (when user will complete this booking) Waiting for your reply Thanks Hello all! First post. Wondering if anyone could help me out with a problem I've been having with a form mailer... I had it working at one point in time, but now not so much. I'm using Securimage as a captcha The file is email.php My problem is... When you type in the code wrong, it tells you its wrong. When you type the code right, it redirects to thank.html, which is correct...but never sends the mail! Am I missing something obvious? Here's my code: Code: [Select] <?php session_start(); //include_once $_SERVER['DOCUMENT_ROOT'] . '/coaxicom_email_original/securimage/securimage.php'; include_once('securimage/securimage.php'); $securimage = new Securimage(); if( isset($_POST['submit'])) { if ($securimage->check($_POST['captcha_code']) == false) { // the code was incorrect // you should handle the error so that the form processor doesn't continue // or you can use the following code if there is no validation or you do not know how echo "The security code entered was incorrect.<br /><br />"; echo "<a href='email.php'>Please click this link to back and try again.</a>"; exit; } //Data $contact1 = $_POST['contact1']; $company1 = $_POST['company1']; $email1 = $_POST['email1']; $phone1 = $_POST['phone1']; $country1 = $_Post['country1']; $address1 = $_POST['address1']; $city1 = $_POST['city1']; $state1 = $_POST['state1']; $zip1 = $_POST['zip1']; $contact2 = $_POST['contact2']; $company2 = $_POST['company2']; $email2 = $_POST['email2']; $phone2 = $_POST['phone2']; $country2 = $_Post['country2']; $address2 = $_POST['address2']; $city2 = $_POST['city2']; $state2 = $_POST['state2']; $zip2 = $_POST['zip2']; $contact3 = $_POST['contact3']; $company3 = $_POST['company3']; $email3 = $_POST['email3']; $phone3 = $_POST['phone3']; $country3 = $_Post['country3']; $address3 = $_POST['address3']; $city3 = $_POST['city3']; $state3 = $_POST['state3']; $zip3 = $_POST['zip3']; $contact4 = $_POST['contact4']; $company4 = $_POST['company4']; $email4 = $_POST['email4']; $phone4 = $_POST['phone4']; $country4 = $_Post['country4']; $address4 = $_POST['address4']; $city4 = $_POST['city4']; $state4 = $_POST['state4']; $zip4 = $_POST['zip4']; $contact5 = $_POST['contact5']; $company5 = $_POST['company5']; $email5 = $_POST['email5']; $phone5 = $_POST['phone5']; $country5 = $_Post['country5']; $address5 = $_POST['address5']; $city5 = $_POST['city5']; $state5 = $_POST['state5']; $zip5 = $_POST['zip5']; $contact6 = $_POST['contact6']; $company6 = $_POST['company6']; $email6 = $_POST['email6']; $phone6 = $_POST['phone6']; $country6 = $_Post['country6']; $address6 = $_POST['address6']; $city6 = $_POST['city6']; $state6 = $_POST['state6']; $zip6 = $_POST['zip6']; $contact7 = $_POST['contact7']; $company7 = $_POST['company7']; $email7 = $_POST['email7']; $phone7 = $_POST['phone7']; $country7 = $_Post['country7']; $address7 = $_POST['address7']; $city7 = $_POST['city7']; $state7 = $_POST['state7']; $zip7 = $_POST['zip7']; $contact8 = $_POST['contact8']; $company8 = $_POST['company8']; $email8 = $_POST['email8']; $phone8 = $_POST['phone8']; $country8 = $_Post['country8']; $address8 = $_POST['address8']; $city8 = $_POST['city8']; $state8 = $_POST['state8']; $zip8 = $_POST['zip8']; $body = <<<EOD <br /><hr><br /> Company: $company1 <br /> Contact: $contact1 <br /> Email: $email1 <br /> Phone: $phone1 <br /> Country: $country1 <br /> Address: $address1 <br /> City: $city1 <br /> State: $state1 <br /> Zip: $zip1 <br /> <br /><hr><br /> Company: $company2 <br /> Contact: $contact2 <br /> Email: $email2 <br /> Phone: $phone2 <br /> Country: $country2 <br /> Address: $address2 <br /> City: $city2 <br /> State: $state2 <br /> Zip: $zip2 <br /> <br /><hr><br /> Company: $company3 <br /> Contact: $contact3 <br /> Email: $email3 <br /> Phone: $phone3 <br /> Country: $country3 <br /> Address: $address3 <br /> City: $city3 <br /> State: $state3 <br /> Zip: $zip3 <br /> <br /><hr><br /> Company: $company4 <br /> Contact: $contact4 <br /> Email: $email4 <br /> Phone: $phone4 <br /> Country: $country4 <br /> Address: $address4 <br /> City: $city4 <br /> State: $state4 <br /> Zip: $zip4 <br /> <br /><hr><br /> Company: $company5 <br /> Contact: $contact5 <br /> Email: $email5 <br /> Phone: $phone5 <br /> Country: $country5 <br /> Address: $address5 <br /> City: $city5 <br /> State: $state5 <br /> Zip: $zip5 <br /> <br /><hr><br /> Company: $company6 <br /> Contact: $contact6 <br /> Email: $email6 <br /> Phone: $phone6 <br /> Country: $country6 <br /> Address: $address6 <br /> City: $city6 <br /> State: $state6 <br /> Zip: $zip6 <br /> <br /><hr><br /> Company: $company7 <br /> Contact: $contact7 <br /> Email: $email7 <br /> Phone: $phone7 <br /> Country: $country7 <br /> Address: $address7 <br /> City: $city7 <br /> State: $state7 <br /> Zip: $zip7 <br /> <br /><hr><br /> Company: $company8 <br /> Contact: $contact8 <br /> Email: $email8 <br /> Phone: $phone8 <br /> Country: $country8 <br /> Address: $address8 <br /> City: $city8 <br /> State: $state8 <br /> Zip: $zip8 <br /> <br /><hr><br /> EOD; //Subject and Email $emailSubject = 'This is my subject'; $webMaster = 'example@gmail.com'; $headers = "From: Example\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster,$emailSubject,$body,$headers); header( "Location: thank.html" ); } else { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head></head> <body> <div id="wrapper"> <div id="main"> <div id="fContainer"> <form action="email.php" method="post" > <div class="fbox" id="f1"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company1" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact1" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email1" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone1" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country1" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address1" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city1" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state1" /></div></div> <br /> <!-- end #f1 --></div> <div class="fbox" id="f2"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company2" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact2" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email2" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone2" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country2" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address2" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city2" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state2" /></div></div> <br /> <!-- end #f2 --></div> <div class="fbox" id="f3"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company3" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact3" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email3" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone3" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country3" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address3" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city3" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state3" /></div></div> <br /> <!-- end #f3 --></div> <div class="fbox" id="f4"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company4" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact4" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email4" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone4" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country4" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address4" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city4" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state4" /></div></div> <br /> <!-- end #f4 --></div> <div class="fbox" id="f5"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company5" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact5" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email5" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone5" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country5" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address5" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city5" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state5" /></div></div> <br /> <!-- end #f5 --></div> <div class="fbox" id="f6"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company6" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact6" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email6" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone6" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country6" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address6" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city6" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state6" /></div></div> <br /> <!-- end #f6 --></div> <div class="fbox" id="f7"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company7" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact7" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email7" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone7" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country7" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address7" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city7" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state7" /></div></div> <br /> <!-- end #f7 --></div> <div class="fbox" id="f8"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company8" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact8" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email8" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone8" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country8" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address8" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city8" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state8" /></div></div> <br /> <!-- end #f8 --></div> <div id="fCaptcha"> <div id="codeLabel">Security Code<span class="red">*</span>:</div> <div id="img"><img id="captcha" src="securimage/securimage_show.php" alt="CAPTCHA Image" /></div> <div id="text"> <input type="text" name="captcha_code" size="10" maxlength="6" /></div> <!-- end #fCaptcha --></div> <div id="fCaptchaBox"></div> <div id="fSubmit"><input type="submit" name="submit" value="Email This Form" /></div> </form> <!-- end #fContainer --></div> <!-- end #main --></div> <!-- end #wrapper --></div> </body> </html> <?php } ?> hi, I'm a newb. barely getting my feet wet in php after years of wanting to. I wrote this script following a youtube tutorial and it all made sense as I coded it.... so as far as I'm familiar with the little bit of coding, my script should work. actually it works. I get an email but with no data??? I can't get the script to gather the info and send it along with the email. not sure why as all seems in place.any help here would be greatly appreciated. thank you. here is the script... <?php /*subject and email variables */ $emailSubject = 'edson vehicle order form'; $webMaster = 'order@edsonvehicleremarketing.com'; /*gathering data variables*/ $modelyear = $_POST['modelyear']; $vehiclemake = $_POST['vehiclemake']; $vehiclemodel = $_POST['vehiclemodel']; $colors = $_POST['colors']; $notcolors = $_POST['notcolors']; $options = $_POST['options']; $descriptions = $_POST['descriptions']; $tradeinyear = $_POST['tradeinyear']; $tradeinmake = $_POST['tradeinmake']; $tradeinmodel = $_POST['tradeinmodel']; $miles = $_POST['miles']; $tradeincolor = $_POST['tradeincolor']; $conditionofcar = $_POST['conditionofcar']; $damage = $_POST['damage']; $lienholder = $_POST['lienholder']; $name = $_POST['name']; $homephone = $_POST['homephone']; $workphone = $_POST['workphone']; $cellphone = $_POST['cellphone']; $besttimetoreach = $_POST['besttimetoreach']; $bestwaytocontact = $_POST['bestwaytocontact']; $paymenttype = $_POST['paymenttype']; $howdidyoulocateus = $_POST['howdidyoulocateus']; $pickuptime = $_POST['pickuptime']; $comments = $_POST['comments']; $body - <<<EOD <br><hr><br> Model year: $modelyear <br> Vehicle make: $vehiclemake <br> Vehicle model: $vehiclemodel <br> Vehicle colors: $colors <br> Colors not considered: $notcolors <br> Options desired: $options <br> Descriptions: $descriptions <br> Trade in year: $tradeinyear <br> Trade in make: $tradeinmake <br> Trade in model: $tradeinmodel <br> miles: $miles <br> Trade in color: $tradeincolor <br> Condition of car: $conditionofcar <br> Damage: $damage <br> Lienholder: $lienholder <br> Name: $name <br> Home phone: $homephone <br> Work phone: $workphone <br> Cell phone: $cellphone <br> Best time to reach: $besttimetoreach <br> Best way to contact: $bestwaytocontact <br> Payment type: $paymenttype <br> How did you locate us: $howdidyoulocateus <br> Pick up time: $pickuptime <br> Comments: $comments <br> EOD; $headers = "From $name\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headrers); /* results rendered as html */ $theResults = <<<EOD <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Edson Vehicle Remarketing</title> <style type="text/css"> body { background-color: #000; background-image: url(); background-repeat: repeat-x; margin-bottom: 0px; } .orderform { left: auto; right: auto; margin-top: 25px; } #htmlforphp { width: auto; height: 300px; text-align: center; padding-top: 250px; padding-right: 50px; font-size: 20px; } </style> <link href="css/layout.css" rel="stylesheet" type="text/css" /> <style type="text/css"> a:link { text-decoration: none; color: #000; } a:visited { text-decoration: none; color: #000; } a:hover { text-decoration: none; color: #333; } a:active { text-decoration: none; color: #666; } #wrapper #bodyArea .orderform { padding-left: 100px; padding-right: 100px; position: relative; color: #999; } </style> </head> <body> <div id="wrapper"> <div id="logo"><img src="images/banner.gif" width="800" height="110" alt="edson vehicle remarketing" /></div> <div id="navigation"><strong><a href="index.html">HOME</a> | <a href="inventory.html">INVENTORY</a> | <a href="financing.php">FINANCING</a> | <a href="orderform.html">ORDER FORM</a> | <a href="directions.html">DIRECTIONS</a> | <a href="contactus.html">CONTACT US</a></strong></div> <div id="bodyArea"> <div id="htmlforphp">Thank you for your interest.<br />Edson vehicle remarketinng will find you the best car possible!</div> </div> <div id="footer"><a href="index.html">home</a> | <a href="inventory.html">inventory</a> | <a href="financing.php">financing</a> | <a href="orderform.html">order form</a> | <a href="directions.html">directions</a> | <a href="contactus.html">contact us</a></div> </div> </body> </html> EOD; echo "$theResults"; ?> Hi All, Need your help with the situation I am stuck in. I have created a HTML Form and using PHP file saving that data into database. But now I want to send out an generic email to each visitor who fill the form. Attaching the code of html form and php database. It would be highly appreaciated if you can help me in updating the php file with which I can send an auto email.
HTML Form - <!-- .contact-form --> <div class="contact-form"> <form id="contact-form" class="validate-form" method="post" action="send.php"> <!-- enter mail subject here --> <input type="hidden" name="subject" id="subject" value="You have a new message from Smeet Mehta!"> <p> <label for="name">NAME</label> <input type="text" name="name" id="name" class="required"> </p> <p> <label for="email">EMAIL</label> <input type="text" name="email" id="email" class="required email"> </p> <p> <label for="message">MESSAGE</label> <textarea name="message" id="message" class="required"></textarea> </p> <p> <button class="submit" control-id="ControlId-5">Send</button> </p> </form> </div> <!-- .contact-form -->
PHP Code - <?php $subject = filter_input(INPUT_POST, 'subject'); $name = filter_input(INPUT_POST, 'name'); $email = filter_input(INPUT_POST, 'email'); $message = filter_input(INPUT_POST, 'message'); $host = "localhost"; $username = "root"; $password = ""; $dbname = "contact"; $conn = new mysqli ($host, $username, $password, $dbname); if (mysqli_connect_error()){ die('Connection Error('.mysqli_connect_error().')'.mysqli_connect_error()); } else { $sql = "INSERT INTO form (subject, name, email, message) values ('$subject', '$name', '$email', '$message')" ; if ($conn->query($sql)){ header("Refresh:0; url=index.html"); } else{ echo "Error: ".$sql ." ".$conn->error; } $conn->close(); } ?> Please Help Edited July 27 by Barandcode tags added Hi guys, I'm new to this forum, I need some help with a contact form, I've done ones before.. but I need someone to make me a mailer.php file that would suffice this framework for my html coded form. The form also has css, which I can't give out, but I'm sure you coders don't really need to see the form. Basically I would also want this progress bar to work correctly. I can't see to get it all right. Code: [Select] <div id="maincontent"> <h2>Contact</h2> <div id="main_form"> <p id="loadBar" style="display:none;"> <strong>Sending Email. Hold on just a sec…</strong><br /> <img src="images/loading.gif" alt="Loading..." title="Sending Email" /> </p> <p id="emailSuccess" style="display:none;"> <strong style="color:red;">Success! Your Email has been sent.</strong> </p> <div id="contactFormArea"> <form action="mailer.php" method="post" id="cForm"> <fieldset> <label for="posName">Name:</label> <input class="input-textarea" type="text" size="25" name="posName" id="posName" /><br /><br /> <label for="posEmail">Email:</label> <input class="input-textarea" type="text" size="25" name="posEmail" id="posEmail" /><br /><br /> <label for="posRegard">Subject:</label> <input class="input-textarea" type="text" size="25" name="posRegard" id="posRegard" /><br /><br /> <label for="posText">Message:</label> <textarea cols="50" rows="5" name="posText" id="posText"></textarea><br /><br /> <label for="selfCC"> <!--<input type="checkbox" name="selfCC" id="selfCC" value="send" /> Send CC to self--> <input type="hidden" name="selfCC" id="selfCC" value="xxx" /> </label> <label> <input class="input-submit" type="submit" name="sendContactEmail" id="sendContactEmail" value=" Send Email " /> </label> </fieldset> </form> </div> </div> Thanks in advance, Andy I am attempting to build a SMTP contact form however when my form is submitted i get an error message from google that says my account has been accessed. Also will this work fine with JS form validation? Thank you in advance.
<?php if(isset($_POST['submit'])) { $message= 'Full Name: '.$_POST['fullname'].'<br /> Email: '.$_POST['emailid'].'<br /> Comments: '.$_POST['comments'].' '; require "PHPMailer-master/class.phpmailer.php"; //include phpmailer class // Instantiate Class $mail = new PHPMailer(); // Set up SMTP $mail->IsSMTP(); // Sets up a SMTP connection $mail->SMTPAuth = true; // Connection with the SMTP does require authorization $mail->SMTPSecure = "ssl"; // Connect using a TLS connection $mail->Host = "smtp.gmail.com"; //Gmail SMTP server address $mail->Port = 465; //Gmail SMTP port $mail->Encoding = '7bit'; // Authentication $mail->Username = "me@gmail.com"; //Gmail address $mail->Password = "pass"; // Gmail password // Compose $mail->SetFrom($_POST['emailid'], $_POST['fullname']); $mail->AddReplyTo($_POST['emailid'], $_POST['fullname']); $mail->Subject = "New Contact Form Enquiry"; // Subject $mail->MsgHTML($message); // Send To $mail->AddAddress("me@gmail.com", "Mr. Example"); // Where to send it - Recipient $result = $mail->Send(); // Send! unset($mail); } ?> Can anyone find a glaring error with my contact form or my mailer? I previously had a form that was working (sending the email through) but stopped working. It was more complicated before and had a recaptcha in it. I've been troubleshooting this for awhile now and can't figure out what's happening. I've stripped it down to just the basics. I'm stumped because I am correctly redirected to the confirmation.html page, yet no email has come through. I even put a simple test file (mailertest.php) on the server. The file is found and echoes "Mail sent", but no email is received. I contacted the host and they claim that things are fine on their end with the PHP mailer and it must be a problem in my code. As a newbie, I don't doubt that I'm doing something wrong, but I can't figure it out!
I'm attaching three files. Contact.php, contact_mailer.php and my test PHP file called mailertest.php. I'd appreciate any help that anyone can offer.
Attached Files
mailertest.php 99bytes
3 downloads
contact_mailer.php 608bytes
1 downloads
contact.php 7.55KB
0 downloads Hi I am new to php and I have a login form for users that works ok with a mysql database table for users. The problem I have is that it only takes all loggedin users to the same page and I want to take logged in users to their own page. I should have no more than 5 users at anyone time and for example I will call them simply user1, user2, user3, user4 and user 5. I want user1 to go to user1.php, user2 to go to user2.php and so on. The login.php code is as follows, can someone please tell me in laymans terms how to change it to accommodate this: Code: [Select] <?php include 'dbc.php'; $err = array(); foreach($_GET as $key => $value) { $get[$key] = filter($value); //get variables are filtered. } if ($_POST['doLogin']=='Login') { foreach($_POST as $key => $value) { $data[$key] = filter($value); // post variables are filtered } $user_email = $data['usr_email']; $pass = $data['pwd']; if (strpos($user_email,'@') === false) { $user_cond = "user_name='$user_email'"; } else { $user_cond = "user_email='$user_email'"; } $result = mysql_query("SELECT `id`,`pwd`,`full_name`,`approved`,`user_level` FROM users WHERE $user_cond AND `banned` = '0' ") or die (mysql_error()); $num = mysql_num_rows($result); // Match row found with more than 1 results - the user is authenticated. if ( $num > 0 ) { list($id,$pwd,$full_name,$approved,$user_level) = mysql_fetch_row($result); if(!$approved) { //$msg = urlencode("Account not activated. Please check your email for activation code"); $err[] = "Account not activated. Please check your email for activation code"; //header("Location: login.php?msg=$msg"); //exit(); } //check against salt if ($pwd === PwdHash($pass,substr($pwd,0,9))) { if(empty($err)){ // this sets session and logs user in session_start(); session_regenerate_id (true); //prevent against session fixation attacks. // this sets variables in the session $_SESSION['user_id']= $id; $_SESSION['user_name'] = $full_name; $_SESSION['user_level'] = $user_level; $_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']); //update the timestamp and key for cookie $stamp = time(); $ckey = GenKey(); mysql_query("update users set `ctime`='$stamp', `ckey` = '$ckey' where id='$id'") or die(mysql_error()); //set a cookie if(isset($_POST['remember'])){ setcookie("user_id", $_SESSION['user_id'], time()+60*60*24*COOKIE_TIME_OUT, "/"); setcookie("user_key", sha1($ckey), time()+60*60*24*COOKIE_TIME_OUT, "/"); setcookie("user_name",$_SESSION['user_name'], time()+60*60*24*COOKIE_TIME_OUT, "/"); } header("Location: myaccount.php"); } } else { //$msg = urlencode("Invalid Login. Please try again with correct user email and password. "); $err[] = "Invalid Login. Please try again with correct user email and password."; //header("Location: login.php?msg=$msg"); } } else { $err[] = "Error - Invalid login. No such user exists"; } } ?> Hi everyone! Newbie in PHP Im trying unsuccessfully to get php mailer to send mail to a specific email address I dont know if its even possible. I have a form in flash but it uses php. Now all the emails that get sent from the site go to a ddatabase and then are posted in the site admin area under contact Im assuming its php mail that send sends these emails. What i would like is it to send those emails to a specific address. I downloaded the latest phpmailer for php 4 since thats what the server is running. Any help would be appreciated. Here ive attached the current mailer file. THANKS. PEACE I got this PHP mailer as part of a template I downloaded. It seems to work for everyone except for me. I would love some help. I followed their documentation as for what to change and you will see it documented as to the area I was supposed to change and the part I should not touch. I only updated the top portion but for some reason its not working. When I tested the contact page after uploading the site, I used one of my own email addresses to send an email to the destination address of my company. I get a response email in the account that I fill in the email field with, but the actual destination email account for my business never gets the message that the customer/I write. This is the code I have so far, so could you please tell me whats wrong. Thanks! Sorry I cant upload files at work. Code: [Select] <?php error_reporting(E_WARNING); $variables = array( "subject" => $_POST["sender_subject"], "message" => $_POST["sender_message"], "name" => $_POST["sender_name"], "email" => $_POST["sender_email"], ); $conf = array( "notification_email" => array( "enable" => true, "to" => "shane@photographybysp.com", "to_name" => "Photography by Shane Padgett", "from" => "{EMAIL}", "from_name" => "{NAME}", "subject" => "New Message: {SUBJECT}", "type" => "html", "message" => <<<EOD <p>Someone new is interested!</p> <p> Email: {EMAIL}<br> Subject: {SUBJECT}<br> {MESSAGE} </p> EOD ), "autoresponder_email" => array( "enable" => true, "from" => "shane@photographybysp.com", "from_name" => "Photography by Shane Padgett", "to" => "{EMAIL}", "to_name" => "{NAME}", "subject" => "Thank you for your message", "type" => "html", "message" => <<<EOD <p>Your message has been recieved!</p> <p> Email: {EMAIL}<br> Subject: {SUBJECT}<br> {MESSAGE} </p> EOD ), ); ## starting the actual code, you have nothing else to configure from this point forward. function SendMail() { $params = AStripSlasshes(func_get_args()); //check to see the numbers of the arguments switch (func_num_args()) { case 1: $email = $params[0]; $vars = array(); break; case 2: $email = $params[0]; $vars = $params[1]; break; case 3: $to = $params[0]; $email = $params[1]; $vars = $params[2]; break; case 4: $to = $params[0]; $to_name = $params[1]; $email = $params[2]; $vars = $params[3]; break; } if ($email["email_status"] == 1) { return true; } $msg = new CTemplate(stripslashes($email["email_body"]) , "string"); $msg = $msg->Replace($vars); $sub = new CTemplate(stripslashes($email["email_subject"]) , "string"); $sub = $sub->Replace($vars); $email["email_from"] = new CTemplate(stripslashes($email["email_from"]) , "string"); $email["email_from"] = $email["email_from"]->Replace($vars); $email["email_from_name"] = new CTemplate(stripslashes($email["email_from_name"]) , "string"); $email["email_from_name"] = $email["email_from_name"]->Replace($vars); if (!$email["email_reply"]) $email["email_reply"] = $email["email_from"]; if (!$email["email_reply_name"]) $email["email_reply_name"] = $email["email_from_name"]; //prepare the headers $headers = "MIME-Version: 1.0\r\n"; if ($email["email_type"] == "html") $headers .= "Content-type: text/html\r\n"; else $headers .= "Content-type: text/plain\r\n"; //prepare the from fields if (!$email["email_hide_from"]) { $headers .= "From: {$email[email_from_name]}<{$email[email_from]}>\r\n"; $headers .= "Reply-To: {$email[email_reply_name]}<{$email[email_reply]}>\r\n"; } $headers .= $email["headers"]; if (!$email["email_hide_to"]) { return @mail($email["email_to"] , $sub, $msg,$headers); } else { } $headers .= "X-Mailer: PHP/" . phpversion(); return mail($to, $sub, $msg,$headers); } function AStripSlasshes($array) { if (is_array($array)) foreach ($array as $key => $item) if (is_array($item)) $array[$key] = AStripSlasshes($item); else $array[$key] = stripslashes($item); else return stripslashes($array); return $array; } $_TSM = array(); class CTemplate { /** * template source data * * @var string * * @access private */ var $input; /** * template result data * * @var string * * @access public */ var $output; /** * template blocks if any * * @var array * * @access public */ var $blocks; /** * constructor which autoloads the template data * * @param string $source source identifier; can be a filename or a string var name etc * @param string $source_type source type identifier; currently file and string supported * * @return void * * @acces public */ function CTemplate($source,$source_type = "file") { $this->Load($source,$source_type); } /** * load a template from file. places the file content into input and output * also setup the blocks array if any found * * @param string $source source identifier; can be a filename or a string var name etc * @param string $source_type source type identifier; currently file and string supported * * @return void * * @acces public */ function Load($source,$source_type = "file") { switch ($source_type) { case "file": $this->template_file = $source; // get the data from the file $data = GetFileContents($source); //$data = str_Replace('$','\$',$data); break; case "rsl": case "string": $data = $source; break; } // blocks are in the form of <!--S:BlockName-->data<!--E:BlockName--> preg_match_all("'<!--S\:.*?-->.*?<!--E\:.*?-->'si",$data,$matches); // any blocks found? if (count($matches[0]) != 0) // iterate thru `em foreach ($matches[0] as $block) { // extract block name $name = substr($block,strpos($block,"S:") + 2,strpos($block,"-->") - 6); // cleanup block delimiters $block = substr($block,9 + strlen($name),strlen($block) - 18 - strlen($name) * 2); // insert into blocks array $this->blocks["$name"] = new CTemplate($block,"string"); } // cleanup block delimiters and set the input/output $this->input = $this->output = preg_replace(array("'<!--S\:.*?-->(\r\n|\n|\n\r)'si","'<!--E\:.*?-- >(\r\n|\n|\n\r)'si"),"",$data); } /** * replace template variables w/ actual values * * @param array $vars array of vars to be replaced in the form of "VAR" => "val" * @param bool $clear reset vars after replacement? defaults to TRUE * * @return string the template output * * @acces public */ function Replace($vars,$clear = TRUE) { if (is_array($vars)) { foreach ($vars as $key => $var) { if (is_array($var)) { unset($vars[$key]); } } } // init some temp vars $patterns = array(); $replacements = array(); // build patterns and replacements if (is_array($vars)) // just a small check foreach ($vars as $key => $val) { $patterns[] = "/\{" . strtoupper($key) . "\}/"; //the $ bug $replacements[] = str_replace('$','\$',$val); } // do regex $result = $this->output = @preg_replace($patterns,$replacements,$this->input); // do we clear? if ($clear == TRUE) $this->Clear(); // return output return $result; } function SepReplace($ssep , $esep , $vars,$clear = TRUE) { if (is_array($vars)) { foreach ($vars as $key => $var) { if (is_array($var)) { unset($vars[$key]); } } } // init some temp vars $patterns = array(); $replacements = array(); // build patterns and replacements if (is_array($vars)) // just a small check foreach ($vars as $key => $val) { $patterns[] = $ssep . strtoupper($key) . $esep; //the $ bug $replacements[] = str_replace('$','\$',$val); } // do regex $result = $this->output = @preg_replace($patterns,$replacements,$this->input); // do we clear? if ($clear == TRUE) $this->Clear(); // return output return $result; } /** * replace a single template variable * * @param string $var variable to be replaced * @param string $value replacement * @param bool $perm makes the change permanent [i.e. replaces input also]; defaults to FALSE * * @return string result of replacement * * @acces public */ function ReplaceSingle($var,$value,$perm = FALSE) { if ($perm) $this->input = $this->Replace(array("$var" => $value)); else return $this->Replace(array("$var" => $value)); } /** * resets all the replaced vars to their previous status * * @return void * * @acces public */ function Clear() { $this->output = $this->input; } /** * voids every template variable * * @return void * * @acces public */ function EmptyVars() { global $_TSM; //$this->output = $this->ReplacE($_TSM["_PERM"]); //return$this->output = preg_replace("'{[A-Z]}'si","",$this->output); return $this->output = preg_replace("'{[A-Z_\-0-9]*?}'si","",$this->output); //return $this->output = preg_replace("'{[\/\!]*?[^{}]*?}'si","",$this->output); } /** * checks if the specified template block exists * * @param string $block_name block name to look for * * @return bool TRUE if exists or FALSE if it doesnt * * @access public */ function BlockExists($block_name) { return isset($this->blocks[$block_name]) && is_object($this->blocks[$block_name])? TRUE : FALSE; } /* function Block($block,$vars = array(),$return_error = false) { if ($this->BlockExists($block)) return $this->blocks[$block]->Replace($vars); else { return ""; } } */ /*Extra functions to keep the compatibility with the new CTemplateDynamic library*/ /** * description * * @param * * @return * * @access */ function BlockReplace($block , $vars = array(), $clear = true){ if (!is_object($this->blocks[$block])) echo "CTemplate::{$this->template_file}::$block Doesnt exists.<br>"; return $this->blocks[$block]->Replace($vars , $clear); } /** * description * * @param * * @return * * @access */ function BlockEmptyVars($block , $vars = array(), $clear = true) { if (!is_object($this->blocks[$block])) echo "CTemplate::{$this->template_file}::$block Doesnt exists.<br>"; if (is_array($vars) && count($vars)) $this->blocks[$block]->Replace($vars , false); return $this->blocks[$block]->EmptyVars(); } /** * description * * @param * * @return * * @access */ function Block($block) { if (!is_object($this->blocks[$block])) echo "CTemplate::{$this->template_file}::$block Doesnt exists.<br>"; return $this->blocks[$block]->output; } } /** * description * * @library * @author * @since */ class CTemplateStatic{ /** * description * * @param * * @return * * @access */ /** * description * * @param * * @return * * @access */ function Replace($tmp , $data = array()) { $template = new CTemplate($tmp , "string"); return $template->replace($data); } function EmptyVars($tmp , $data = array()) { $template = new CTemplate($tmp , "string"); if (count($data)) { $template->replace($data , false); } return $template->emptyvars(); } /** * description * * @param * * @return * * @access */ function ReplaceSingle($tmp , $var , $value) { return CTemplateStatic::Replace( $tmp , array( $var => $value ) ); } } header("Content-Type: text/xml"); if (!$variables["email"]) { echo "<response><message>error</message></response>"; die(); } if(!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/",$variables["email"])){ echo "<response><message>error</message></response>"; die(""); } //check if the notification should be sent if ($conf["notification_email"]["enable"] == true) { $vars = $variables; foreach ($conf["notification_email"] as $key => $val) { $conf["notification_email"][$key] = CTemplateStatic::Replace($val , $vars); } //process the notify email $email = array( "email_to" => utf8_decode($conf["notification_email"]["to"]), "email_to_name" => utf8_decode($conf["notification_email"]["to_name"]), "email_from" => utf8_decode($conf["notification_email"]["from"]), "email_from_name" => utf8_decode($conf["notification_email"]["from_name"]), "email_subject" => utf8_decode($conf["notification_email"]["subject"]), "email_body" => utf8_decode($conf["notification_email"]["message"]), "email_type" => utf8_decode($conf["notification_email"]["type"]) ); foreach ($email as $key => $val) { $email[$key] = CTemplateStatic::Replace($val , $vars); } SendMail($email); } //check if the notification should be sent if ($conf["autoresponder_email"]["enable"] == true) { $vars = $variables; foreach ($conf["autoresponder_email"] as $key => $val) { $conf["autoresponder_email"][$key] = CTemplateStatic::Replace($val , $vars); } //process the notify email $email = array( "email_to" => utf8_decode($conf["autoresponder_email"]["to"]), "email_to_name" => utf8_decode($conf["autoresponder_email"]["to_name"]), "email_from" => utf8_decode($conf["autoresponder_email"]["from"]), "email_from_name" => utf8_decode($conf["autoresponder_email"]["from_name"]), "email_subject" => utf8_decode($conf["autoresponder_email"]["subject"]), "email_body" => utf8_decode($conf["autoresponder_email"]["message"]), "email_type" => utf8_decode($conf["autoresponder_email"]["type"]) ); foreach ($email as $key => $val) { $email[$key] = CTemplateStatic::Replace($val , $vars); } SendMail($email); } echo "<response><message>sent</message></response>"; die(); ?> MOD EDIT: [code] . . . [/code] tags added. <?php include("add_p2.php"); //basic pdo connection (with added option for error handling) if (isset($_POST['submit'])) { try { $stmt = $dbh->prepare("INSERT INTO passwords (description, username, password ) VALUES (:description, :username, :AES_ENCRYPT)"); $stmt->bindParam(':description', $description); $stmt->bindParam(':username', $username); $stmt->bindParam(':password', $password); try { $statement->execute(array( "description" => "description", "username" => "username", "password" => "password" )); } catch(PDOException $e) { echo "Exception caught: $e"; } //insert one row $name = 'one'; $value = 1; $stmt->execute(); header( 'Location: localhost/password_added.php' ); exit(); ?> <?php $dsn = "mysql:host=127.0.0.1;dbname=pword_db;charset=utf8"; $opt = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ); $pdo = new PDO($dsn,'root','', $opt); ?> <form action="add_p.php" method="post"> <span class="cursive">Description: </span><br> <textarea name="description" rows="20" cols="50"></textarea> <br> <span class="cursive">Username: </span><br> <input type="text" name="username" /> <br> <span class="cursive">Password: </span><br> <input type="text" name="password" /> <br> <input type="submit"/> </form>Hi, above is the 3 components that should add form data into MySQL database using PDO. all it's doing is entering empty values, I'm really not sure why this is? please could someone help me with pointing me in the right direction, offer hint's making this work Thanks Attached Files PHPmyadmin.JPG 64.83KB 0 downloads OK so to start. We have our domain in the format X.com. Our new-mail form (php) is under mails.X.com. We use phpmail for sending mails. Receiving is disabled. There is apcall for mail() function in button's onclick event. Works as intended (gets call transmitted to phpmail function as well as MTP's) but mails never leaves our servers (and reaches receipient(s)). What may the problem be? Hi guys I need some help here about mailer. I have created a file register new user (register.php) and when a new user register an email will be sent to their address. I have this code on my register file but when I run them it's okay but I did not get the email... can anyone assist me what I did wrong? Thanks. <?php $to = "someone@example.com"; //change to a valid email $subject = "Test mail"; $message = "Hello! This is a simple email message."; $from = "someonelse@example.com"; //change to a valid email $headers = "From:" . $from; mail($to,$subject,$message,$headers); echo "Mail Sent."; ?> This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=306860.0 Here's my situation: I had someone create a PHP form for me. I have inserted it into a website I am designing. The form works on my personal host (except still trying to figure out how to have the uploaded file be attached to the sent email), but I am getting an error where the form will actually be hosted. See below. Please let me know if any more info is needed. Form: http://www.jjbuttons.com/order Error on submission: Warning: mail() [function.mail]: Bad parameters to mail() function, mail not sent. in /home/content/j/u/m/jumpinjack/html/form/attach_mailer_class.php on line 186 Error while sending you mail. Host: GoDaddy PHP version: 4.4.9 http://www.jjbuttons.com/info.php Same form / code: http://www.chrisdoughmandesign.com/order.html Mail submits (except still trying to figure out how to have uploaded file be attached to email) Host: JustHost PHP version: 5.2.16 http://www.chrisdoughmandesign.com/info.php Code: [Select] <?php if(isset($_POST['cmd']) && ($_POST['cmd'] == 'complete')) { if(isset($_POST['completeorder'])) { //UPDATE THESE VARIABLES $to = 'user@example.com'; // TODO: Change to your desired email. $cc = ""; //OPTIONAL $bcc = ""; //OPTIONAL $subject = 'Order Form Submission'; //TODO: Update to a subject for the email that you like $uploadpath = $_SERVER['DOCUMENT_ROOT']."/files/mail/"; //TODO: Change path to match your environment $max_size = 1024*2; //TODO: Update the max. size for uploading in kbs require($_SERVER['DOCUMENT_ROOT']."/form/attach_mailer_class.php"); //TODO: Change path to match your environment include ($_SERVER['DOCUMENT_ROOT']."/form/upload_class.php"); //TODO: Change path to match your environment //EDITTING BELOW THIS SHOULD NOT BE NECESSARY $name = $_POST['fname'] . ' ' . $_POST['lname']; $from = $_POST['email']; $msg = ""; $body =' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style> .rounded_corners { border-radius: 15px; -moz-border-radius: 15px; } fieldset { margin:10px auto; } #commentForm label.error, #commentForm input.submit { margin-left: 10px; } </style> </head> <body> <div style="margin:0 auto; width:900px; padding:10px;"> <fieldset class="rounded_corners"> <LEGEND ACCESSKEY=I style="font-weight:bold; padding:1px 5px;"> Billing / Shipping Information</LEGEND> <div style="float:left; width:430px; "> <div class="rounded_corners" style="background-color:#EEE; padding:5px; font-weight:bold; ">Bill To:</div> <div> <table style="margin-left:5px; width:100%:" cellpadding="3" cellspacing="0"> <tr> <td style="width:110px; text-align:right;">* First Name:</td> <td style="width:290px;">'.$_POST['fname'].'</td> </tr> <tr> <td style="text-align:right;">* Last Name:</td> <td>'.$_POST['lname'].'</td> </tr> <tr> <td style="text-align:right;">Company:</td> <td>'.$_POST['company'].'</td> </tr> <tr> <td style="text-align:right;">Address 1</td> <td>'.$_POST['add1'].'</td> </tr> <tr> <td style="text-align:right;">Address 2</td> <td>'.$_POST['add2'].'</td> </tr> <tr> <td style="text-align:right;">City:</td> <td>'.$_POST['city'].'</td> </tr> <tr> <td style="text-align:right;">State:</td> <td>'.$_POST['state'].'</td> </tr> <tr> <td style="text-align:right;">* Zip:</td> <td>'.$_POST['zip'].'</td> </tr> <tr> <td style="text-align:right;">* Phone:</td> <td>'.$_POST['phone'].'</td> </tr> <tr> <td style="text-align:right;">* Email:</td> <td>'.$_POST['email'].'</td> </tr> </table> </div> </div> <div style="float:right; width:430px;"> <div class="rounded_corners" style="background-color:#EEE; padding:5px; font-weight:bold; "> <span style="float:left;">Ship To:</span> <span style="float:right;"><input type="checkbox" name="sameasbilling" id="sameasbilling" /></span> <div style="clear:both; height:1px;"></div> </div> <div> <table style="margin-left:5px; width:100%:" cellpadding="3" cellspacing="0"> <tr> <td style="width:110px; text-align:right;">* First Name:</td> <td style="width:290px;">'.$_POST['fname2'].'</td> </tr> <tr> <td style="text-align:right;">* Last Name:</td> <td>'.$_POST['lname2'].'</td> </tr> <tr> <td style="text-align:right;">Company:</td> <td>'.$_POST['company2'].'</td> </tr> <tr> <td style="text-align:right;">Address 1</td> <td>'.$_POST['add12'].'</td> </tr> <tr> <td style="text-align:right;">Address 2</td> <td>'.$_POST['add22'].'</td> </tr> <tr> <td style="text-align:right;">City:</td> <td>'.$_POST['city2'].'</td> </tr> <tr> <td style="text-align:right;">State:</td> <td>'.$_POST['state2'].'</td> </tr> <tr> <td style="text-align:right;">* Zip:</td> <td>'.$_POST['zip2'].'</td> </tr> <tr> <td style="text-align:right;">* Phone:</td> <td>'.$_POST['phone2'].'</td> </tr> </table> </div> </div> <div style="clear:both; height:1px;"></div> <div style="width:100%; text-align:center;"> * indicates required information</div> </fieldset> <fieldset class="rounded_corners"> <legend accesskey="2" style="font-weight:bold; padding:1px 5px;"> Order</LEGEND> <div class="rounded_corners" style="background-color:#EEE; padding:5px; font-weight:bold; "> <table style="width:100%;"> <tr> <td style="width: 150px;"></td> <td style="font-weight:bold; text-align:center;">Button Size</td> <td style="font-weight:bold; text-align:center;">Quantity</td> <td style="font-weight:bold; text-align:center;">Button Back</td> <td style="font-weight:bold; text-align:center;"></td> </tr> </table> </div> <div style="width:100%; padding:5px;"> <table style="width:100%;" cellpadding="2"> <tr> <td style="width: 150px; text-align:center; font-weight:bold;">* Product 1</td> <td style="">'.$_POST['size1'].'</td> <td style="">'.$_POST['qty1'].'</td> <td style="">'.$_POST['back1'].'</td> <td style=""></td> </tr>'; if(isset($_POST['size2']) && isset($_POST['qty2']) && isset($_POST['back2'])) { $body .= '<tr> <td style="width: 150px; text-align:center; font-weight:bold;">Product 2</td> <td style="">'.$_POST['size2'].'</td> <td style="">'.$_POST['qty2'].'</td> <td style="">'.$_POST['back2'].'</td> <td style=""></td> </tr>'; } if(isset($_POST['size3']) && isset($_POST['qty3']) && isset($_POST['back3'])) { $body .= '<tr> <td style="width: 150px; text-align:center; font-weight:bold;">Product 3</td> <td style="width: 150px; text-align:center; font-weight:bold;">Product 2</td> <td style="">'.$_POST['size3'].'</td> <td style="">'.$_POST['qty3'].'</td> <td style="">'.$_POST['back3'].'</td> <td style=""></td> </tr>'; } if(isset($_POST['size4']) && isset($_POST['qty4']) && isset($_POST['back4'])) { $body .= '<tr> <td style="width: 150px; text-align:center; font-weight:bold;">Product 4</td> <td style="width: 150px; text-align:center; font-weight:bold;">Product 2</td> <td style="">'.$_POST['size4'].'</td> <td style="">'.$_POST['qty4'].'</td> <td style="">'.$_POST['back4'].'</td> <td style=""></td> </tr>'; } $body .= '</table> </div> </fieldset> <fieldset class="rounded_corners"> <LEGEND accesskey="3" style="font-weight:bold; padding:1px 5px;">Miscellaneous Info</LEGEND> <table cellpadding="5"> <tr> <td style="width:280px; text-align:center;">*When do you need your order?</td> <td style="width:280px; text-align:center;">'.$_POST['month'].'</td> <td style="width:280px; text-align:center;">'.$_POST['days'].'</td> </tr> <tr> <td style="width:280px; text-align:center;">Is this a Quote or an Order?</td> <td style="width:280px; text-align:center;">'.$_POST['saletype'].'</td> <td style="width:280px; text-align:center;"></td> </tr> <tr> <td style="width:280px; text-align:center;">Have you ordered from us before?</td> <td style="width:280px; text-align:center;">'.$_POST['prevorder'].'</td> <td style="width:280px; text-align:center;"></td> </tr> <tr> <td colspan="3" style="width:100%; text-align:center; font-weight:bold;"> Comments, questions, special instructions: </td> </tr> <tr> <td colspan="3" style="width:100%; text-align:center;"> '.$_POST['comments'].' </td> </tr> </table> </fieldset> </div> </body> </html>'; $my_mail = new attach_mailer($name , $from , $to, $cc , $bcc, $subject, $body); if (isset($_FILES)) { foreach ($_FILES as $key => $file) { for($i = 0; $i < count($file['name']); $i++) { if(isset($file['tmp_name'][$i]) && $file['tmp_name'][$i] != '') { $my_upload = new file_upload; $my_upload->extensions = array(".ai", ".eps", ".pdf", ".psd", ".jpg", ".jpeg"); $my_upload->rename_file = false; $my_upload->upload_dir = $uploadpath; $my_upload->the_temp_file = $file['tmp_name'][$i]; $my_upload->the_file = $file['name'][$i]; $my_upload->http_error = $file['error'][$i]; if ($my_upload->upload()) { $full_path = $my_upload->upload_dir.$my_upload->file_copy; $my_mail->create_attachment_part($full_path); $my_upload->del_temp_file($full_path); } $msg .= $my_upload->show_error_string(); } } } } $my_mail->process_mail(); $msg .= $my_mail->get_msg_str(); echo $msg; } } elseif(isset($_POST['cmd']) && $_POST['cmd'] == 'set_opts') { switch ($_POST['selected']) { case '1\" Round': $options = array('Select Back Button', 'Pin Back','Magnet Back','Zipper Pull'); break; case '1.25\" Round': $options = array('Select Back Button', 'Pin Back','Magnet Back','Zipper Pull'); break; case '2.25\" Round': $options = array('Select Back Button', 'Pin Back','Magnet Back', 'Bottle Opener', 'Bottle Opener With Key Ring'); break; case '3\" Round': $options = array('Select Back Button', 'Pin Back','Magnet Back'); break; case '3.5\" Round': $options = array('Select Back Button', 'Pin Back','Magnet Back'); break; case '2x3\" Rectangle': $options = array('Select Back Button', 'Pin Back','Magnet Back'); break; case '3x2\" Vertical Rectangle': $options = array('Select Back Button', 'Pin Back','Magnet Back'); break; case '2x2 Square': $options = array('Select Back Button', 'Pin Back','Magnet Back'); break; case '2x2 Diamond': $options = array('Select Back Button', 'Pin Back','Magnet Back'); break; case 'Select Button Size': $options = array('Select Back Button'); break; } echo json_encode(array('result' => $options)); } ?> Hi Guys I am adding a short contact form to a site. All the fields are text fields. What do you think is the minimum validation I need to add to make the form safe against hacking etc. Thanks does anyone have any update on this? I am using it pretty heavily, and someone who has a gmail account just told me that their message was sent to spam. I have a gmail account myself and last night I ran a test and it was not sent there for me. I guess google could be doing some algorithmic nonsense to analyze behavior patterns, but I would guess not in this case. Does anyone know the status of some of the major email clients and their acceptance of PHP mailer receipts? I know the DNS is also associated, but the test that I ran myself came to the inbox without the need for a DNS change. gmail simply popped up a warning of information. thank you guys. I'm just fishing for info here as to see what I can do to stop this. Hi there! I have two different hosting services: on the first one I can regularly use the function mail(), but the second does not allow me to send mails (it will block the account for mass mailing). I need to use mail to notify things to user who requested it, so I need to be able to send mail from this second server too. I thought that I will create a mailer script on the firs server, so that the second will simply call the script when needed, passing the e-mail addresses, the subject and content trough POST. Now, how to avoid that some malicious user uses my script to send own mails? I thought that I can send with the POST two vars, "time" and "secure_code" (I will eventually fake the names, so that is not so easy to recognize), where "time" is get by time(), and "secure_code" is a function depending on the value of "time". The mailer script gets the both values, and use the same function to verify if the "secure_code" is correct, according to time. Question is, is this safe? What kind of function shall I use? Also, how could I avoid that a malicious user simply same the "time" and "secure_code" in a certain moment, and use it again? Thanks in advance. |