cerebrus189 Posted June 8, 2008 Share Posted June 8, 2008 Hi all, I'm new to PHP and am busy doing an assignment for school. I have a form processing php confirmation page, as well as a way to send the information to the end user. What I need to do is also send a message back to myself within the PHP script or another way, if that's not possible. This is what I have so far. It shows a confirmation page with the variable information correctly and sends an email to the end user. However, I've also got to send it to myself through email but I'm not sure how to do this within the script itself. Is this possible. Also, if anybody knows how to write form data to a text file, that information would be greatly appreciated as well. Here's my PHP code so far. Yvette <?php /* */ $my_email = $_POST['email']; /* */ $continue = "http://w3.cnm.edu/~ywyskochil/IT499/"; /* You do not need to make any changes below this line. */ $errors = array(); // Remove $_COOKIE elements from $_REQUEST. if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}} // Validate email field. if(isset($_REQUEST['email']) && !empty($_REQUEST['email'])) { $_REQUEST['email'] = trim($_REQUEST['email']); if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}} } // Check referrer is from same site. if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";} // Check for a blank form. function recursive_array_check_blank($element_value) { global $set; if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}} else { foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);} } } recursive_array_check_blank($_REQUEST); if(!$set){$errors[] = "You cannot send a blank form";} unset($set); // Display any errors and exit if errors exist. if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;} if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");} // Build message. function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");} $message = build_message($_REQUEST); $message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL."Please confirm that you entered this information on our website by replying with Confirmed in the subject line."; $message = stripslashes($message); $subject = "PinkyBean.com Confirmation of Contact Form Information"; $headers = "From: " . $_REQUEST['temail']; $headers .= PHP_EOL; $headers .= "Return-Path: " . $_REQUEST['temail']; $headers .= PHP_EOL; $headers .= "Reply-To: " . $_REQUEST['temail']; mail($my_email,$subject,$message,$headers); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Please confirm your PinkyBean.com comment or question.</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="stylish.css" rel="stylesheet" type="text/css"> </head> <body bgcolor="#ffffff" text="#000000"> <div> <center> <div id="Layer3" style="position:absolute; width:763px; height:318px; z-index:1; left: -96px; top: -23px;"><img src="images/black_white_banner_design.jpg" alt="banner" width="766" height="305" /></div> <p> </p> <div id="Layer1" style="position:absolute; width:713px; height:94px; z-index:3; left: 393px; top: 97px;"> <h1 align="left" class="style2" onmouseover="style.color='black'" onmouseout="style.color='red'"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="120" height="30"> <param name="movie" value="home.swf" /> <param name="quality" value="high" /> <embed src="home.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="120" height="30" ></embed> </object> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="120" height="30"> <param name="movie" value="products.swf" /> <param name="quality" value="high" /> <embed src="products.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="120" height="30" ></embed> </object> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="120" height="30"> <param name="BGCOLOR" value="" /> <param name="movie" value="order.swf" /> <param name="quality" value="high" /> <param name="wmode" value="transparent" /> <embed src="order.swf" width="120" height="30" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent" ></embed> </object> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="120" height="30"> <param name="BGCOLOR" value="" /> <param name="movie" value="contact.swf" /> <param name="quality" value="high" /> <param name="wmode" value="transparent" /> <embed src="contact.swf" width="120" height="30" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent" ></embed> </object> </h1> <h1 align="left" class="style2" onmouseover="style.color='black'" onmouseout="style.color='red'"> </h1> <blockquote> <blockquote> <h1 align="left" class="style1"> </h1> </blockquote> </blockquote> </div> <p align="left"> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p><b>Thank you </b> <br> Your message has been sent to <?php echo $_POST['email']; ?> with the following information.</p> <p>Please check your email for a confirmation. </p> <p>Name: <?php echo $_POST['name']; ?></p> <div id="Layer2" style="position:absolute; width:312px; height:54px; z-index:4; top: 148px; left: 83px;"> <h1 class="style3 style4 style5 style1" onmouseover="style.color='black'" onmouseout="style.color='#FF33CC'">Pinky Bean Co.</h1> </div> <p>Address:<?php echo $_POST['address']; ?></p> <p><?php echo $_POST['address1']; ?></p> <p>City:<?php echo $_POST['city']; ?></p> <p>State:<?php echo $_POST['state']; ?></p> <p>Phone Number:<?php echo $_POST['phone']; ?></p> <p>Fax: <?php echo $_POST['fax']; ?></p> <p>Comments: <?php echo $_POST['comments']; ?></p> <p>How did you hear about us? <?php echo $_POST['hearabout']; ?></p> <p>Subject: <?php echo $_POST['subject']; ?></p> <p><a href="<?php print $continue; ?>">Click here to continue</a></p> </center> </div> Quote Link to comment https://forums.phpfreaks.com/topic/109317-multiple-email-addressing-from-form-variable-and-webmaster/ Share on other sites More sharing options...
.josh Posted June 8, 2008 Share Posted June 8, 2008 In the future, please use php or code tags around your script, if you want anybody to take you seriously. You said you got it working to send to one person; sending to two people is just a matter of adding a comma after the first email address and adding another email address, in your $my_email variable. As to your second question: We don't do people's homework for them. Quote Link to comment https://forums.phpfreaks.com/topic/109317-multiple-email-addressing-from-form-variable-and-webmaster/#findComment-560779 Share on other sites More sharing options...
cerebrus189 Posted June 9, 2008 Author Share Posted June 9, 2008 It sounds easy enough in theory to simple add a comma, but when I do, I'm not getting any form action to happen, so obviously that's not the solution...I know I've tried. Didn't you mom ever teach you that if you couldn't say anything nice, don't say anything at all. I came to you for help, not so you could be an elitist jerk. Don't respond again. I don't need the sarcasm. I get enough of that from my own kids. Like I said, I'm not a PHP person, I've done more web design not programming. All I was hoping for was a simple link or somewhere I could go where they could explain the proper way to design something like this. I'm a hard worker, a high-honor student, who's used to working for what I've got. Quote Link to comment https://forums.phpfreaks.com/topic/109317-multiple-email-addressing-from-form-variable-and-webmaster/#findComment-560888 Share on other sites More sharing options...
.josh Posted June 9, 2008 Share Posted June 9, 2008 It sounds easy enough in theory to simple add a comma, but when I do, I'm not getting any form action to happen, so obviously that's not the solution...I know I've tried. Didn't you mom ever teach you that if you couldn't say anything nice, don't say anything at all. I came to you for help, not so you could be an elitist jerk. Don't respond again. I don't need the sarcasm. I get enough of that from my own kids. Like I said, I'm not a PHP person, I've done more web design not programming. All I was hoping for was a simple link or somewhere I could go where they could explain the proper way to design something like this. I'm a hard worker, a high-honor student, who's used to working for what I've got. I wasn't being an elitist jerk. You were asking for help on your homework. I was simply stating the rules. I don't feel there was any sarcasm at all involved in my post. I'm sorry you took it that way. I guess you just enjoy shooting the messenger. It sounds easy enough in theory to simple add a comma, but when I do, I'm not getting any form action to happen, so obviously that's not the solution...I know I've tried. That whole comma thing doesn't really have anything to do with your form; I think you misunderstood. // example $to = "[email protected], [email protected]"; // comma separated email addresses here $subject = "blahblahblah"; $message = "lots of more blah"; mail($to,$subject,$message); ...or if that isn't the issue, then maybe I'm not understanding you. Quote Link to comment https://forums.phpfreaks.com/topic/109317-multiple-email-addressing-from-form-variable-and-webmaster/#findComment-561159 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.