Hi everyone, I have been racking my brains trying to get a simple maiform script to work. I keep getting an Internal Server Error 500. I have the file in the cgi-bin, I have chmod permissions set correctly and my form input tags are correct and yet nothing. Does it matter if I upload in Binary or Ascii? I'm including the php code for the form, plus my HTML tags. Any help would be fabulous. I want to be able to reuse the script simply by changing email to send data, and thank you redirect page. Thanks ahead of time!! Yolanda HTML TAGS: (and yes, I have: email not E-Mail) <FORM method="POST" action="http://www.patzcuarolake.com/cgi-bin/mailform.php"> <INPUT type="hidden" name="recipient" value="famalli@hotmail.com"> <INPUT type="hidden" name="subject" value="Real Estate Information Request"> <INPUT type="hidden" name="redirect" value="http://www.patzcuarolake.com/cambrons_realestate_thankyou.htm"> <INPUT type="hidden" name="required" value="name,email,day_phone"> <INPUT type="hidden" name="print_config" value="email,subject"> <INPUT type="hidden" name="print_blank_fields" value="1"> PHP SCRIPT: <?php /********************************************************************* * >>>> DO NOT CHANGE THIS FILE OR IT MIGHT NOT WORK <<<< * >>>> WE WILL NOT SUPPORT THIS SCRIPT IF IT IS <<<< * >>>> ALTERED IN ANY WAY FROM IT'S ORIGINAL FORM <<<< * 1.) Verify they are coming from our server * 2.) Get the current Time * 3.) Get all variables from Get and Post * 4.) Make sure they entered all required fields * 5.) Send Email * 6.) Print HTML/redirect to proper page * * change this line to $debug = true; if you want to enable debugging*/ $debug = false; /********************************************************************/ if($debug) { echo "<pre>"; echo "GET Variables:"; print_r($_GET); echo "POST Variables:"; print_r($_POST); echo "</pre>"; error_reporting(E_ALL); } else { error_reporting(0); } /********************************************************************* * 1.) Verify they came from our server. *********************************************************************/ //get just the domain name from the referer and server we are on $referer=preg_replace('/^http:\/\//','',$_SERVER['HTTP_REFERER']); $referer=preg_replace('/\/.*/','',$referer); $referer=preg_replace('/^www./','',$referer); $server=preg_replace('/^www./','',$_SERVER['SERVER_NAME']); //if server does not match referer, print error page if($referer!=$server) { error($server,"Bad Referer. You can only send email through this script if you use a form on this domain.<br> If you are using a form on this domain, and still get this message, try disabling any<br> firewalls you have running, it could be blocking the headers this script checks before sending mail."); } /********************************************************************* * 2.) Get the current Time. *********************************************************************/ $date=date("l, F dS, Y \a\\t H:i:s"); /********************************************************************* * 3.) Get all variables from Get & Post put them into $fields array *********************************************************************/ if($_SERVER['REQUEST_METHOD']=="GET") { foreach($_GET as $name=>$value) { $fields[$name]=$value; } } elseif($_SERVER['REQUEST_METHOD']=="POST") { foreach($_POST as $name=>$value) { $fields[$name]=$value; } } else { error($server,"Unkown method. You must specify method=\"GET\" or method=\"POST\" in order for the mailform script to work."); } /********************************************************************* * 4.) Make sure they entered all required fields *********************************************************************/ $config=array("recipient","subject","email","realname","redirect","required", "env_report","sort","print_config","print_blank_fields","title","return_link_url", "return_link_title","missing_fields_redirect","background","bgcolor", "text_color","link_color","vlink_color","alink_color"); if(isset($fields['required'])) { $required=preg_split("/,/",$fields['required']); } else { $required=array(); } //make sure they at least have the email and receipient fields array_push($required,'email'); array_push($required,'recipient'); $required = array_unique($required); $field_keys=array_keys($fields); $missing=""; foreach($required as $value) { if(!$fields[$value] && $fields[$value]!="0"){ $missing.="<li>$value</li>"; } } //if they have missing fields if($missing) { //if they have their own missing fields page, direct them there if(isset($fields['missing_fields_redirect'])) { header("Location: ".$fields['missing_fields_redirect']); exit; } else { error($server,"You have not filled in all of the required fields. The missing fields are:<br> <ul>$missing</ul>"); } } //if the email address looks invalid if(!eregi("([_\.0-9a-z-]+@)([0-9a-z][0-9a-z-]+\.)+([a-z]{2,3})", $fields['email'])) { error($server,"Please enter a valid email address."); } foreach($config as $value) { if(preg_match("/\~|\`|\#|\%|\^|\&|\*|\(|\)|\+|\=|\{|\}|\[|\]|\<|\>|\;|\|/",$fields[$value])) { error($server, "Invalid Charaters detected in $value. You may not use any of these characters<br> ~ \` # $ % ^ & * ( ) + = { } [ ] < > ; | <br> In the form fields."); } } /********************************************************************* * 5.) Send Email *********************************************************************/ //sort fields, if needed if(isset($fields['sort'])) { if($fields['sort']=="alphabetic") { ksort($fields); } else { $fields['sort']=preg_replace('/^order:/','',$fields['sort']); $sort_order=preg_split("/,/",$fields['sort']); foreach($sort_order as $value) { $temp[$value]=$fields[$value]; } $temp_keys=array_keys($temp); foreach($fields as $name=>$value) { if(!in_array($value,$temp_keys)) { $temp[$name]=$value; } } $fields=$temp; } } //end of sort routine //create body of email message $body="Below is the result of your feedback form on www.$server. It was submitted by\n"; if(isset($fields['realname'])) { $body.=$fields['realname']." (".$fields['email'].")"; } else { $body.=$fields['email']; } $body.=" on $date \n"; $body.="---------------------------------------------------------------------------\n"; //don't print config fields: //unless they have print_config set if(isset($fields['print_config'])) { $print_config=preg_split("/,/",$fields['print_config']); $config=array_diff($config,$print_config); } foreach($fields as $name=>$value) { if(!in_array($name,$config)) { $body.="$name: $value\n"; } } $body.="---------------------------------------------------------------------------\n"; //Print off the env_report if that is set if(isset($fields['env_report'])) { $env_fields=preg_split("/,/",$fields['env_report']); foreach($env_fields as $value) { if(isset($_SERVER[$value])) { $body.="$value: ".$_SERVER[$value]."\n"; } } } //set the subject if one doesn't exist if(!isset($fields['subject'])) { $fields['subject']="www.$server Form Submission"; } //Finally, send the message! mail($fields['recipient'], $fields['subject'], $body, "From: ".$fields['email']); if($debug) { echo "<pre>"; echo "Email being sent:<br>"; print_r($body); echo "</pre>"; } /********************************************************************* * 6.) Print HTML/redirect to proper page *********************************************************************/ //if they set a redirect page, send user there if(isset($fields['redirect'])) { header("Location: ".$fields['redirect']); } //Set some default values if they are not set if(!isset($fields['print_blank_fields'])) { $fields['print_blank_fields']=1; } if(!isset($fields['title'])) { $fields['title']="Thank You!"; } if(!isset($fields['bgcolor'])) { $fields['bgcolor']="#ececec"; } if(!isset($fields['text_color'])) { $fields['text_color']="#000000"; } if(!isset($fields['link_color'])) { $fields['link_color']="#000000"; } if(!isset($fields['vlink_color'])) { $fields['vlink_color']="#000000"; } if(!isset($fields['alink_color'])) { $fields['alink_color']="#000000"; } echo <<<TERMHTML <html> <head> <title>Thank You for contacting $server</title> </head> <body bgcolor="$fields[bgcolor]" text="$fields[text_color]" link="$fields[link_color]" vlink="$fields[vlink_color]"> <center> <table border="1" bordercolor="#000000" width="600" cellpadding="4"> <tr> <td bgcolor="#FEA096"> <font face="arial" size="4" color="$fields[text_color]"><b><center>Here is what you submitted to $server on $date</center></b></font> </td> </tr> <tr> <td> TERMHTML; foreach($fields as $name=>$value) { if(!in_array($name,$config) && ($value || $fields['print_blank_fields'])) { echo "<b>$name:</b> $value<br>"; } } if(isset($fields['return_link_url']) && isset($fields['return_link_title'])) { echo "<ul><li><a href=\"$fields[return_link_url]\" target=\"_top\">$fields[return_link_title]</a></ul>"; } echo <<<TERMHTML <font face="arial" size="2"></font></td> </tr> </table><br><a href="http://www.$server">Click here to return to our main page</a></b> </body> </html> TERMHTML; /********************************************************************* * Function: Error($server,$value) * purpose: print off the error message in $value, nice and neat * Then exit program. *********************************************************************/ function error($server, $value) { echo <<<TERMHTML <html> <head><title>$server Mailform Error</title></html> <body bgcolor="$fields[bgcolor]" text="$fields[text_color]" link="$fields[link_color]" vlink="$fields[vlink_color]"> <center> <table border="1" bordercolor="#000000" width="600" cellpadding="4"> <tr> <td bgcolor="#FEA096"> <font face="arial" size="4" color="$fields[text_color]"><b><center>$server Mailform Error</center></b></font> </td> </tr> <tr> <td><b>$value</b> </td> </tr> </table><br><b>Your IP is $_SERVER[REMOTE_ADDR]</b> </center> </body> </html> TERMHTML; exit; } ?>
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или законы РФ. Ваш ip-адрес записывается.
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или законы РФ. Ваш ip-адрес записывается.
If you would like to report an abuse of our service, such as a spam message, please . Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .