Hello Everyone,
I am new to the forum and need some help. I am by no means good at PHP coding but we have an issue with our form not sending the confirmation email once submitted to our sales department. I can see the request for the quote in our content management system, however nothing gets sent to the sales team. I looked through the code and the email address provided to "send to" is current but it is not working, so I am assuming something in the code is not lining up. Also, there is no option in our content management system to click to "turn it on or off".
This is the form process:
<?
session_start();
include('settings.php');
include('classes/class.formdata.php');
include('classes/class.email.php');
include('classes/class.DB.php');
include('functions/functions.general.php');
if ($_POST["PreviousOrderNumber"]){$_POST["Layout*"]=$_POST["PreviousOrderNumber"];}
unset($_POST["PreviousOrderNumber"]);
$newformdata = new FormData($_POST);
//echo "Hello";
switch ($send_form_data) {
case 'email': {
if (!$_SESSION['formerrors']) {
$newemail = new Email($to,$from, $subject);
$newemail->SendEmail();
var_dump($_SESSION["formdata"]);
unset($_SESSION["formdata"]);
$redirect = $newformdata->referrer;
header("Location: $redirect");
}
} break;
case 'email/db': {
if (!$_SESSION['formerrors']) {
$newemail = new Email($to,$from, $subject);
$newemail->SendEmail();
$dbFormData = new DB();
$dbFormData->writePostToDB($_SESSION["formdata"],"QuoteRequests");
if (count($_FILES)>1){
$dbFormData->writeFilesToDB($_FILES,"QuoteRequests");
}
unset($_SESSION["formdata"]);
}
} break;
default: {
echo 'Invalid setting in variable $send_form_data';
} break
;
}
//echo "END";
//exit;
$redirect = $newformdata->referrer;
header("Location: $redirect");
exit;
$newformdata = new FormData($_POST);
//var_dump($_SESSION['formerrors']) . " - " .var_dump($_SESSION["formdata"]);exit;
switch ($send_form_data) {
case 'email': {
if (!$_SESSION['formerrors']) {
$newemail = new Email($to,$from, $subject);
$newemail->SendEmail();
unset($_SESSION["formdata"]);
}
} break
;
default: {
echo 'Invalid setting in variable $send_form_data';
} break
;
}
//insert into db
if (!$_SESSION['formerrors']) {
$arg = '';
$FirstName= $_POST['FirstName*'];
$LastName= $_POST['LastName*'];
$Company= $_POST['Company'];
$Phone= $_POST['Phone*'];
$Fax= $_POST['Fax'];
$Email= $_POST['Email*'];
$PONumber= $_POST['PONumber'];
$Address= $_POST['Address*'];
$ApartmentOrUnitNumber= $_POST['ApartmentOrUnitNumber'];
$City= $_POST['City*'];
$State= $_POST['State*'];
$Zip= $_POST['Zip*'];
$Quantity= $_POST['Quantity*'];
$Height= $_POST['Height*'];
$Width= $_POST['Width*'];
$Characters= $_POST['Characters*'];
$AdditionalCharacters= $_POST['AdditionalCharacters'];
$Metal= $_POST['Metal*'];
$Border= $_POST['Border*'];
$Texture= $_POST['Texture*'];
$Color= $_POST['Color*'];
$Finish= $_POST['Finish*'];
$Mounting= $_POST['Mounting*'];
$Font= $_POST['Font*'];
$Capitalization= $_POST['Capitalization*'];
$Proof= $_POST['Proof*'];
$Layout= $_POST['Layout*'];
$Logo= $_POST['Logo'];
$SpecialInstructions= $_POST['SpecialInstructions'];
//echo "Done"; exit;
$arg = "INSERT INTO `healypla_general`.`QuoteRequests` (`Quote_Id`, `FirstName`, `LastName`, `Company`, `Phone`, `Fax`, `Email`, `PONumber`, `Address`, `ApartmentOrUnitNumber`, `City`, `State`, `Zip`, `Quantity`, `Height`, `Width`, `Characters`, `AdditionalCharacters`, `Metal`, `Border`, `Texture`, `Color`, `Finish`, `Mounting`, `Font`, `Capitalization`, `Proof`, `Layout`, `Logo`, `SpecialInstructions`, `DateSubmitted`)
VALUES (NULL, '$FirstName ', '$LastName', '$Company', '$Phone', '$Fax', '$Email', '$PONumber', '$Address', '$ApartmentOrUnitNumber', '$City', '$State', '$Zip', '$Quantity', '$Height', '$Width', '$Characters', '$AdditionalCharacters', '$Metal', '$Border', '$Texture', '$Color', '$Finish', '$Mounting', '$Font', '$Capitalization', '$Proof', '$Layout', '$Logo', '$SpecialInstructions', CURRENT_TIMESTAMP);";
$newdb = new DB($dbhost, $dbuser, $dbpass, $dbname);
$arg = $arg;
$result1 = $newdb->insert_db($arg);
}
$redirect = $newformdata->referrer;
if ($_SESSION['formerrors']) { header("Location: $redirect"); } else {
echo "Done";}
exit;
?>
$FirstName= $_POST['FirstName*'];
$LastName= $_POST['LastName*'];
$Company= $_POST['Company'];
$Phone= $_POST['Phone*'];
$Fax= $_POST['Fax'];
$Email= $_POST['Email*'];
$PONumber= $_POST['PONumber'];
$Address= $_POST['Address*'];
$City= $_POST['City*'];
$State= $_POST['State*'];
$Zip= $_POST['Zip*'];
$Quantity= $_POST['Quantity*'];
$Height= $_POST['Height*'];
$Width= $_POST['Width*'];
$Characters= $_POST['Characters*'];
$AdditionalCharacters= $_POST['AdditionalCharacters'];
$Metal= $_POST['Metal*'];
$Border= $_POST['Border*'];
$Texture= $_POST['Texture*'];
$Color= $_POST['Color*'];
$Finish= $_POST['Finish*'];
$Mounting= $_POST['Mounting*'];
$Font= $_POST['Font*'];
$Capitalization= $_POST['Capitalization*'];
$Proof= $_POST['Proof*'];
$Layout= $_POST['Layout*'];
$Logo= $_POST['Logo'];
$SpecialInstructions= $_POST['SpecialInstructions'];
Then there is a settings php which reads
<?
//Global settings
//Handles what to do with form data after it has been validated
//email or database
$send_form_data = 'email/db';
//Email settings
//Where to send email
$to = 'sales@healyplaques.com';
//Where it came from
$from = 'quote';
//Subject of email
$subject = 'Custom Plaque Quote - ';
//Database settings
?>
I appreciate any help in advance and thank you for your time 🙂
-Amanda Smith