Attention: danilo Re: Spry Tabbed Panel Dilemma
Okay. I understand conceptually what you are saying. At this point in time I haven't built up enough technical expertise in PHP, though I am begging to learn. (Would you recommend a good book for me).
The form processing code is as follows:<?php
if (array_key_exists('send', $_POST)) {
//mail processing script
// remove escape characters from POST array
if (PHP_VERSION < 6 && get_magic_quotes_gpc()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
}
$to = 'jojotoronald@aol.com'; //use your own email address
$subject = 'Contact information for quote on job';
// list expected fields
$expected = array('name', 'business', 'addressStreet', 'city', 'state', 'zip', 'phone', 'email', 'inquire');
// set required fields
$required = array('name', 'business', 'addressStreet', 'city', 'state', 'zip', 'phone', 'email', 'inquire');
// create empty array for any missing fields
$missing = array();
// assume that there is nothing suspect
$suspect = false;
// create a pattern to locate suspect phrases
$pattern = '/Content-Type:|Bcc:|Cc:/i';
// function to check for suspect phrases
function isSuspect($val, $pattern, &$suspect) {
// if the variable is an array, loop through each element
// and pass it recursively back to the same function
if (is_array($val)) {
foreach ($val as $item) {
isSuspect($item, $pattern, $suspect);
}
}
else {
// if one of the suspect phrases is found, set Boolean to true
if (preg_match($pattern, $val)) {
$suspect = true;
}
}
}
// check the $_POST array and any subarrays for suspect content
isSuspect($_POST, $pattern, $suspect);
if ($suspect) {
$mailSent = false;
unset($missing);
} else {
// process the $_POST variables
foreach ($_POST as $key => $value) {
// assign to temporary variable and strip whitespace if not an array
$temp = is_array($value) ? $value : trim($value);
// if empty and required, add to $missing array
if (empty($temp) && in_array($key, $required)) {
array_push($missing, $key);
} elseif (in_array($key, $expected)) {
// otherwise, assign to a variable of the same name as $key
${$key} = $temp;
}
}
}
// go ahead only if not suspect and all required fields OK
if (!suspect && empty($missing)) {
//build the message
$message = "Name: $name\r\n\r\n";
$message .= "Firm's name: $business\r\n\r\n";
$message .= "Street address: $addressStreet\r\n\r\n";
$message .= "City: $city\r\n\r\n";
$message .= "State: $state\r\n\r\n";
$message .= "Zip code: $zip\r\n\r\n";
$message .= "Phone number: $phone\r\n\r\n";
$message .= "Email address: $email\r\n\r\n";
$message .= "Nature of inquiry: $inquire";
// limit line lenght to 70 characters
$message = wordwrap($message, 70);
// send it
$mailSent = mail($to, $subject, $message);
if ($mailSent) {
// $missing is no longer needed if the email is sent, so unset it
unset($missing);
}
}
}
Where and how do I set the code for $tabToShow and what would that code be. Much thanks in advance. Ronald