I swear I had this working a couple hours ago but suddenly instead of only sending the form and saying "Thank you for filling out the form!" once the form is submitted, it does it once the page is loaded.
<?php
if (($_SERVER['REQUEST_METHOD'] == 'POST') && (!empty($_POST['action']))) :
endif; // form submitted
if (isset($_POST['years'])) { $years = $_POST['years']; }
if (isset($_POST['business'])) { $business = $_POST['business']; }
if (isset($_POST['primary'])) { $primary = $_POST['primary']; }
if (isset($_POST['improve'])) { $improve = $_POST['improve']; }
if (isset($_POST['meaning'])) { $meaning = $_POST['meaning']; }
if (isset($_POST['tagline'])) { $tagline = $_POST['tagline']; }
if (isset($_POST['services'])) { $services = $_POST['services']; }
if (isset($_POST['marketingrep'])) { $marketingrep = $_POST['marketingrep']; }
if (isset($_POST['bestquality'])) { $bestquality = $_POST['bestquality']; }
if (isset($_POST['qualityimprovement'])) { $qualityimprovement = $_POST['qualityimprovement']; }
if (isset($_POST['mediateam'])) { $mediateam = $_POST['mediateam']; }
if (isset($_POST['ifsoexperience'])) { $ifsoexperience = $_POST['ifsoexperience']; }
if (isset($_POST['outside'])) { $outside = $_POST['outside']; }
if (isset($_POST['succession'])) { $succession = $_POST['succession']; }
if (isset($_POST['succession-interest'])) { $successioninterest = $_POST['succession-interest']; }
if (isset($_POST['staff'])) { $staff = $_POST['staff']; }
if (isset($_POST['licensed'])) { $licensed = $_POST['licensed']; }
if (isset($_POST['vision'])) { $vision = $_POST['vision']; }
if (isset($_POST['marketingplan'])) { $marketingplan = $_POST['marketingplan']; }
if (isset($_POST['assist'])) { $assist = $_POST['assist']; }
$formerrors = false;
if ($years === '' ) :
$err_years = '<div class="error">Please fill out this field.</div>';
$formerrors = true;
endif;
if ($business === '' ) :
$err_business = '<div class="error">Please fill out this field.</div>';
$formerrors = true;
endif;
if (!($formerrors)) :
$to = "[email protected]";
$subject = "FIG Survey Landing Page Lead";
$message = "How many years have you been with FIG? \r\n$years\r\n\r\nHow much business did you write in 2012? \r\n$business\r\n\r\nWhat is your primary source of marketing? \r\n$primary\r\n\r\nWhat could FIG improve on in fulfilling your marketing needs?\r\n$improve\r\n\r\nWhat does FIG mean to you? \r\n$meaning\r\n\r\nWhat is FIG's tagline? \r\n$tagline\r\n\r\nWhat services does FIG do for you? \r\n$services\r\n\r\nWho is your marketing rep? \r\n$marketingrep\r\n\r\nWhat is their best quality? \r\n$bestquality\r\n\r\nWhat's the quality they most need to improve on? \r\n$qualityimprovement\r\n\r\nHave you ever spoken with our All Points Media Team? \r\n$mediateam\r\n\r\nIf so, what was your experience? \r\n$ifsoexperience\r\n\r\nWhat do you do outside of work? \r\n$outside\r\n\r\nDo you have a succession plan? \r\n$succession\r\n\r\nAre you interested in implementing one? \r\n$successioninterest\r\n\r\nDo you have a staff? If so how many? Please list roles in office: \r\n$staff\r\n\r\nAre you series 6, 7 or 65 licensed? Please list which one(s). \r\n$licensed\r\n\r\nWhat is your vision? \r\n$vision\r\n\r\nDo you have a marketing plan? \r\n$marketingplan\r\n\r\nWhat else could FIG be doing to assist you with your business? \r\n$assist\r\n\r\n";
if (mail($to, $subject, $message)) :
$msg = "Thanks for filling out the survey!";
else:
$msg = "Problem sending the message";
endif;
endif;
?>
Any ideas? Thanks!