Code doesn't generate anything. Beginner help.

I have a small form for contact us that works just fine. Does exactly what I want it to do.
Expanded code to create a longer form and somehow managed to mess it up. Could someone look at code. Fairly simple but I’m sure a syntax error is causing the problem where the expanded versioin fails. Here is Code:
[php]<?php
if(isset($_POST[‘email’])) {

// CHANGE THE TWO LINES BELOW
$email_to = "MyEmail.com";
 
$email_subject = "Questionnaire submission from myurl.com";
 
 
function died($error) {
    // your error code can go here
    echo "We are very sorry, but there were error(s) found with the form you submitted. ";
    echo "These errors appear below.<br /><br />";
    echo $error."<br /><br />";
    echo "Please go back and fix these errors.<br /><br />";
    die();
}
 
// validation expected data exists
if(!isset($_POST['first_name']) ||
    !isset($_POST['last_name']) ||
    !isset($_POST['email_from']) ||
    !isset($_POST['comments'])) {
    died('We are sorry, but there appears to be a problem with the form you submitted.');       
} 
     
 
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name']; 
$email_from = $_POST['email_from'];
$telephone = $_POST['telephone']; 
$fax = $_POST['fax']; 
$address = $_POST['address']; 
$city = $_POST['city']; 
$state = $_POST['state'];
$postal = $_POST['postal'];
$webdev = $_POST['webdev'];
$customdesign = $_POST['customdesign']; 
$logodesign = $_POST['logodesign']; 
$facebook = $_POST['facebook']; 
$webmaint = $_POST['webmaint']; 
$redesign = $_POST['redesign']; 
$domain = $_POST['domain']; 
$budget = $_POST['budget']; 
$deadline = $_POST['deadline'];
$newdesign = $_POST['newdesign'];
$redesignexisting = $_POST['redesignexisting'];
$existingcontent = $_POST['existingcontent']; 
$addingnewcontent = $_POST['addingnewcontent']; 
$busmodel = $_POST['busmodel']; 
$servicesprovided = $_POST['servicesprovided']; 
$howmanypages = $_POST['howmanypages']; 
$targetaudience = $_POST['targetaudience'];
$specialneeds = $_POST['specialneeds']; 
$entertainment = $_POST['entertainment'];
$increasesales = $_POST['increasesales'];
$brandrecog = $_POST['brandrecog']; 
$internalcomm = $_POST['internalcomm'];
$servicecalls = $_POST['servicecalls']; 
$increasebase = $_POST['increasebase']; 
$primarymessage = $_POST['primarymessage'];
$specificdesign = $_POST['specificdesign']; 
$interactivity = $_POST['interactivity']; 
$projectedimage = $_POST['projectedimage'];
$lookandfeel = $_POST['lookandfeel']; 
$sitesliked = $_POST['sitesliked']; 
$compsitesliked = $_POST['compsitesliked'];
$logo = $_POST['logo']; 
$slogan = $_POST['slogan'];
$mission = $_POST['mission'];
$colorscheme = $_POST['colorscheme']; 
$cosymbols = $_POST['cosymbols']; 
$coicons = $_POST['coicons']; 
$coimages = $_POST['coimages']; 
$howmanyimages = $_POST['howmanyimages'];
$imagesbudget = $_POST['imagesbudget']; 
$textcontent = $_POST['textcontent']; 
$devcontent = $_POST['devcontent']; 
$bgimages = $_POST['bgimages'];
$creditcards = $_POST['creditcards']; 
$merchaccount = $_POST['merchaccount'];
$merchaccountname = $_POST['merchaccountname'];
$qtyproducts = $_POST['qtyproducts'];
$updatemaint = $_POST['updatemaint'];
$updatefreq = $_POST['updatefreq']; 
$updatetrain = $_POST['updatetrain'];
$comments = $_POST['comments']; 


 
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';

if(!preg_match($email_exp,$email_from)) {
$error_message .= ‘The Email Address you entered does not appear to be valid.
’;
}
$string_exp = “/^[A-Za-z .’-]+$/”;
if(!preg_match($string_exp,$first_name)) {
$error_message .= ‘The First Name you entered does not appear to be valid.
’;
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= ‘The Last Name you entered does not appear to be valid.
’;
}
if(strlen($comments) < 2) {
$error_message .= ‘The Comments you entered do not appear to be valid.
’;
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = “Questionnaire details below.\n\n”;

function clean_string($string) {
  $bad = array("content-type","bcc:","to:","cc:","href");
  return str_replace($bad,"",$string);
}
 
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Fax: ".clean_string($fax)."\n";
$email_message .= "Address: ".clean_string($address)."\n";
$email_message .= "City: ".clean_string($city)."\n";
$email_message .= "State: ".clean_string($state)."\n";
$email_message .= "Postal: ".clean_string($postal)."\n";
$email_message .= "Web Development: ".clean_string($webdev)."\n";
$email_message .= "Custom Design: ".clean_string($customdesign)."\n";
$email_message .= "Logo Design: ".clean_string($logodesign)."\n";
$email_message .= "Facebook: ".clean_string($facebook)."\n";
$email_message .= "Web Maint: ".clean_string($webmaint)."\n";
$email_message .= "Redesign Site: ".clean_string($redesign)."\n";
$email_message .= "Domain Name: ".clean_string($domain)."\n";
$email_message .= "Budget Amount: ".clean_string($budget)."\n";
$email_message .= "Deadline: ".clean_string($deadline)."\n";
$email_message .= "New Design: ".clean_string($newdesign)."\n";
$email_message .= "Redesign Existing Content: ".clean_string($redesignexisting)."\n";
$email_message .= "Existing Content: ".clean_string($existingcontent)."\n";
$email_message .= "Adding New Content: ".clean_string($addingnewcontent)."\n";
$email_message .= "Business Model: ".clean_string($busmodel)."\n";
$email_message .= "Services Provided: ".clean_string($servicesprovided)."\n";
$email_message .= "How Many Pages: ".clean_string($howmanypages)."\n";
$email_message .= "Target Audience: ".clean_string($targetaudience)."\n";
$email_message .= "Special Needs: ".clean_string($specialneeds)."\n";
$email_message .= "Entertainment: ".clean_string($entertainment)."\n";
$email_message .= "Increase Sales: ".clean_string($increasesales)."\n";
$email_message .= "Brand Recognition: ".clean_string($brandrecog)."\n";
$email_message .= "Internal Communication: ".clean_string($internalcomm)."\n";
$email_message .= "Service Calls: ".clean_string($servicecalls)."\n";
$email_message .= "Increase Customer Base: ".clean_string($increasebase)."\n";
$email_message .= "Primary Message: ".clean_string($primarymessage)."\n";
$email_message .= "Specific Design: ".clean_string($specificdesign)."\n";
$email_message .= "Interactivity': ".clean_string($interactivity)."\n";
$email_message .= "Projected Image: ".clean_string($projectedimage)."\n";
$email_message .= "Look and Feel: ".clean_string($lookandfeel)."\n";
$email_message .= "Sites Liked: ".clean_string($siteliked)."\n";
$email_message .= "Competitive Sites Liked: ".clean_string($compsitesliked)."\n";
$email_message .= "Logo: ".clean_string($logo)."\n";
$email_message .= "Slogan: ".clean_string($slogan)."\n";
$email_message .= "Mission: ".clean_string($mission)."\n";
$email_message .= "Color Scheme: ".clean_string($colorscheme)."\n";
$email_message .= "Company Symbols: ".clean_string($cosymbols)."\n";
$email_message .= "Company Icons: ".clean_string($coicons)."\n";
$email_message .= "Company Images: ".clean_string($coimages)."\n";
$email_message .= "How Many Images: ".clean_string($howmanyimages)."\n";
$email_message .= "Images Budget: ".clean_string($imagesbudget)."\n";
$email_message .= "Text Content: ".clean_string($textcontent)."\n"; 
$email_message .= "Development Content: ".clean_string($devcontent)."\n"; 
$email_message .= "Background Images: ".clean_string($bgimages)."\n"; 
$email_message .= "Credit Cards: ".clean_string($creditcards)."\n"; 
$email_message .= "Merchant Account: ".clean_string($merchaccount)."\n"; 
$email_message .= "Merchant Account Name: ".clean_string($merchaccoountname)."\n"; 
$email_message .= "Quantity of Products: ".clean_string($qtyproducts)."\n"; 
$email_message .= "Update Maintenance: ".clean_string($updatemaint)."\n"; 
$email_message .= "Update Frequency: ".clean_string($updatefreq)."\n"; 
$email_message .= "Update Training: ".clean_string($updatetrain)."\n"; 
$email_message .= "Comments: ".clean_string($comments)."\n"; 

// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
‘X-Mailer: PHP/’ . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

Thank you for contacting Me. We will be in touch with you very soon.

<?php } die(); ?>[/php]

Any help or direction would be greatly appreciated.

Slightly longer? :o

Seriously, I had a website site design class in college that the instructor said that a rule of thumb that there should be only 8-9 input questions per page. I sure hope that you’re not expecting the user to enter it all on one page.

As for the error(s), I have to fix Easter dinner, but I’ll look at it again if someone else hasn’t helped you.

It’s unfortunately a fact finding questionnaire. All fields not required. Maybe only a third will need answered per request. Only required fields are first four and comments. the rest are necessary only in certain circumstances.

First thing first, add this to the top of the page:
[php]
error_reporting(E_ALL);
ini_set(‘display_errors’, ‘1’);[/php]

Post the errors that display back here.

I added lines to top of page. and then went through process, and I got a blank page. Checked source view and there was nothing. Next Step.?

There is a typo on line 170.

below the error reporting lines, add
[php]print_r( $_POST );[/php]

All of your code prays that the post variable value email exists.

added print command still nothing. did fix typo in line 170 two oo’s got it. uploaded still nothing blank page.

Sponsor our Newsletter | Privacy Policy | Terms of Service