Jump to content

mail() isn't working!


dp69_2001

Recommended Posts

It's been a few years since I've done any PHP and for some reason my big mouth got me into a project for work. I can't figure out why this isn't working! Thank you in advance to anyone that can help me.

<!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>Thank You!</title>
<style type="text/css">
body {
margin-left: 10%;
margin-right: 10%;
Margin-top: 20px;
Padding: 5px;
font-size: 1em;
border: 1px dotted gray;
background-color: #C4D3FF;
letter-spacing:+0.1em;
}
h3, h2, h1 { font-family: sans-serif;
text-align: center;
}
table {width: 80%;
margin-left: 15%;
margin-right: 5%;
column-width: 50%;


}


#submitbutton {
           float: right;
       }




</style>
</head>


<body>
<?php
   $burger = $_POST['burger']; 
   $restservice = $_POST['restservice'];
   $fries = $_POST['fries'];
   $buffet = $_POST['buffet'];
   $steak = $_POST['steak']; 
   $carryout = $_POST['carryout'];
   $pizza = $_POST['pizza']; 
   $asian = $_POST['asian']; 
   $mexican = $_POST['mexican']; 
   $deli = $POST['deli'];
   $dessert = $_POST['dessert']; 
   $onionrings = $_POST['onionrings'];
   $bbq = $_POST['bbq']; 
   $kidsmeal = $_POST['kidsmeal'];
   $restbreakfast = $_POST['restbreakfast']; 
   $dutchoven = $_POST['dutchoven']; 
   $seafood = $_POST['seafood']; 
   $restaurantoverall = $_POST['restaurantoverall']; 
   $atmosphere = $_POST['atmosphere']; 
   $speed = $_POST['speed']; 
   $value = $_POST['value']; 
   $service = $_POST['service']; 
   $delivery = $_POST['delivery']; 
   $drivethru = $_POST['drivethru']; 
   $fastfoodoverall = $_POST['fastfoodoverall']; 
   $fastbreakfast = $_POST['fastbreakfast']; 
   $coffeeshop = $_POST['coffeeshop']; 
   $pharmacy = $_POST['pharmacy']; 
   $clothing = $_POST['clothing']; 
   $trophies = $_POST['trophies']; 
   $tanning = $_POST['tanning']; 
   $phonedealer = $_POST['phonedealer']; 
   $beautysalon = $_POST['beautysalon']; 
   $computerssoftware = $_POST['computerssoftware']; 
   $electronics = $_POST['electronics']; 
   $massagesalon = $_POST['massagesalon']; 
   $florist = $_POST['florist']; 
   $bakery = $_POST['bakery']; 
   $giftshop = $_POST['giftshop']; 
   $localowned = $_POST['localowned']; 
   $hardware = $_POST['hardware']; 
   $tattoo = $_POST['tattoo']; 
   $lumber = $_POST['lumber']; 
   $bookstore = $_POST['bookstore']; 
   $jewelry = $_POST['jewelry']; 
   $shoestore = $_POST['shoestore']; 
   $nurserygarden = $_POST['nurserygarden']; 
   $bank = $_POST['bank']; 
   $skillednursing = $_POST['skillednursing']; 
   $upholstery = $_POST['upholstery']; 
   $apartments = $_POST['apartments']; 
   $daycare = $_POST['daycare']; 
   $prefabhomes = $_POST['prefabhomes']; 
   $mortgageco = $_POST['mortgageco']; 
   $commserv = $_POST['commserv']; 
   $healthcare = $_POST['healthcare']; 
   $lodging = $_POST['lodging']; 
   $garagedoor = $_POST['garagedoor']; 
   $placework = $_POST['placework']; 
   $healthcare = $_POST['healthcare']; 
   $realestate = $_POST['realestate']; 
   $pestcontrol = $_POST['pestcontrol']; 
   $signshop = $_POST['signshop']; 
   $petgrooming = $_POST['petgrooming']; 
   $taxidermist = $_POST['taxidermist']; 
   $printshop = $_POST['printshop']; 
   $institution = $_POST['institution']; 
   $utilities = $_POST['utilities']; 
   $rental = $_POST['rental']; 
   $vet = $_POST['vet']; 
   $pet = $_POST['pet'];  
   $vision = $_POST['vision']; 
   $bedbreakfast = $_POST['bedbreakfast']; 
   $attorney = $_POST['attorney']; 
   $mortgage = $_POST['mortgage']; 
   $electrician = $_POST['electrician']; 
   $mailman = $_POST['mailman']; 
   $mechanic = $_POST['mechanic']; 
   $busdriver = $_POST['busdriver']; 
   $chiropractor = $_POST['chiropractor']; 
   $principal = $_POST['principal']; 
   $dentist = $_POST['dentist']; 
   $teacher = $_POST['teacher']; 
   $doctor = $_POST['doctor']; 
   $custodian = $_POST['custodian']; 
   $contractor = $_POST['contractor']; 
   $cafeteria = $_POST['cafeteria']; 
   $surgeon = $_POST['surgeon']; 
   $schoolaide = $_POST['schoolaide']; 
   $hairstylist = $_POST['hairstylist']; 
   $clergy = $_POST['clergy']; 
