metrov Posted January 31, 2007 Share Posted January 31, 2007 Hi, I'm using a Flash email form that uses PHP. However, it's not working, and I suspect it's coz my server uses only PHP4, and this code might be an earlier version of PHP? Would someone be able to tell me what version of PHP this code is? And if it's earlier than 4, how can I convert it to 4? I am not a PHP programmer. Thanks very much. Here is the code in the .php file:<?php/* ---------------------------php and flash contact form. by www.MacromediaHelp.com--------------------------- Note: most servers require that one of the emails (sender or receiver) to be an email hosted by same server, so make sure your email (on last line of this file) is one hosted on same server.--------------------------- */// read the variables form the string, (this is not needed with some servers).$subject = $_REQUEST["subject"];$message = $_REQUEST["message"];$sender = $_REQUEST["sender"];// include sender IP in the message.$full_message = $_SERVER['REMOTE_ADDR'] . "\n\n" . $message;$message= $full_message;// remove the backslashes that normally appears when entering " or '$message = stripslashes($message); $subject = stripslashes($subject); $sender = stripslashes($sender); // add a prefix in the subject line so that you know the email was sent by online form$subject = "Contact form ". $subject;// send the email, make sure you replace email@yourserver.com with your email addressif(isset($message) and isset($subject) and isset($sender)){ mail("info@mediashox.com", $subject, $message, "From: $sender");}?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 31, 2007 Share Posted January 31, 2007 It's fine for 4.Why do you say it's not working?If you're not a PHP programmer, it'll probably be faster and easier for you to hire one in the freelancer forum. Quote Link to comment Share on other sites More sharing options...
metrov Posted January 31, 2007 Author Share Posted January 31, 2007 It is not working because I am not receiving the emails. The code is from Macromedia, so it is a valid code. According to their instructions, it is only necessary to change the email address to your own email address.Do I really have to hire someone just to tell me if this is PHP 4 or not?Sorry, I see that you did say it's 4. Thanks -- I guess I'll have to check with my server. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 31, 2007 Share Posted January 31, 2007 Change the mail line to this:print mail("info@mediashox.com", $subject, $message, "From: $sender");Do you see a 1, a 0, or nothing?Did you check your spam folder? The mail only has minimal headers, and is likely to be filtered as spam. Quote Link to comment Share on other sites More sharing options...
metrov Posted January 31, 2007 Author Share Posted January 31, 2007 No numbers come up, only the message [in the Flash movie] saying 'Your message has been sent.'And still no email in regular or SPAM folder.Thanks for your help. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 31, 2007 Share Posted January 31, 2007 Oh it's in flash, right. Erm, there should be more code? How does it know to tell flash if it was successful or not?What happens if you just go to the page in your browser, instead of using flash? We'll fudge things a bit to see if we can get it to work. Quote Link to comment Share on other sites More sharing options...
redarrow Posted January 31, 2007 Share Posted January 31, 2007 try this ok.[code]<?php$to = 'bob@barnyard.com';$subject = $_GET['subject'];$message = $_GET['message'];$sender = $_GET["sender"];$full_message = $_SERVER['REMOTE_ADDR'] . "\n\n" . $message;$message= $full_message;$headers = "From: $sender\r\n" .'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; if(isset($message) && isset($subject) && isset($sender)){mail($to, $subject, $message, $headers); }?>[/code] Quote Link to comment Share on other sites More sharing options...
metrov Posted January 31, 2007 Author Share Posted January 31, 2007 Hi Jesirose and redarrow1 -- I went directly to the .php file URL, and got a blank page.2 -- I tried doing this with both versions of the code, same results -- blank page, no prompt, no email arrival3 -- I tried the form using redarrow's code, got no email4 -- Called my hosting company. The tech guy re-checked the code, said both versions were fine, the emails should be coming through which led him to believe that there's something wrong with the Flash code.5 -- However, the Flash files came directly from Macromedia [creators of Flash]. I've looked at it, and it is perfect. 6 -- There's no code to tell Flash if it was successful or not. The Flash movie just goes to a new page that says 'Message sent', but no test involved.So, if the PHP code is perfect, and the Flash code is perfect, I have no idea why it's not working. Any other suggestions would be much welcome. Thanks a lot Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 31, 2007 Share Posted January 31, 2007 Create a new blank PHP page, and do this:<?phpprint mail('info@mediashox.com', 'test', 'test', 'From: "Testing" <info@mediashox.com>').'<br />';print mail('info@mediashox.com', 'test', 'test');?>You should see:11If you do, the mail function is working fine. Next step is to check your mail and make sure you got two emails containing Test. If you did, it's the flash, if not, it's the server, and you can show this to the tech guy, that the mail is being accepted for delivery, but not delivered.If you don't see two 1's, there is a problem with your PHP setup. Quote Link to comment Share on other sites More sharing options...
metrov Posted January 31, 2007 Author Share Posted January 31, 2007 When you say create a new 'page', you mean create a new 'mailer.php' file? And then use my browser to go directly to that file? Thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 31, 2007 Share Posted January 31, 2007 yes, only don't call it the same as your other php files or you'll overwrite them. Also, this has to be on the same server you're using, not your local computer. Quote Link to comment Share on other sites More sharing options...
metrov Posted January 31, 2007 Author Share Posted January 31, 2007 1 -- make sure you got two emails containing Test. // Got no emailsIf you did, it's the flash, if not, it's the server, and you can show this to the tech guy, that the mail is being accepted for delivery, but not delivered.2 -- If you don't see two 1's, there is a problem with your PHP setup.// Did not see the two 1's.So doesn't this indicate a problem with my PHP setup? If so, I'm confused coz you said my PHP was okay. Do you mean something else? Thanks for your help. Sorry this isn't working. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 31, 2007 Share Posted January 31, 2007 If you went to that page and saw no 1, that means the email was not accepted for delivery. You need to have sendmail installed and configured. At this point, I'd go back to your tech guy and have them check the mail settings. Quote Link to comment Share on other sites More sharing options...
metrov Posted January 31, 2007 Author Share Posted January 31, 2007 OK, thanks. I'll let you know what happens.I just thought of something. I'm getting regular emails okay to this address [info@mediashox.com] Does that matter? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 31, 2007 Share Posted January 31, 2007 No, it shouldn't matter, as the problem is getting mail from PHP to be accepted by the server. Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted January 31, 2007 Share Posted January 31, 2007 [quote author=metrov link=topic=124824.msg518336#msg518336 date=1170278024]2 -- If you don't see two 1's, there is a problem with your PHP setup.// Did not see the two 1's.So doesn't this indicate a problem with my PHP setup? If so, I'm confused coz you said my PHP was okay. Do you mean something else?[/quote]Jesi meant the php code itself looks fine, but the way PHP is setup on your server maybe incorrect.RegardsHuggie Quote Link to comment Share on other sites More sharing options...
metrov Posted February 1, 2007 Author Share Posted February 1, 2007 OK, talked to my hosting tech guys several times, they swear everything is set up and working perfectly on their end. Still nothing works. They gave me another .php formmail code, still doesn't work. If I test their code by going directly to the .php file URL, I get an error messsage. You can see it here:[url=http://mediashox.com/email/mailer.php]http://mediashox.com/email/mailer.php[/url]I may have to hire someone who is proficient in both Flash Action Script and PHP to get it all sorted out. If you know of anyone, please let me know. Thanks again Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 1, 2007 Share Posted February 1, 2007 Did you tell them their code doesn't work? If they can't get it to work, geez. Quote Link to comment Share on other sites More sharing options...
metrov Posted February 1, 2007 Author Share Posted February 1, 2007 Their guy said their code IS working because it gives the error message [which is in the code], the error being that nothing was sent from my Flash form movie. He said the variables in my Flash movie have to correspond to the variables in the php code. Ok, duh, even I know that much. Anyway, I tried matching the variables in my Flash code to match their php code, still no luck. At this moment, I'm tired of hassling with it [I've actually been trying to get this to work for weeks]. So I'm open to hiring some help.Thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 1, 2007 Share Posted February 1, 2007 I don't know flash, or I'd offer to help more.Best of luck. Quote Link to comment Share on other sites More sharing options...
metrov Posted February 1, 2007 Author Share Posted February 1, 2007 In your first post, you suggested I look for help in the 'freelancer' forum, but I just looked there and NOBODY responds to those posts. Do you know what's up with that? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 1, 2007 Share Posted February 1, 2007 You can't respond to the posts :) You leave contact info and people contact you that way.Or try getafreelancer.com (I've said that like 60 times today, but it's easy to find cheap help on there.) Quote Link to comment Share on other sites More sharing options...
metrov Posted February 1, 2007 Author Share Posted February 1, 2007 Cool, thanks! Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted February 1, 2007 Share Posted February 1, 2007 [quote author=jesirose link=topic=124824.msg518604#msg518604 date=1170300420]Did you tell them their code doesn't work? If they can't get it to work, geez.[/quote]Their code is working fine. I've checked the URL and there's no issues with it. If you call it with a query string in the URL it responds as expected.Can you post the code that is in the flash file? I don't remember masses about Flash, but I can remember enough to get forms working I'm sure!RegardsHuggie Quote Link to comment Share on other sites More sharing options...
metrov Posted February 1, 2007 Author Share Posted February 1, 2007 Huggie, thanks![b]Here is the .php code from my hosting company:[/b]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<?PHPdefine('VERSION','Classic v1.07.0');define('MANUAL','http://www.boaddrink.com/projects/phpformmail/readme.php');define('CHECK_REFERER', true);// +------------------------------------------------------------------------+// | PHPFormMail |// | Copyright (c) 1999 Andrew Riley (webmaster@boaddrink.com) |// | |// | This program is free software; you can redistribute it and/or |// | modify it under the terms of the GNU General Public License |// | as published by the Free Software Foundation; either version 2 |// | of the License, or (at your option) any later version. |// | |// | This program is distributed in the hope that it will be useful, |// | but WITHOUT ANY WARRANTY; without even the implied warranty of |// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |// | GNU General Public License for more details. |// | |// | You should have received a copy of the GNU General Public License |// | along with this program; if not, write to the Free Software |// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |// | USA. |// | |// +------------------------------------------------------------------------+// | |// | If you run into any problems, pleas read the readme_formmail.txt. |// | If that does not help, check out http://www.boaddrink.com. |// | |// | For more info, please visit http://www.boaddrink.com or read the |// | readme file included. |// +------------------------------------------------------------------------+// | |// | Value array fix by: Konrad Maqestieau |// | check_recipients reset() fix by: Don |// | servertime_offset code by: desolate |// | |// +------------------------------------------------------------------------+$referers = array('www.mediashox.com', 'mediashox.com');$valid_env = array('REMOTE_HOST', 'REMOTE_ADDR', 'REMOTE_USER', 'HTTP_USER_AGENT');$recipient_array = array();// +------------------------------------------------------------------------+// | |// | SMTP Modification by: CrystalTech Web Hosting Inc. |// | Modified Date: 09.16.05 |// | Modification approved for PHPFormMail Classic v1.07.0 |// | |// +------------------------------------------------------------------------+// | |// | Please enter a Valid Mail Server for your Email Recipient: |// | If the recipient is you@yourdomain.com, then the SMTP server should |// | be mail.yourdomain.com - For additional support, please email |// | support@crystaltech.com |// | |// +------------------------------------------------------------------------+// Please specify your Mail Server - Example: mail.mediashox.com.ini_set("SMTP","mail.mediashox.com");// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.ini_set("smtp_port","25");// +------------------------------------------------------------------------+// | STOP EDITING! The only two required variables that need to be updated |// | are $referers and $valid_env |// +------------------------------------------------------------------------+$errors = $fieldname_lookup = array();$invis_array = array('recipient','subject','required','redirect', 'print_blank_fields','env_report','sort', 'missing_fields_redirect','title','bgcolor', 'text_color','link_color','alink_color', 'vlink_color','background','subject','title', 'link','css','return_link_title', 'return_link_url','recipient_cc','recipient_bcc', 'priority','redirect_values','hidden','alias', 'mail_newline', 'gmt_offset', 'alias_method');/**************************************************************** * fake_in_array() is only used in PHP3 since PHP4 has a native * * in_array. Depending on what version of PHP you are running * * the script will determine what is the best function to run * * --- THER IS NO LONGER ANY REASON TO DELETE THIS FUNCTION --- * * Function renamed in 1.04.0 * ****************************************************************/function fake_in_array($needle, $haystack){ $found = false; while (list($key,$val) = each ($haystack)) { if ($needle == $val) $found = true; } return $found;}/**************************************************************** * check_referer() breaks up the enviromental variable * * HTTP_REFERER by "/" and then checks to see if the second * * member of the array (from the explode) matches any of the * * domains listed in the $referers array (declaired at top) * ****************************************************************/function check_referer($referers){ global $errors; if (count($referers)) { if (getenv('HTTP_REFERER')) { $temp = explode('/', getenv('HTTP_REFERER')); $found = false; while (list(,$stored_referer) = each($referers)) { if (eregi('^' . $stored_referer . '$', $temp[2])) $found = true; } if (!$found) { $errors[] = '1|You are coming from an unauthorized domain. Please read the manual section titled "<a href="' . MANUAL . '#setting_up" target="_blank">Setting Up the PHPFormMail Script</a>".'; error_log('[PHPFormMail] Illegal Referer. (' . getenv('HTTP_REFERER') . ')', 0); } return $found; } else { $errors[] = '0|Sorry, but I cannot figure out who sent you here. Your browser is not sending an HTTP_REFERER. This could be caused by a firewall or browser that removes the HTTP_REFERER from each HTTP request you submit.'; error_log('[PHPFormMail] HTTP_REFERER not defined. Browser: ' . getenv('HTTP_USER_AGENT') . '; Client IP: ' . getenv('REMOTE_ADDR') . '; Request Method: ' . getenv('REQUEST_METHOD') . ';', 0); return false; } } else { $errors[] = '1|There are no referers defined. All submissions will be denied. Please read the manual section titled "<a href="' . MANUAL . '#setting_up" target="_blank">Setting Up the PHPFormMail Script</a>".'; error_log('[PHPFormMail] You have no referers defined. All submissions will be denied.', 0); return false; }}/**************************************************************** * check_recipients() breaks up the recipents e-mail addresses * * and then crossrefrences the domains that are legal referers * * Function added in 1.3.1 * ****************************************************************/function check_recipients($recipient_list){ global $errors, $referers; $recipients_ok = true; $recipient_list = explode(',', $recipient_list); while (list(,$recipient) = each($recipient_list)) { $recipient_domain = false; $recipient = trim($recipient); reset($referers); while ((list(,$stored_domain) = each($referers)) && ($recipient_domain == false)) { if (eregi('^[_\.a-z0-9-]*@' . $stored_domain . '$', $recipient)) $recipient_domain = true; } if ($recipient_domain == false) { $recipients_ok = false; error_log('[PHPFormMail] Illegal Recipient: ' . $recipient . ' from ' . getenv('HTTP_REFERER'), 0); } } if (!$recipients_ok) $errors[] = '1|You are trying to send mail to a domain that is not in the allowed recipients list. Please read the manual section titled "<a href="' . MANUAL . '#setting_up" target="_blank">Setting Up the PHPFormMail Script</a>".'; return join(',', $recipient_list);}/**************************************************************** * map_recipients() takes the array and maps them to the proper * * e-mail addresses from $recipient_array. If this function is * * called then the e-mail addresses are not checked against the * * referer array. * * Function added in 1.7.0 * ****************************************************************/function map_recipients($recipient_list){ global $errors, $recipient_array; $recipients_ok = true; $recipient_list = explode(',',$recipient_list); while (list(,$val) = each($recipient_list)){ $val = trim($val); if(isset($recipient_array[$val])) $output[] = $recipient_array[$val]; else $recipients_ok = false; } if (!$recipients_ok) $errors[] = '1|You are trying to send mail to an address that is not listed in the recipient array.'; if (isset($output)) return join(',', $output); else return null;}/**************************************************************** * decode_vars() is used to assign all of the variables passed * * into the form to a generic variable. Allthough there are * * two official form actions, POST and GET, I decided to use * * this variable method so if more actions are invented, I * * wouldn't have to change anything. * * * * In the first line, the request methood is assigned to * * $request with HTTP_ and _VARS appended to it. * * In the second line uses PHPs variable variable. * * It's basically addressing the variable $HTTP_POST_VARS or * * $HTTP_GET_VARS and returning that. Read more about * * variable variables in the PHP documentation. * ****************************************************************/function decode_vars(){ if (isset($_REQUEST)) $request = '_' . getenv('REQUEST_METHOD'); else $request = 'HTTP_' . getenv('REQUEST_METHOD') . '_VARS'; global $$request; if (count($$request) > 0) { while (list($key, $val) = each($$request)) { if (is_array($val)) $val = implode(', ',$val); $output[$key] = stripslashes($val); } return $output; } else return array();}/**************************************************************** * error() is our generic error function. * * When called, it checks for errors in the $errors array and * * depending on $form["missing_fields_redirect"] will either * * print out the errors by calling the function output_html() * * or it will redirect to the location specified in * * $form["missing_fields_redirect"]. * ****************************************************************/function error(){ global $form, $natural_form, $errors; if (isset($form['missing_fields_redirect'])) { if (isset($form['redirect_values'])) header('Location: ' . $form['missing_fields_redirect'] . '?' . getenv('QUERY_STRING') . "\r\n"); else header('Location: ' . $form['missing_fields_redirect'] . "\r\n"); } else { if(!isset($form['title'])) $form['title'] = 'PHPFormMail - Error'; $output = "<h1>The following errors were found:</h1>\n<ul>\n"; $crit_error = 0; while (list(,$val) = each ($errors)) { list($crit,$message) = explode('|',$val); $output .= ' <li>' . $message . "</li>\n"; if ($crit == 1) $crit_error = 1; } $output .= "</ul>\n"; if ($crit_error == 1) $output .= "<div class=\"crit\">PHPFormMail has experienced errors that must be fixed by the webmaster. Mail will NOT be sent until these issues are resolved. Once these issues are resolved, you will have to resubmit your form to PHPFormMail for the mail to be sent.</div><div class=\"returnlink\">Please use the <a href=\"javascript: history.back();\">back</a> button to return to the site.</div>\n"; else $output .= "<div class=\"returnlink\">Please use the <a href=\"javascript: history.back();\">back</a> button to correct these errors.</div>\n"; output_html($output); }}/**************************************************************** * check_required() is the function that checks all required * * fields to see if they are empty or match the provided regex * * string (regex checking added in 1.02.0). * * * * Should a required variable be empty or not match the regex * * pattern, a error will be added to the global $errors array. * ****************************************************************/function check_required(){ global $form, $errors, $invis_array, $fieldname_lookup; $problem = true; if ((!isset($form['recipient'])) && (!isset($form['recipient_bcc']))) { $problem = false; $errors[] = '1|There is no recipient to send this mail to. Please read the manual section titled "<a href="' . MANUAL . '#recipient" target="_blank">Form Configuration - Recipient</a>".'; error_log('[PHPFormMail] There is no recipient defined from ' . getenv('HTTP_REFERER'), 0); } if (isset($form['required'])) { $required = split(',', $form['required']); while (list(,$val) = each($required)) { $val = trim($val); $regex_field_name = $val . '_regex'; if ((!isset($form[$val])) || (isset($form[$val]) && (strlen($form[$val]) < 1))) { $problem = false; if (isset($fieldname_lookup[$val])) $field = $fieldname_lookup[$val]; else $field = $val; $errors[] = '0|Required value (<b>' . $field . '</b>) is missing.'; } else if (isset($form[$regex_field_name])) { if (!eregi($form[$regex_field_name],$form[$val])) { $problem = false; $errors[] = '0|Required value (<b>' . $fieldname_lookup[$val] . '</b>) has an invalid format.'; } $invis_array[] = $regex_field_name; } } } return $problem;}/**************************************************************** * sort_fields() is responsable for sorting all fields in $form * * depending $form["sort"]. * * There are three main sort methods: alphabetic, reverse * * alphabetic, and user supplied. * * * * The user supplied method is formatted "order:name,email,etc".* * The text "order" is required and the fields are comma * * sepperated. ("order" is legacy from the PERL version.) If * * the user supplied method leaves fields out of the comma * * sepperated list, the remaining fields will be appended to * * the end of the orderd list in the order they appear in the * * form. * * Function added in 1.02.0 * ****************************************************************/function sort_fields(){ global $form; switch ($form["sort"]) { case 'alphabetic': case 'alpha': ksort($form); break; case 'ralphabetic': case 'ralpha': krsort($form); break; default: if ($col = strpos($form['sort'],':')) { $form['sort'] = substr($form['sort'],($col + 1)); $temp_sort_arr = explode(',', $form['sort']); for($x = 0; $x < count($temp_sort_arr); $x++) { $out[$temp_sort_arr[$x]] = $form[$temp_sort_arr[$x]]; unset($form[$temp_sort_arr[$x]]); } $form = array_merge($out,$form); } } return true;}/**************************************************************** * alias_fields() creates a lookup array so we can use Aliases * * for the field names. If a alias is not available, the * * lookup array is filled with the form field's name * * Function added in 1.05.0 * ****************************************************************/function alias_fields(){ global $form, $fieldname_lookup; while (list($key,) = each($form)) { $fieldname_lookup[$key] = $key; } reset($form); if (isset($form['alias'])) { $aliases = explode(',', $form['alias']); while (list(,$val) = each($aliases)) { $temp = explode('=', $val); $fieldname_lookup[trim($temp[0])] = trim($temp[1]); } } return true;}/**************************************************************** * send_mail() the function that parses the data into SMTP * * format and sends the e-mail. * ****************************************************************/function send_mail(){ global $form, $invis_array, $valid_env, $in_array_func, $fieldname_lookup, $errors; if (!isset($form['subject'])) $form['subject'] = 'WWW Form Submission'; if (!isset($form['email'])) $form['email'] = 'email@example.com'; switch ($form['mail_newline']) { case 2: $mail_newline = "\r"; break; case 3: $mail_newline = "\r\n"; break; default: $mail_newline = "\n"; } if (isset($form['gmt_offset']) && ereg('^(\\-|\\+)?([0-9]{1}|(1{1}[0-2]{1}))$', $form['gmt_offset'])) { $mkseconds = mktime(gmdate('H') + $form['gmt_offset']); $mail_date = gmdate('F jS, Y', $mkseconds) . ' at ' . gmdate('h:iA', $mkseconds) . ' (GMT ' . $form['gmt_offset'] . ').'; } else $mail_date = date('F jS, Y') . ' at ' . date('h:iA (T).'); if (isset($form['realname'])) $realname = $form['realname']; elseif (isset($form['firstname']) || isset($form['lastname'])) $realname = trim($form['firstname'] . ' ' . $form['lastname']); $mailbody = "Below is the result of your feedback form. It was submitted by" . $mail_newline; if (isset($realname)) $mailbody.= $realname . ' (' . $form['email'] . ') on ' . $mail_date . $mail_newline . $mail_newline; else $mailbody.= $form['email'] . ' on ' . $mail_date . $mail_newline . $mail_newline; reset($form); while (list($key,$val) = each($form)) { if ((!$in_array_func($key,$invis_array)) && ((isset($form['print_blank_fields'])) || ($val))) { if(($form['alias_method'] == 'email') || ($form['alias_method'] == 'both')) $mailbody .= $fieldname_lookup[$key]; else $mailbody .= $key; $mailbody .= ': ' . $val . $mail_newline; } } if (isset($form['env_report'])) { $temp_env_report = explode(',', $form['env_report']); $mailbody .= $mail_newline . $mail_newline . "-------- Env Report --------" . $mail_newline; while (list(,$val) = each($temp_env_report)) { if ($in_array_func($val,$valid_env)) $mailbody .= $val . ': ' . getenv($val) . $mail_newline; } } if (!isset($form['recipient'])) $form['recipient'] = ''; // Append lines to $mail_header that you wish to be // added to the headers of the e-mail. (SMTP Format // with newline char ending each line) // Used to specify the recipient as the FROM Address instead of the email field. $mail_header = 'From: ' . $form['recipient'] . $mail_newline; // Add the sender to the reply-to field instead of the from field. $mail_header .= 'Reply-To: ' . $form['email']; // Add a valid Return-Path Sender ini_set("sendmail_from",$form['recipient']); if (isset($realname)) $mail_header .= ' (' . $realname . ')'; $mail_header .= $mail_newline; if (isset($form['recipient_cc'])) $mail_header .= 'Cc: ' . $form["recipient_cc"] . $mail_newline; if (isset($form['recipient_bcc'])) $mail_header .= 'Bcc: ' . $form['recipient_bcc'] . $mail_newline; if (isset($form['priority'])) $mail_header .= 'X-Priority: ' . $form['priority'] . $mail_newline; else $mail_header .= "X-Priority: 3" . $mail_newline; $mail_header .= 'X-Mailer: PHPFormMail ' . VERSION . " (http://www.boaddrink.com)" . $mail_newline; // Used to specify the return-path. $mail_header .= 'Return-Path: ' . $form['recipient']; $mail_status = mail($form['recipient'], $form['subject'], $mailbody, $mail_header); if (!$mail_status) { $errors[] = '1|Message could not be sent due to an error while trying to send the mail.'; error_log('[PHPFormMail] Mail could not be sent due to an error while trying to send the mail.'); } return $mail_status;}/**************************************************************** * output_html() is used to output all HTML to the browser. * * This function is called if there is an error or for the * * "Thank You" page if neither are declaired as redirects. * * * * While called output_html() it actually outputs valid XHTML * * 1.0 documents. * * Function added in 1.02.0 * ****************************************************************/function output_html($body){ global $form; $bgcolor = isset($form['bgcolor']) ? ('background-color: ' . htmlspecialchars($form['bgcolor']) . ';') : ('background-color: #FFF;'); $background = isset($form['background']) ? ('background-image: url(' . htmlspecialchars($form['background']) . ');') : NULL; $text_color = isset($form['text_color']) ? ('color: ' . htmlspecialchars($form['text_color']) . ';') : ('color: #000;'); $link_color = isset($form['link_color']) ? ('color: ' . htmlspecialchars($form['link_color']) . ';') : NULL; $alink_color = isset($form['alink_color']) ? ('color: ' . htmlspecialchars($form['alink_color']) . ';') : NULL; $vlink_color = isset($form['vlink_color']) ? ('color: ' . htmlspecialchars($form['vlink_color']) . ';') : NULL; print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; print "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n"; print "<head>\n"; print " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=us-ascii\" />\n"; print " <meta name=\"robots\" content=\"noindex,nofollow\" />\n"; print " <title>" . htmlspecialchars($form['title']) . "</title>\n"; print " <style type=\"text/css\">\n"; print " BODY {" . trim($bgcolor . ' ' . $text_color . ' ' . $background) . "}\n"; if (isset($link_color)) print " A {" . $link_color . "}\n"; if (isset($alink_color)) print " A:active {" . $alink_color . "}\n"; if (isset($vlink_color)) print " A:visited {" . $vlink_color . "}\n"; print " h1 {font-size: 14pt; font-weight: bold; margin-bottom: 20pt}\n"; print " .crit {font-size: 12pt; font-weight: bold; color: #F00; margin-bottom: 10pt;}\n"; print " .returnlink {font-size: 12pt; margin-top: 20pt; margin-bottom: 20pt;}\n"; print " .validbutton {margin-top: 20pt; margin-bottom: 20pt;}\n"; print " </style>\n"; if (isset($form['css'])) print " <link rel=\"stylesheet\" href=\"" . htmlspecialchars($form['css']) . "\">\n"; print "</head>\n\n"; print "<body>\n"; print "<!-- PHPFormMail " . VERSION . " from http://www.boaddrink.com -->\n"; print $body; print "<div class=\"validbutton\"><a href=\"http://validator.w3.org/check/referer\" target=\"_blank\"><img src=\"http://www.w3.org/Icons/valid-xhtml10\" style=\"border:0;width:88px;height:31px\" alt=\"Valid XHTML 1.0!\" /></a></div>\n"; print "</body>\n"; print "</html>";}$form = decode_vars();if (count($form) > 0) { // PFMA remove if block // Determine (based on the PHP version) if we should use the native // PHP4 in_array or the coded fake_in_array if (phpversion() >= '4.0.0') $in_array_func = 'in_array'; else $in_array_func = 'fake_in_array'; if($use_field_alias = isset($form['alias'])) alias_fields(); // If the $recipient_array has any entries at the top of this script set the variable to true // This is used to save some CPU time later by only checking a boolean and not doing a function // call each time we need to check if we are to use the $recipient_array $use_recipient_array = (count($recipient_array) > 0); if(CHECK_REFERER == true) check_referer($referers); else error_log('[PHPFormMail] HTTP_REFERER checking is turned off. Referer: ' . getenv('HTTP_REFERER') . '; Client IP: ' . getenv('REMOTE_ADDR') . ';', 0); // I added this conditional so the $recipient_function will only be called if we are supposed // to check the referer or we need to call map_recipients (it makes no sense to run four // conditionals with a possible calling of three functions if they arent needed). if((CHECK_REFERER == true) || ($use_recipient_array == true)) { // This is used for another variable function call if ($use_recipient_array == true) $recipient_function = 'map_recipients'; else $recipient_function = 'check_recipients'; if (isset($form['recipient'])) $form['recipient'] = $recipient_function($form['recipient']); if (isset($form['recipient_cc'])) $form['recipient_cc'] = $recipient_function($form['recipient_cc']); if (isset($form['recipient_bcc'])) $form['recipient_bcc'] = $recipient_function($form['recipient_bcc']); } check_required(); if (!$errors) { if (isset($form['sort'])) sort_fields(); if (isset($form['hidden'])) { // PFMA REMOVE 1 $form['hidden'] = str_replace(' ', '', $form['hidden']); $form['hidden'] = explode(',', $form['hidden']); // PFMA ADD $form['hidden'] = array_map('trim', $form['hidden']); } if (send_mail()) { if (isset($form['redirect'])) { if (isset($form['redirect_values'])) header('Location: ' . $form['redirect'] . '?' . getenv('QUERY_STRING') . "\r\n"); else header('Location: ' . $form['redirect'] . "\r\n"); } else { if (!isset($form['title'])) $form['title'] = 'PHPFormMail - Form Results'; $output = "<h1>The following information has been submitted:</h1>\n"; reset($form); while (list($key,$val) = each($form)) { if ((!$in_array_func($key,$invis_array)) && ((isset($form['print_blank_fields'])) || ($val))) { $output .= '<div class="field"><b>'; if(($use_field_alias) && ($form['alias_method'] != 'email')) $output .= htmlspecialchars($fieldname_lookup[$key]); else $output .= htmlspecialchars($key); if ((isset($form['hidden'])) && ($in_array_func($key,$form['hidden']))) $output .= ":</b> <i>(hidden)</i></div>\n"; else $output .= ':</b> ' . nl2br(htmlspecialchars(stripslashes($val))) . "</div>\n"; } } if (isset($form['return_link_url']) && isset($form['return_link_title'])) $output .= '<div class="returnlink"><a href="' . $form["return_link_url"] . '">'. $form["return_link_title"] . "</a></div>\n"; output_html($output); } } }} else { $errors[] = '0|Nothing was sent by a form. (No data was sent by POST or GET method.) There is nothing to process here.'; error_log('[PHPFormMail] No data sent by POST or GET method. (' . getenv('HTTP_REFERER') . ')', 0);}if (count($errors) > 0) error();?>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[b]Here is the Flash code. I believe the variables that go to the .php file are readily apparent:[/b]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++send_btn.onRelease = function() { my_vars = new LoadVars(); my_vars.sender = email_box.text; my_vars.subject = subject_box.text; my_vars.message = message_box.text; if (my_vars.sender != "" and my_vars.subject != "" and my_vars.message != "") { my_vars.sendAndLoad("mailer.php", my_vars, "POST"); gotoAndStop(2); } else { error_clip.gotoAndPlay(2); } my_vars.onLoad = function() { gotoAndStop(3); };};email_box.onSetFocus = subject_box.onSetFocus=message_box.onSetFocus=function () { if (error_clip._currentframe != 1) { error_clip.gotoAndPlay(6); }};++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[b]As you can see the .php code contains far more variables than my Flash movie. The Flash form mail movie is quite simple, which you can see here:[/b][url=http://mediashox.com/email/form.html]http://mediashox.com/email/form.html[/url]Please let me know if you need anything else. [or if this is too much] I really appreciate your help on this. Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.