Can someone help me get my form workings? I have been beating my head against the wall on this.
the link is here . The form is at the bottom of the page. Thanks
Webmaster Resources .::. Webmaster Forums .::. Fuel Saver
Can someone help me get my form workings? I have been beating my head against the wall on this.
the link is here . The form is at the bottom of the page. Thanks
Webmaster Resources .::. Webmaster Forums .::. Fuel Saver
Suzanne posted this at 17:21 — 29th December 2003.
She has: 5,512 posts
Joined: Feb 2000
What is the problem? The form seems to be displaying? If the problem is in feedback.php I can move this to the scripting forum for you.
love me, love my brain :: iStockphoto portfolio
ronhollin posted this at 19:17 — 29th December 2003.
They have: 121 posts
Joined: Apr 2003
Yes I believe that is the problem. I am not getting the email. Thank you.
Suzanne posted this at 19:29 — 29th December 2003.
She has: 5,512 posts
Joined: Feb 2000
let's see what's inside that feedback.php file, then, see if we can fix it up for you.
ronhollin posted this at 01:12 — 20th January 2004.
They have: 121 posts
Joined: Apr 2003
I'm sorry Suzanne, I've been unable to post lately, but here is the feedback.php file. Thanks
<?php
// $recipient="sales@sunglassreplicas.com"; Make double sure of security...
// Note - reset below (triple sure)
// referers.. domains/ips that you will allow forms to
$referers = array ('www.sunglassreplicas.com','sunglassreplicas.com'); // Show error// reside on.
function print_error($reason,$type = 0) {
echo "<html><head>";
echo "<title>Sunglass Replica Link Partner - Error</title>\n";
echo "</head><body>\n\n";
// for missing required data
if ($type == "missing") {
?>
The form was not submitted for the following reasons:
<?phpecho $reason."\n";
?>
Please close this window to return to the form and try again.
<?php
} else { // every other error
?>
The form was not submitted because of the following reasons:
<?php
echo $reason."\n";
}
echo "\n";
exit;
}
// function to check the referer for security reasons.
// contributed by some one who's name got lost.. Thanks
// goes out to him any way.
function check_referer($referers) {
if (count($referers)) {
$found = false;
$temp = explode("/",getenv("HTTP_REFERER"));
$referer = $temp[2];
for ($x=0; $x < count($referers); $x++) {
if (eregi ($referers[$x], $referer)) {
$found = true;
}
}
if (!getenv("HTTP_REFERER"))
$found = false;
if (!$found){
print_error("You are coming from an unauthorized domain.");
error_log("[FormMail.php] Illegal Referer. (".getenv("HTTP_REFERER").")", 0);
}
return $found;
} else {
return true; // not a good idea, if empty, it will allow it.
}
}
if ($referers)
check_referer($referers);
// parse the form and create the content string which we will send
function parse_form($array) {
// build reserved keyword array
$reserved_keys[] = "MAX_FILE_SIZE";
$reserved_keys[] = "required";
$reserved_keys[] = "redirect";
// $reserved_keys[] = "email";
$reserved_keys[] = "submit"; /* added */
$reserved_keys[] = "require";
$reserved_keys[] = "path_to_file";
$reserved_keys[] = "recipient";
$reserved_keys[] = "subject";
$reserved_keys[] = "bgcolor";
$reserved_keys[] = "text_color";
$reserved_keys[] = "link_color";
$reserved_keys[] = "vlink_color";
$reserved_keys[] = "alink_color";
$reserved_keys[] = "title";
$reserved_keys[] = "missing_fields_redirect";
$reserved_keys[] = "env_report";
if (count($array)) {
while (list($key, $val) = each($array)) {
// exclude reserved keywords
$reserved_violation = 0;
for ($ri=0; $riI NEED VALID RECIPIENT EMAIL ADDRESS ($HTTP_POST_VARS['recipient']) ($recipient_to_test) TO CONTINUE");
}
}
// This is because I originally had it require but too many people
// were used to Matt's Formmail.pl which used required instead.
if ($required)
$require = $required;
// handle the required fields
if ($require) {
// seperate at the commas
$require = ereg_replace( " +", "", $require);
$required = split(",",$require);
for ($i=0;$iMissing: $required[$i]\n";
}
}
if ($missing_field_list)
print_error($missing_field_list,"missing");
}
// check the email fields for validity
if (($email) || ($EMAIL)) {
$email = trim($email);
if ($EMAIL)
$email = trim($EMAIL);
if (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $email)) {
print_error("your email address is invalid");
}
$EMAIL = $email;
}
// prepare the content
if (!isset($_SERVER)) {
$_GET = &$HTTP_GET_VARS;
$_POST = &$HTTP_POST_VARS;
$_ENV = &$HTTP_ENV_VARS;
$_SERVER = &$HTTP_SERVER_VARS;
$_COOKIE = &$HTTP_COOKIE_VARS;
$_REQUEST = array_merge($_GET, $_POST, $_COOKIE);
}
$content = parse_form($_POST);
// if the subject option is not set: set the default
if (!$subject)
$subject = "Form submission";
// send it off
mail_it(stripslashes($content), stripslashes($subject), $email, $recipient);
// if the redirect option is set: redirect them
if ($redirect) {
header ("Location: $redirect");
exit;
} else {
print "Thank you for your submission\n";
echo "\n";
exit;
}
// <---------- THE END ----------> //
Webmaster Resources .::. Webmaster Forums .::. Fuel Saver
Suzanne posted this at 02:01 — 20th January 2004.
She has: 5,512 posts
Joined: Feb 2000
before I go digging, is the closing ?> on the file?
Suzanne posted this at 02:30 — 20th January 2004.
She has: 5,512 posts
Joined: Feb 2000
This is a lot of code -- I went through it and tried to fix it by indenting the code so I can see but I can't work on it further tonight. Hopefully others can use this code to find the problem for you:
<?php // reset recipient variable for security (why not only set it here?!)$recipient="sales@sunglassreplicas.com\";
// referers.. domains/ips that you will allow forms to reside on.
$referers = array ('www.sunglassreplicas.com','sunglassreplicas.com');
// Show error
function print_error($reason,$type = 0) {
echo<<<HEADER
<html>
<head>
<title>Sunglass Replica Link Partner - Error</title>
</head>
<body>
HEADER;
// for missing required data
if ($type == \"missing\") {
echo<<<ERROR
<p>The form was not submitted for the following reasons:</p>
<p>$reason</p>
<p>Please close this window to return to the form and try again.</p>
ERROR;
}
else { // every other error
echo<<<ERROR
<p>The form was not submitted because of the following reasons:</p>
<p>$reason</p>
ERROR;
}
echo<<<FOOTER
</body>
</html>
FOOTER;
exit;
}
// function to check referer for security reasons.
function check_referer($referers) {
if (count($referers)) {
$found = false;
$temp = explode(\"/\",getenv(\"HTTP_REFERER\"));
$referer = $temp[2];
for ($x=0; $x < count($referers); $x++) {
if (eregi ($referers[$x], $referer)) {
$found = true;
}
}
if (!getenv(\"HTTP_REFERER\"))
$found = false;
if (!$found) {
print_error(\"You are coming from an <b>unauthorized domain.</b>\");
error_log(\"[FormMail.php] Illegal Referer. (\".getenv(\"HTTP_REFERER\").\")\", 0);
}
return $found;
} else {
return true; // not a good idea, if empty, it will allow it.
}
}
}
if ($referers) check_referer($referers);
// parse the form and create the content string which we will send
function parse_form($array) {
// build reserved keyword array
$reserved_keys[] = \"MAX_FILE_SIZE\";
$reserved_keys[] = \"required\";
$reserved_keys[] = \"redirect\";
// $reserved_keys[] = \"email\";
$reserved_keys[] = \"submit\"; /* added */
$reserved_keys[] = \"require\";
$reserved_keys[] = \"path_to_file\";
$reserved_keys[] = \"recipient\";
$reserved_keys[] = \"subject\";
$reserved_keys[] = \"bgcolor\";
$reserved_keys[] = \"text_color\";
$reserved_keys[] = \"link_color\";
$reserved_keys[] = \"vlink_color\";
$reserved_keys[] = \"alink_color\";
$reserved_keys[] = \"title\";
$reserved_keys[] = \"missing_fields_redirect\";
$reserved_keys[] = \"env_report\";
if (count($array)) {
while (list($key, $val) = each($array)) {
// exclude reserved keywords
$reserved_violation = 0;
for ($ri=0; $ri<count($reserved_keys); $ri++) {
if ($key == $reserved_keys[$ri]) {
$reserved_violation = 1;
}
}
// prepare content
if ($reserved_violation != 1) {
if (is_array($array[$val])) {
for ($z=0;$z<count($array[$key]);$z++) {
$content .= \"$key: $array[$key][$z]\n\";
}
} else {
$content .= \"$key: $array[$key]\n\";
}
}
}
}
return $content;
}
// mail the content we figure out in the following steps
function mail_it($content, $subject, $email, $recipient) {
$recipient=\"sales@sunglassreplicas.com\"; // repeat
mail($recipient, $subject, $content, \"From: $email\r\nReply-To: $email\r\nX-Mailer: DT_formmail\");
}
// set up variables
$website_url = $_POST['website_url'];
$website_title = $_POST['website_title'];
$description = $_POST['description'];
$reciprocal_link = $_POST['reciprocal_link'];
$contact_name = $_POST['contact_name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$required = $_POST['required'];
$subject = $_POST['subject'];
$redirect = $_POST['redirect'];
// check for a recipient email address and check the validity of it
$recipient = $_POST['recipient'];
$recipient_in = split(',',$recipient);
for ($i=0;$i<count($recipient_in);$i++) {
$recipient_to_test = trim($recipient_in[$i]);
if (!eregi(\"^[_\\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\\.)+[a-z]{2,3}$\", recipient_to_test)) {
print_error(\"<b>I NEED VALID RECIPIENT EMAIL ADDRESS ($HTTP_POST_VARS['recipient']) ($recipient_to_test) TO CONTINUE</b>\");
}
}
// This is because I originally had it require but too many people
// were used to Matt's Formmail.pl which used required instead.
if ($required) $require = $required;
// handle the required fields
if ($require) {
// seperate at the commas
$require = ereg_replace( \" +\", \"\", $require);
$required = split(\",\",$require);
for ($i=0;$i<count($required);$i++) {
$string = trim($required[$i]);
// check if they exsist
if( (!(${$string})) || ('http://' == (${$string})) ) {
// if the missing_fields_redirect option is on: redirect
if ($missing_fields_redirect) {
header (\"Location: $missing_fields_redirect\");
exit;
}
$require;
$missing_field_list .= \"<b>Missing: $required[$i]</b><br>\n\";
}
}
if ($missing_field_list) print_error($missing_field_list,\"missing\");
// check the email fields for validity
if (($email) || ($EMAIL)) {
$email = trim($email);
if ($EMAIL) $email = trim($EMAIL);
if (!eregi(\"^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$\", $email)) {
print_error(\"your <b>email address</b> is invalid\");
}
$EMAIL = $email;
}
// prepare the content
if (!isset($_SERVER)) {
$_GET = &$HTTP_GET_VARS;
$_POST = &$HTTP_POST_VARS;
$_ENV = &$HTTP_ENV_VARS;
$_SERVER = &$HTTP_SERVER_VARS;
$_COOKIE = &$HTTP_COOKIE_VARS;
$_REQUEST = array_merge($_GET, $_POST, $_COOKIE);
}
$content = parse_form($_POST);
// if the subject option is not set: set the default
if (!$subject) $subject = \"Form submission\";
// send it off
mail_it(stripslashes($content), stripslashes($subject), $email, $recipient);
// if the redirect option is set: redirect them
if ($redirect) {
header (\"Location: $redirect\");
exit;
} else {
print \"Thank you for your submission\n\";
echo \"<br><br>\n\";
exit;
}
// <---------- THE END ----------> //
?>
love me, love my brain :: iStockphoto portfolio
ronhollin posted this at 02:34 — 20th January 2004.
They have: 121 posts
Joined: Apr 2003
That was very kind of you. Yes maybe someone will lend me a hand.
druagord posted this at 14:44 — 20th January 2004.
He has: 335 posts
Joined: May 2003
And what do you get as an output when you post ?
i have seen something in this function i don't think this is your problem but it could cause errors
function parse_form($array) {// build reserved keyword array
$reserved_keys[] = "MAX_FILE_SIZE";
$reserved_keys[] = "required";
$reserved_keys[] = "redirect";
// $reserved_keys[] = "email";
$reserved_keys[] = "submit"; /* added */
$reserved_keys[] = "require";
$reserved_keys[] = "path_to_file";
$reserved_keys[] = "recipient";
$reserved_keys[] = "subject";
$reserved_keys[] = "bgcolor";
$reserved_keys[] = "text_color";
$reserved_keys[] = "link_color";
$reserved_keys[] = "vlink_color";
$reserved_keys[] = "alink_color";
$reserved_keys[] = "title";
$reserved_keys[] = "missing_fields_redirect";
$reserved_keys[] = "env_report";
if (count($array)) {
// moved here
$reserved_violation = 0;
while (list($key, $val) = each($array)) {
// exclude reserved keywords
// this goes out of the loop $reserved_violation = 0;
for ($ri=0; $ri<count($reserved_keys); $ri++) {
if ($key == $reserved_keys[$ri]) {
$reserved_violation = 1;
}
}
// prepare content
if ($reserved_violation != 1) {
if (is_array($array[$val])) {
for ($z=0;$z<count($array[$key]);$z++) {
$content .= "$key: $array[$key][$z]\n";
}
} else {
$content .= "$key: $array[$key]\n";
}
}
}
}
return $content;
}
'
IF , ELSE , WHILE isn't that what life is all about
ronhollin posted this at 14:57 — 20th January 2004.
They have: 121 posts
Joined: Apr 2003
I'm not sure what you are refering to druagord.
druagord posted this at 15:00 — 20th January 2004.
He has: 335 posts
Joined: May 2003
You have to move the $reserved_violation =0 out of the while loop
Mark Hensler posted this at 17:55 — 20th January 2004.
He has: 4,044 posts
Joined: Aug 2000
<?phpfunction parse_form($array) {
// build reserved keyword array
$reserved_keys[] = "MAX_FILE_SIZE\";
$reserved_keys[] = \"required\";
$reserved_keys[] = \"redirect\";
// $reserved_keys[] = \"email\";
$reserved_keys[] = \"submit\"; /* added */
$reserved_keys[] = \"require\";
$reserved_keys[] = \"path_to_file\";
$reserved_keys[] = \"recipient\";
$reserved_keys[] = \"subject\";
$reserved_keys[] = \"bgcolor\";
$reserved_keys[] = \"text_color\";
$reserved_keys[] = \"link_color\";
$reserved_keys[] = \"vlink_color\";
$reserved_keys[] = \"alink_color\";
$reserved_keys[] = \"title\";
$reserved_keys[] = \"missing_fields_redirect\";
$reserved_keys[] = \"env_report\";
$content = '';
foreach ($reserved_keys as $key) {
if (isset($array[$key])) {
if (is_array($array[$key])) {
for ($z=0;$z<count($array[$key]);$z++) {
$content .= \"$key: $array[$key][$z]\n\";
}
}
else {
$content .= \"$key: $array[$key]\n\";
}
}
}
return $content;
}
?>
Mark Hensler ["Max Albert"] [Email]
If there is no answer on Google, then there is no question.