hi. using php, and more than 5 variables, i am trying to email a form when submitted on a website. i read on another forum the best way to do this is concatenate the content and pass in mail() as one variable. however, when i use the following code, i only get partial results... see below. //////////// //my code: //////////// <?php $to="test@test.com"; $from="my_website"; $company = $_REQUEST['company'] ; $name = $_REQUEST['name'] ; $phone = $_REQUEST['phone'] ; $email = $_REQUEST['email'] ; $content = "Company: " . $_REQUEST["company"] . "\r\n"; $content .= "------------------------------------\r\n"; $content = "Name: " . $_REQUEST["name"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Address 1: " . $_REQUEST["address"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Address 2: " . $_REQUEST["address2"] . "\r\n"; $content .= "------------------------------------\r\n"; $content = "Phone: " . $_REQUEST["phone"] . "\r\n"; $content .= "------------------------------------\r\n"; $content = "Email: " . $_REQUEST["email"] . "\r\n"; $content .= "------------------------------------\r\n"; $content = "Fax: " . $_REQUEST["fax"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Message:\r\n" . $_REQUEST["message"] . "\r\n"; $content .= "------------------------------------\r\n"; if (empty($company) || empty($name) || empty($phone) || empty($email)) { header( "Location: http://www.test.com/error.html" ); } else { mail( $to, $from, "my emailed form", $content ); header( "Location: http://www.test.com/thankyou.html" ); } ?> ////////////// //my results: ////////////// ------------------------------------ Message: ehfsdjkfhsjkfhjskdhfdsjkhfjksdhfjsdhfjshkfhsjkfhjkshfkjshjkd ------------------------------------ that's it. i only get the last piece of data requested. i dont know where the rest of my information went!! why is it not grabbing all of my content? PLEASE HELP!! april
awwwwwwwwwwww... shoot. i guess i was off with the ".=" on this part.. $content = "Company: " . $_REQUEST["company"] . "\r\n"; $content .= "------------------------------------\r\n"; $content = "Name: " . $_REQUEST["name"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Address 1: " . $_REQUEST["address"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Address 2: " . $_REQUEST["address2"] . "\r\n"; $content .= "------------------------------------\r\n"; $content = "Phone: " . $_REQUEST["phone"] . "\r\n"; $content .= "------------------------------------\r\n"; $content = "Email: " . $_REQUEST["email"] . "\r\n"; $content .= "------------------------------------\r\n"; $content = "Fax: " . $_REQUEST["fax"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Message:\r\n" . $_REQUEST["message"] . "\r\n"; $content .= "------------------------------------\r\n"; i changed it to the below and now it works... $content = "\r\n------------------------------------\r\n"; $content .= "Company: " . $_REQUEST["company"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Name: " . $_REQUEST["name"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Address 1: " . $_REQUEST["address"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Address 2: " . $_REQUEST["address2"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Phone: " . $_REQUEST["phone"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Email: " . $_REQUEST["email"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Fax: " . $_REQUEST["fax"] . "\r\n"; $content .= "------------------------------------\r\n"; $content .= "Message:\r\n" . $_REQUEST["message"] . "\r\n"; $content .= "------------------------------------\r\n";
This site talks about Email Injection attacks with PHP and provides examples on how to sanitize the input before passing it to the mail function.
i think you need a little change in code if (conditions) { redirection to error page } else { initialise variables your "$content = " code mail function redirection to Thank u page } what do you say??