$nailtech = $_POST['nailtech']; 
   $caterer = $_POST['caterer']; 
   $insuranceagent = $_POST['insuranceagent']; 
   $butcher = $_POST['butcher']; 
   $investmentplanning = $_POST['investmentplanning']; 
   $realestateagent = $_POST['realestateagent']; 
$obgyn = $_POST['obgyn']; 
   $massagetherapist = $_POST['massagetherapist']; 
$optometrist = $_POST['optometrist']; 
   $accountant = $_POST['accountant']; 
   $ophthalmologist = $_POST['ophthalmologist']; 
   $tattooartist = $_POST['tattooartist']; 
   $photographer = $_POST['photographer']; 
   $baker = $_POST['baker']; 
   $waitress = $_POST['waitress']; 
   $bankteller = $_POST['bankteller']; 
   $veterinarian = $_POST['veterinarian']; 
   $gymnastics = $_POST['gymnastics']; 
   $fishing = $_POST['fishing']; 
   $fitness = $_POST['fitness']; 
   $bowling = $_POST['bowling']; 
   $sportseq = $_POST['sportseq']; 
   $scenicdrive = $_POST['scenicdrive']; 
   $gunshop = $_POST['gunshop']; 
   $hiking = $_POST['hiking']; 
   $youthprogram = $_POST['youthprogram']; 
   $camping = $_POST['camping']; 
   $fishingtackle = $_POST['fishingtackle']; 
   $autoparts = $_POST['autoparts']; 
   $autobody = $_POST['autobody']; 
   $tuneup = $_POST['tuneup']; 
   $gasstation = $_POST['gasstation'];  
   $newauto = $_POST['newauto']; 
   $oillube = $_POST['oillube']; 
   $usedauto = $_POST['usedauto']; 
   $tirestore = $_POST['tirestore']; 
   $appliances = $_POST['appliances']; 
   $flooring = $_POST['flooring']; 
   $interior = $_POST['interior']; 
   $furniture = $_POST['furniture']; 
   $paintstore = $_POST['paintstore']; 
   $furniturerental = $_POST['furniturerental']; 
   $cabinetshop = $_POST['cabinetshop']; 
   $acheat = $_POST['acheat']; 
   $septic = $_POST['septic']; 
   $building = $_POST['building']; 
   $landscape = $_POST['landscape']; 
   $excavating = $_POST['excavating']; 
   $electricservice = $_POST['electricservice']; 
   $plumbing = $_POST['plumbing']; 
   $painting = $_POST['painting']; 
   $roofing = $_POST['roofing']; 
   $engineering = $_POST['engineering']; 
   $windows = $_POST['windows']; 
   $other1 = $_POST['other1']; 
   $other2 = $_POST['other2']; 
   $other3 = $_POST['other3']; 
   $other4 = $_POST['other4']; 
   $other4 = $_POST['other4']; ; 
   $name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];   
$zip = $_POST['zip']; 
   $phone = $_POST['phone']; 


