I’ve never worked in php but I’ve had to take over a website that has php forms. Can someone look at this and tell me why it’s not working? Thanks!
[php]<?php include(‘db_connect.php’);
if($_POST['Submit']=='Submit' && !empty($fname) && !empty($lname) && !empty($phone) && !empty($email) && !empty($proj_type)) {
$sql = "INSERT INTO `design_proposal` (`design_proposal_id`,`fname`,`lname`,`phone`,`email`, `proj_type`,`concern`,`contact`) VALUES (NULL,'".mysql_real_escape_string($fname)."','".mysql_real_escape_string($lname)."','".mysql_real_escape_string($phone)."','".mysql_real_escape_string($email)."', '".mysql_real_escape_string($proj_type)."','".mysql_real_escape_string($concern)."','".mysql_real_escape_string($contact)."');";
include('db_connect.php');
$result = mysql_query($sql);
if($result) {
$msg3 .= "<p class=\"formmessagegreen\">Thank you! You have been successful at sending your design proposal.</p>";
} else {
$msg .= "<p class=\"formmessagered\">I'm sorry there was an error sending your design proposal.</p>";
}
if($_POST['contact']=='Yes') {
$concern = stripslashes($_POST['concern']);
$to = '[email protected]';
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";//html based emails
$header .="From: ".$email. "\r\n";
$body = "<html><body>" .$fname." ".$lname."<br /> Email: ".$email. "<br /> Phone: ".$phone."<br /> Project Type: ".$proj_type. "<br /> Concern: " .$concern."<br /> Contact: " .$contact. "</body></html>";
$subject = "Feedback for Free Design Proposal";
$to1 = $email;
$header1 = 'MIME-Version: 1.0' . "\r\n";
$header1 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";//html based emails
$header1 .='From: [email protected]';
$body1 = "<html><body>Thank you for contacting BuildTREND. We will be in touch very soon to discuss your project and to answer your questions. <br>
We are here to make your project and your home exceptional!<br>
If you have any questions or would like to talk to us now, please call 1-800-959-7725 or email me at [email protected]<br><br>
Best regards,<br>
Shawn T. Gerety<br>
President & CEO <br />
www.buildtrend.com <br />
<img src=\"http://www.buildtrend.com/images/BuildTREND-LOGO-DP.jpg\" alt=\"BuildTREND Logo\" width=\"395\" height=\"56\"/></body></html>";
$subject1 = "Thank you ".$fname." ".$lname."!";
//Sends mail to me, with elements created above
$success = mail ($to, $subject, $body, $header) && mail ($to1, $subject1, $body1, $header1);
} else {
$concern = stripslashes($_POST['concern']);
$to = '[email protected], [email protected]';
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";//html based emails
$header .="From: ".$email. "\r\n";
$body = "<html><body>" .$fname." ".$lname."<br / Email: > ".$email. "<br /> Phone: " .$phone. "<br /> Concern: ".$concern."<br /> Contact: No</body></html>";
$subject = "Free Design Propsal";
$to1 = $email;
$header1 = 'MIME-Version: 1.0' . "\r\n";
$header1 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";//html based emails
$header1 .='From: [email protected]';
$body1 = "<html><body>Thank you for visiting our website. We hope you found it helpful and informative! If there is one thing that we hope you took from your time with <br>
<br><br>
Best regards,<br>
<br>
President & CEO <br>
<img src=\"http://www.buildtrend.com/images/BuildTREND-LOGO-DP.jpg\" alt=\"BuildTREND Logo\" width=\"395\" height=\"56\"/></body></html>";
$subject1 = "Thank you ".$fname." ".$lname."!";
$success = mail ($to, $subject, $body, $header) && mail ($to1, $subject1, $body1, $header1);
}
} else {
switch (true) {
case (!empty($email)):
$msg ="Please enter an email address.";
$msg2= "class=\"asterisk\"";
break;
case (!empty($phone)):
$msg ="Please enter a phone number.";
$msg2= "class=\"asterisk\"";
break;
case (!empty($fname)):
$msg ="Please enter your first name.";
$msg2= "class=\"asterisk\"";
break;
case (!empty($lname)):
$msg ="Please enter your last name.";
$msg2= "class=\"asterisk\"";
break;
case (!empty($proj_type)):
$msg ="Please Enter your project type.";
$msg2= "class=\"asterisk\"";
break;
default:
$msg = "formmessage";
$msg2 = "class=\"asterisk1\"";
}
}
?>[/php]
form
[code]
Get Your Free Design Proposal!
<?php echo $msg3; echo $con . $mysql_error; ?>
<p class="<?php echo $msg;?>">Please fill in all the required fields.</p>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data" name="Design Proposal" id="Design Proposal">
<p> First Name <span <?php echo $msg2; ?>>*</span><br>
Last Name >*
Phone >*
Email >*
Tye of Project >*
Bath Remodeling
Basement Finishing
Custom Cabinetry
Kitchen Remodeling
Other
Biggest Remodeling Concern
Please have someone call me about my project
Please Don't Forget To Share!
SERVICES |
SERVICE AREAS |
SERVICE AREAS CONT... |
CONTACT US |