$msg = "Best Food and Restaurant \n \n" .
"Burger: $burger\n" .
"French Fries: $fries\n" .
"Steak: $steak\n" .
"Pizza: $pizza\n" .
"Mexican: $mexican\n" .
"Dessert: $dessert\n" .
"BBQ: $bbq\n" .
"Breakfast: $restbreakfast\n" .
"Seafood: $seafood\n" .
"Atmosphere: $atmosphere\n" .
"Service: $service\n" .
"Buffet: $buffet\n" .
"Carryout: $carryout\n" .
"Asian: $asian\n" .
"Deli: $deli\n" .
"Onion Rings: $onionrings\n" .
"Kids Meal or Menu: $kidsmeal\n" .
"Dutch Oven: $dutchoven\n" .
"Overall: $restaurantoverall\n \n" .
"Fast Food\n \n" .
"Speed: $speed\n" .
"Service: $service\n" .
"Drive Thru: $drivethru\n" .
"Breakfast: $fastbreakfast\n" .
"Value: $value\n" .
"Delivery: $delivery\n" .
"Overall: $fastfoodoverall\n \n" .
"Best Shops & Stores\n \n" .
"Coffee Shop: $coffeeshop\n" .
"Clothing: $clothing\n" .
"Tanning: $tanning\n" .
"Beauty Salon: $beautysalon\n" .
"Electronics: $electronics\n" .
"Florist: $florist\n" .
"Gift Shop: $giftshop\n" .
"Hardware Store: $hardware\n" .
"Lumber Store: $lumber\n" .
"Jewelry: $jewelry\n" .
"Nursery-garden: $nurserygarden\n" .
"Pharmacy: $pharmacy\n" .
"Trophies: $trophies\n" .
"Cell Phone Dealer: $phonedealer\n" .
"Computers/Software: $computerssoftware\n" .
"Massage Salon: $massagesalon\n" .
"Bakery: $bakery\n" .
"Locally Owned: $localowned\n" .
"Tattoo Parlor: $tattoo\n" .
"Book Store: $bookstore\n" .
"Shoe Store: $shoestore\n \n" .
"Services\n \n" .
"Bank: $bank\n" .
"Carpet/Upholstery Cleaning: $upholstery\n" .
"Day Care/Nursery School: $daycare\n" .
"Mortgage Co.: $mortgageco\n" .
"Health Care Facility: $healthcare\n" .
"Garage Door Service: $garagedoor\n" .
"Health Care Supplies: $healthcare\n" .
"Pest control: $pestcontrol\n" .
"Pet Grooming: $petgrooming\n" .
"Print Shop: $printshop\n" .
"Utility Company: $utilities\n" .
"Veterinary Hospital: $vet\n" .
"Vision Center: $vision\n" .
"Skilled Nursing Facility: $skillednursing\n" .
"Apartments: $apartments\n" .
"Pre-Fab Homes: $prefabhomes\n" .
"Community Service Club: $commserv\n" .
"Lodging: $lodging\n" .
"Best Place to Work: $placework\n" .
"Real Estate Firm: $realestate\n" .
"Sign Shop: $signshop\n" .
"Taxidermist: $taxidermist\n" .
"Institution of Higher Learning: $institution\n" .
"Rental Shop: $rental\n" .
"Bed and Breakfast: $bedbreakfast\n" .
"Pet Store: $pet\n \n" .
"Best People\n \n" .
"Attorney: $attorney\n" .
"Electrician: $electrician\n" .
"Auto Mechanic: $mechanic\n" .
"Chiropractor: $chiropractor\n" .
"Dentist: $dentist\n" .
"Doctor: $doctor\n" .
"Gen. Contractor: $contractor\n" .
"Surgeon: $surgeon\n" .
"Hair Stylist: $hairstylist\n" .
"Nail Tech: $nailtech\n" .
"Insurance Agent: $insuranceagent\n" .
"Investment/Retirement Planning: $investmentplanning\n" .
"OB/GYN: $obgyn\n" .
"Optomotrist: $optometrist\n" .
"Ophthalmologist: $ophthalmologist\n" .
"Photographer: $photographer\n" .
"Waitress/Waiter: $waitress\n" .
"Veterinarian: $veterinarian\n" .
"Mortgage Lender: $mortgage\n" .
"Mail Carrier: $mailman\n" .
"Bus Driver: $busdriver\n" .
"Principal: $principal\n" .
"Teacher: $teacher\n" .
"School Custodian: $custodian\n" .
"Cafeteria Worker: $cafeteria\n" .
"School Aide: $schoolaide\n" .
"Clergy: $clergy\n" .
"Caterer: $caterer\n" .
"Butcher: $butcher\n" .
"Real Estate Agent: $realestateagent\n" .
"Massage Therapist: $massagetherapist\n" .
"Accountant: $accountant\n" .
"Tatto Artist: $tattooartist\n" .
"Baker: $baker\n" .
"Bank Teller: $bankteller\n \n" .
"Sports & Recreation\n \n" .
"Gymnastics Training/Dance Studio: $gymnastics\n" .
"Fitness Center: $fitness\n" .
"Sports Equipment: $sportseq\n" .
"Gun/Firearm Shop: $gunshop\n" .
"Youth Program: $youthprogram\n" .
"Fishing Tackle: $fishingtackle\n" .
"Fishing: $fishing\n" .
"Bowling: $bowling\n" .
"Scenic Drive: $scenicdrive\n" .
"Hiking Trail: $hiking\n" .
"Camping Spot: $camping\n" .
"Autos and ATVs\n \n" .
"Auto Parts & Rebuilders:$autoparts\n" .
"Tune-Up Service: $tuneup\n" .
"Auto Dealer (New): $newauto\n" .
"Auto Dealer (Used): $usedauto\n" .
"Auto Body Shop: $autobody\n" .
"Gas Station: $gasstation\n" .
"Oil & Lube Service: $oillube\n" .
"Tire Store: $tirestore\n \n" .
"Furniture, Appliances & decorating\n \n" .
"Appliances: $appliances\n" .
"Interior Decor: $interior\n" .
"Paint Store: $paintstore\n" .
"Cabinet Shop: $cabinetshop\n" .
"Carpet/Flooring Store: $flooring\n" .
"Furniture: $furniture\n" .
"Furniture - Rental: $furniturerental\n \n" .
"Building/Home Services\n \n" .
"A/C & Heating: $acheat\n" .
"Building/New Homes: $building\n" .
"Excavating: $excavating\n" .
"Plumbing Roofing: $plumbing\n" .
"Window Replacement: $windows\n" .
"Septic Tank: $septic\n" .
"Landscape Co.: $landscape\n" .
"Electric Co. Service: $electricservice\n" .
"Painting: $painting\n" .
"Engineering Firm: $engineering\n" .
"Other\n \n" .
"Other 1: $other1\n" .
"Other 2: $other2\n" .
"Other 3: $other3\n" .
"Other 4: $other4\n \n" .
"Personal Info\n \n" .
"Name: $name\n" .
"Address: $address\n" .
"City: $city\n" .
"State: $state\n" .
"Zip: $zip\n" .
"Phone: $phone\n";


$email = $_POST['someone@drpgraphicdesign.com'];
$subject = $_POST['BOB -' . $name . 'has submitted a ballot'];
$to = $_POST['someone@msn.com'];
mail($to, $subject, $msg, 'From:' . $email) or die('unable to submit');
echo "Thank you for voting $name";


?>


</body>
</html>

Link to comment
Share on other sites



$email = $_POST['someone@drpgraphicdesign.com'];
$subject = $_POST['BOB -' . $name . 'has submitted a ballot'];
$to = $_POST['someone@msn.com'];
mail($to, $subject, $msg, 'From:' . $email) or die('unable to submit');
echo "Thank you for voting $name";


?>


</body>
</html>

 

Oh. My. God. Really.

 

I think you got a little over zealous with the post array. I doubt you actually posted those last few.

Link to comment
Share on other sites

For your massive line after line of code, that only changes in what value/legend, I would make an array of arrays, with your categories as the index of the main array, and you have an index/value pair for each form field under that category. The sub-array index would be the form field name and the value would be the legend you want in the email message.

 

Then you can loop over the array of arrays to build the email message. The main array index would given you the category heading for the message and then loop over each sub-array to output the legend from the array value and access the correct $_POST field using the array index.

Link to comment
Share on other sites

The point trying to be made is that your code:

$email = $_POST['someone@drpgraphicdesign.com'];
$subject = $_POST['BOB -' . $name . 'has submitted a ballot'];

 

Is attempting to look up the value of inputs in your form that look like:

<input type="text" name="someone@drpgraphicdesign.com">
<input type="text" name="BOB - something has submitted a ballot">

 

Which is almost certainly not what you want.  You need to just assign $email and $subject to the string values, not try and lookup something in the $_POST array.

$email = 'someone$drpgraphicdesign.com';

 

Link to comment
Share on other sites

Oh my hell! Thank you.

Those 3 lines should be:

$email = 'dallas@drpgraphicdesign.com';
$subject = 'BOB -' . $name . 'has submitted a ballot';
$to = 'dp69_2001@msn.com';

 

Thank you so much for pointing that out. I'd hoped it was just a mistake like that somewhere and that I could finish this damn thing. They've been nagging me about it since Monday. I will definitely be trying learn more about arrays before doing anything similar.

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.