PHP - Simple Confirmation Email...
I have been looking everywhere, and can't find a simple example of scripting a confirmation email. Basically, I have a form that is submitting to a database. But when the user submits the form successfully (I already have the validation in place), it sends their submitted email address a confirmation email.
Currently the form submits, fills in fields in a database, and sends the user to a static thank you page. At this time I would like to send them the email. How can this be done somewhat simply? Similar TutorialsHi, I'm new here and new to php. My first attempt at a php project actually so I'm hoping to get some help. I want people to register at my site but I don't want them to put false emails on it. So I used the coding from this website http://www.phpeasystep.com/workshopview.php?id=24 to provide codings for forms and email confirmation links. The process worked up to when I click on the confirmation link (at testing) from the email and the link returns to a blank webpage. No data is transferred from "temp_members_db" table to "registered_members" table at all. I'll attach print screen of my tables. Hoping that someone can point out to me where I'm going wrong as I can't seem to get myself out of this one. Hello, When a user sends a message using my contact form, they will get a confirmation to the supplied email to confirm that the email has been recieved, one problem is, the auto-reply message displays "donotreply@website.com" at the bottom of it, here is some of my code: //AUTO-REPLY CLIENT CODE START $confirmation = $visitor_email; $consubject="Your message has been recieved"; $body2 = "Hello $name, \nThe below message has now been recieved.\n\n >> $user_message <<\n\nWe will reply to you shortly.\n\nThank you,\n\nThe website Team.\n\n\nThis is an automated message, please do not reply to it.\n". $fromnoreply = 'donotreply@website.com'; //AUTO-REPLY CLIENT CODE END //TO WEBMAIL CODE START $to = $your_email; $subject="Contact form - $name"; $from = $visitor_email; $from = $your_email; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "A user $name submitted the contact form:\n". "Name: $name\n". "Email: $visitor_email \n". "Message: \n ". "$user_message\n". "IP: $ip\n"; //TO WEBMAIL CODE END //headers $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; $headers2 = "From: $fromnoreply \r\n"; $headers2 .= ""; // the important stuff!, yes definately! JAMES mail($to, $subject, $body,$headers); mail($confirmation, $consubject, $body2,$headers2); header('Location: ?sent'); //where shall i go once message is sent?? Possibly here. *wink* The above code automatically sends the below email to the client aswell as sending the clients message to me. Code: [Select] Hello Bob Smith, The below message has now been recieved. >> This is a test << We will reply to you shortly. Thank you, The website Team. This is an automated message, please do not reply to it. donotreply@website.com My objective is to remove the displayed email at the bottom of the message. Many thanks I want to send confirmation email to 2 different email boxes. this is the code sending to one box: { $this->load->library('email'); //$config['mailtype'] = 'html'; //$this->email->initialize($config); $this->email->from('no-reply@mymail.com 'Site team'); $this->email->to($em); $this->email->subject('Welcome'); $msg = 'You have registered'; $this->email->message($msg); $this->email->send(); } thanks and what should be the code sending same email to one more email box (example: mymail@gmail. com) I'm trying to incorporate a confirmation email function into an existing php script. I have a form that works perfectly, but I can't figure out how to get it to send an email confirmation. Here's the code ... sorry for posting so much of it, but in case I miss anything ... here it is. It's hosted on GoDaddy on a Linux platform ... if that makes any difference. If anyone can enlighten me ... Please Do. Thanks! <?php $d = date("m-d-y H:i:s"); // assign incomming data $CustomerStatus = $_POST["CustomerStatus"]; $Contact = $_POST["Contact"]; $Name = $_POST["Name"]; $an = str_replace(" ", "", $Name); $Company = $_POST["Company"]; $Address = $_POST["Address"]; //$office = $_POST["office"]; $CityStateZip = $_POST["CityStateZip"]; $Phone = $_POST["Phone"]; $Email = $_POST["Email"]; $ResponseType = $_POST["ResponseType"]; $Artwork = $_POST["Artwork"]; $ProjectName = $_POST["ProjectName"]; $DueDate = $_POST["DueDate"]; $EstimateNumber = $_POST["EstimateNumber"]; $PONumber = $_POST["PONumber"]; $Pages = $_POST["Pages"]; $Quantity = $_POST["Quantity"]; $ColorFrontBack = $_POST["ColorFrontBack"]; $FlatSize = $_POST["FlatSize"]; $FoldedSize = $_POST["FoldedSize"]; $StockText = $_POST["StockText"]; $StockCover = $_POST["StockCover"]; $LabelStock = $_POST["LabelStock"]; $Coating = $_POST["Coating"]; $Bindery = $_POST["Bindery"]; $Additional = $_POST["Additional"]; $group1 = $_POST["group1"]; $group2 = $_POST["group2"]; $group3 = $_POST["group3"]; $redirect = $_POST["redirect"]; //$subject = $_POST["Subject"]; /* ************* Begin Configuration ************* */ $relocate = "http://www.xxxxx.com/"; // insert your relocation url here $home = "http://www.xxxxx.com/"; $MOVE_TO_PATH = '/home/content/xxxxx/html/FileUpload/'; $PATH_TO_DIR = 'http://www.xxxxx.com/FileUpload/'; // The following values are used to verify_uploaded_file() as the sizes and types that can be uploaded. $UPLOAD_TYPES['PSD'] = 1; // Allow .psd files $UPLOAD_TYPES['JPG'] = 1; // Allow .jpg files (definition must be upper case) $UPLOAD_TYPES['JPEG'] = 1; // Allow .jpeg files $UPLOAD_TYPES['AI'] = 1; // Allow .ai files $UPLOAD_TYPES['EPS'] = 1; // Allow .eps files $UPLOAD_TYPES['PDF'] = 1; // Allow .pdf files $UPLOAD_TYPES['GIF'] = 1; // Allow .gif files $UPLOAD_TYPES['PNG'] = 1; // Allow .png files $UPLOAD_TYPES['DOC'] = 1; // Allow .doc files $UPLOAD_TYPES['XLS'] = 1; // Allow .xls files $UPLOAD_TYPES['ZIP'] = 1; // Allow .zip files $UPLOAD_TYPES['SIT'] = 1; // Allow .sit files $UPLOAD_TYPES['FLA'] = 1; // Allow .fla files $UPLOAD_SIZES['max'] = 180000000; // Maximum size -- Make sure the file is under 180 MB : 180,000,000 = 180 MB $UPLOAD_SIZES['min'] = 0; // Minimum size -- Arbitrary small file size to distinguish between no file and file submission $sender_name = "Order"; $sender_email = "me@xxxxx.com"; $mailheaders = "Content-Type: text/plain; charset=us-ascii\nFrom: $sender_name <$sender_email>\nReply-To: <$sender_email>\nReturn-Path: <$sender_email>\nX-Mailer: PHP"; //$to = "me@xxxxx.com"; $to = "me@xxxxx.com"; $subject = "Order"; $msg ="$d\n\n"; $msg .= "CustomerStatus: $CustomerStatus\n"; $msg .= "Contact: $Contact\n"; $msg .= "Name: $Name\n"; $msg .= "Company: $Company\n"; $msg .= "Address: $Address\n"; $msg .= "CityStateZip: $CityStateZip\n"; $msg .= "Phone: $Phone\n"; $msg .= "Email: $Email\n"; $msg .= "ResponseType: $ResponseType\n"; $msg .= "Artwork: $Artwork\n"; $msg .= "ProjectName: $ProjectName\n"; $msg .= "DueDate: $DueDate\n"; $msg .= "EstimateNumber: $EstimateNumber\n"; $msg .= "PONumber: $PONumber\n"; $msg .= "Pages: $Pages\n"; $msg .= "Quantity: $Quantity\n"; $msg .= "ColorFrontBack: $ColorFrontBack\n"; $msg .= "FlatSize: $FlatSize\n"; $msg .= "FoldedSize: $FoldedSize\n"; $msg .= "StockText: $StockText\n"; $msg .= "StockCover: $StockCover\n"; $msg .= "LabelStock: $LabelStock\n"; $msg .= "Coating: $Coating\n"; $msg .= "Bindery: $Bindery\n"; $msg .= "Additional: $Additional\n"; $msg .= "group1: $group1\n"; $msg .= "group2: $group2\n"; $msg .= "group3: $group3\n"; $success_block = "<p>Thank you for submitting your information. We will review your information and get back to you within a day or two.</p><br><br>"; /* ************* End Configuration ************* */ Hi guys, I understand that there are websites which do teach about creating Email Confirmation, are there any sites which you can recommend? Thanks Wilson Hello again. I have a site where people can order items, as per this thread : http://www.phpfreaks.com/forums/index.php?topic=345342.0 Now, I would like to be able to send an order confirmation to the person that has made the order, as well as to the site's ordering department. I have this code : Code: [Select] <?php if(isset($_POST['Email'])) { $email_to = "orders@thenewme.co.za"; $email_subject = "The New Me - Order Confirmation"; function died($error) { // error code echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['FName']) || !isset($_POST['LName']) || !isset($_POST['Email']) || !isset($_POST['Phone']) || !isset($_POST['Address']) || !isset($_POST['City']) || !isset($_POST['Pcode'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['FName']; // required $last_name = $_POST['LName']; // required $email_from = $_POST['Email']; // required $telephone = $_POST['Phone']; // not required $address = $_POST['Address']; // required $city = $_POST['City']; // required $postal_code = $_POST['Pcode']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "The New Me - Single Order details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Address: ".clean_string($address)."\n"; $email_message .= "City: ".clean_string($city)."\n"; $email_message .= "Postal Code: ".clean_string($postal_code)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> This is the whole page's code : Code: [Select] <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>The New Me</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1" /> <meta http-equiv="imagetoolbar" content="no" /> <meta name="description" content="An Example of the a flexible, scalable background image." /> <meta name="author" content="Michael Bester" /> <link rel="stylesheet" href="css/flexi-background.css" type="text/css" media="screen" /> <style type="text/css" media="screen"> h1 { background-color: #fff; background-color: rgba(255,255,255,0.8); color: #333; font-family: Helvetica, Arial, sans-serif; font-size: 2em; font-weight: normal; margin-top: 2.5%; margin-bottom: 1em; padding: 0.5em 0; position: absolute; text-align: center; width: 100%; z-index: 2; } h2 { background-color: #fff; background-color: rgba(255,255,255,0.8); color: #333; font-family: Helvetica, Arial, sans-serif; font-size: 1em; z-index: 2; text-align: center; } p { background-color: #fff; background-color: rgba(255,255,255,0.8); color: #333; font-family: Helvetica, Arial, sans-serif; font-weight: normal; z-index: 2; } .copyright { background-color: #fff; background-color: rgba(255,255,255,0.8); color: #333; font-family: Helvetica, Arial, sans-serif; font-weight: normal; font-size: 10px; z-index: 2; } </style> </head> <body> <h1>Welcome to the New Me</h1> <script src="js/flexi-background.js" type="text/javascript" charset="utf-8"></script> <table border="0" cols="3" width="100%"> <tr align="center"> <td><a href="index.htm"><img src="images/Home.gif" alt="Home" id="home" border="0"></a></td><td><a href="products.php"><img src="images/Products.gif" alt="Products" id="prod" border="0"></a></td><td><a href="contact_us.htm"><img src="images/Contact_us.gif" alt="Contact Us" id="contact" border="0"></a></td><td><a href="questions.htm"><img src="images/Questions.gif" alt="Questions?" id="Questions" border="0"></a></td> </tr> </table> <p> </p> <table cols="3" width="100%"> <tr><td width="25%"> </td><td width="50%"><h2>Have you always wanted to lose weight naturally and keep it off?</h2></td><td width="25%"> </td></tr> <tr><td valign="top" align="center"> <img border="0" src="images/gesonde%20kos.jpg" width="129" height="62"><p> <img border="0" src="images/Green%20Tea%201.jpg" width="127" height="92"></p> <p><img border="0" src="images/Picture1.png" width="113" height="265"></td><td><p> <?php if(isset($_POST['Email'])) { $email_to = "orders@thenewme.co.za"; $email_subject = "The New Me - Order Confirmation"; function died($error) { // error code echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['FName']) || !isset($_POST['LName']) || !isset($_POST['Email']) || !isset($_POST['Phone']) || !isset($_POST['Address']) || !isset($_POST['City']) || !isset($_POST['Pcode'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['FName']; // required $last_name = $_POST['LName']; // required $email_from = $_POST['Email']; // required $telephone = $_POST['Phone']; // not required $address = $_POST['Address']; // required $city = $_POST['City']; // required $postal_code = $_POST['Pcode']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "The New Me - Single Order details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Address: ".clean_string($address)."\n"; $email_message .= "City: ".clean_string($city)."\n"; $email_message .= "Postal Code: ".clean_string($postal_code)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> </p></td> <td valign="top" align="left"> <img border="0" src="images/Picture2.png" width="117" height="129"><p> <img border="0" src="images/Picture3.png" width="171" height="91"></p> <p><img border="0" src="images/skaal.jpg" width="111" height="111"></td></tr> <tr><td valign="top" align="center"> </td><td> </td> <td valign="top" align="left"> </td></tr> <tr><td valign="top" align="center"> </td><td> </td> <td valign="top" align="left"> </td></tr> <tr><td valign="top" align="center"> </td><td> <img border="0" src="images/suurlemoen%20sap.jpg" width="124" height="119" align="left"><img border="0" src="images/water.jpg" width="120" height="120" align="right"></td> <td valign="top" align="left"> </td></tr> </table> <p class="copyright"><a href = "http://www.ncc-cla.com">© NCC - vereeniging 2011</a></p> </body> </html> I know I'm probably doing something wrong, can anyone help? I have written a form script that submits the form data to me. This part works fine. I also want to send the sender a confirmation e-mail. I have written this part of the code also, but the from line in the confirmation e-mail is the e-mail of the ISP and not mine. Any suggestions? I still have little knowledge of php, I asked a question earlier but that gave me so as it is now my help please. I'm looking for an easy script that sends the info and send a confirmation. but everyone says something different. Have you a script that I only need to change what data? before hand thanks now use this script but does not work also completely leak, I understood for spammmers Hi! My question is probably simple but I've been scratching my head for hours now... I'm pretty new to php. I have an online form for orders; when submitted, an email is sent to the shop manager containing the info the client has filled in. So I pass all the info in the code below, but I can't manage to echo the array containing the order's items/qty/item_code. (I'm using Wordpress, Oxygen Builder, Metabox and Code Snippets, if that helps). Here's the code (used as a Code Snippet):
add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) {
$name = rwmb_meta( 'name', '', $post_id );
Nom: $name
$headers = ['Content-type: text/html', "Reply-To: $email"];
Help with this would be greatly appreciated! Please let me know if any details are missing. Thanks in advance! Jordan Edited June 23 by JordanCHello all, I used simple php email function but it send an email in junk folder or spam. Can anyone tell me why is this so? Her is the code: $host = "ssl://smtp.gmail.com"; $port = "465"; $to = " xx@gmail.com"; // note the comma $subject = " $_POST[company_website] "; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: About Wholesale Account' . "<$_POST[email]>\r\n"; $headers .= 'Cc: mail@gmail.com' . "\r\n"; $headers .= 'Bcc: cc@gmail.com' . "\r\n"; mail($to, $subject, $message, $headers); Hi the user fill details and then the email his sent to me the only problem is that the emails keeps going to my spam, can someone help me out please I looked already php website and email format looks the same. This is the link to my form. http://www.people.eurico.co.uk/ here my form script Code: [Select] <?php // Set email variables $email_to = 'xxxxx@xxxxxxx.co.uk'; $email_subject = 'Call back form'; // Set required fields $required_fields = array('fullname','email','telephone','comment'); // set error messages $error_messages = array( 'fullname' => 'Please enter a Name to proceed.', 'email' => 'Please enter a valid Email.', 'telephone' => 'Please telephone.', 'comment' => 'Please enter your Message to continue.' ); // Set form status $form_complete = FALSE; // configure validation array $validation = array(); // check form submittal if(!empty($_POST)) { // Sanitise POST array foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value)); // Loop into required fields and make sure they match our needs foreach($required_fields as $field) { // the field has been submitted? if(!array_key_exists($field, $_POST)) array_push($validation, $field); // check there is information in the field? if($_POST[$field] == '') array_push($validation, $field); // validate the email address supplied if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field); } // basic validation result if(count($validation) == 0) { // Prepare our content string $email_content = 'peoplesmartlearning.co.uk: ' . "\n\n"; // simple email content foreach($_POST as $key => $value) { if($key != 'submit') $email_content .= $key . ': ' . $value . "\n"; } // if validation passed ok then send the email mail($email_to, $email_subject, $email_content); // Update form switch $form_complete = TRUE; } } function validate_email_address($email = FALSE) { return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE; } function remove_email_injection($field = FALSE) { return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field)); } ?> The HTML Code: [Select] <div class="call_us_form"> <p class="title">WE'LL CALL YOU BACK</p> <?php if($form_complete === FALSE): ?> <form class="contact_form" id="fm-form" method="post" action="index.php" > <fieldset> <div class="fm-req"> <label for="fm-firstname">Name</label> <input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" /> <?php if(in_array('fullname', $validation)): ?><script type="text/javascript">alert("Please enter a Name"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-firstname">Email</label> <input type="text" id="email" class="detail" name="email" value=" <?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /> <?php if(in_array('email', $validation)): ?><script type="text/javascript">alert("Please enter a valid Email Address"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-firstname">Number</label> <input type="text" id="telephone" class="detail" name="telephone" value="<?php echo isset($_POST['telephone'])? $_POST['telephone'] : ''; ?>" /> <?php if(in_array('telephone', $validation)): ?><script type="text/javascript">alert("Please enter telephone number"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-lastname">Message</label> <textarea cols="40" rows="5" id="comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea> <?php if(in_array('comment', $validation)): ?><script type="text/javascript">alert("Please enter your message"); history.back();</script><?php endif; ?> </div> <input class="submit_button" type="submit" value="Call us" /> </fieldset> </form> <?php else: ?> <p>Thank you for your Message!</p> <p>We will get back to you as soon as we can</p> <script type="text/javascript"> setTimeout ('ourRedirect()', 5000) function ourRedirect () { location.href='index.php' } </script> <?php endif; ?> Can someone show me a simple mail script that I can run in cli, I can enter a $to = email@email.com and then have it send to my email? just in cli.. Thanks Hi This is for a simple email client. I am trying to create a delete button that deletes a message when in message view from the MySQL database. Bellow is what I have so far. Currently it sends an alert confirming the message has been deleted and goes back to the inbox view where, it is evident that nothing has been deleted. Even when I log out then back in, the message is still there. Code: [Select] // This is how I call the JavaScript function in the html page: <input type="button" value="Delete" onclick="deleteMessage();" /> // This is the relevant JavaScript: /* ~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions used to Delete a message ~~~~~~~~~~~~~~~~~~~~~~~~~~ */ var requestDlt = false; // for the message to delete /* I created my own addition PHP script that, if correct, should delete a message when in message view */ function deleteMessage(mailNumber) { var url = "delete.php?mailID="+mailNumber; // assign to the url if (window.ActiveXObject) // if the users window matches this { // then requestDlt = new ActiveXObject("Microsoft.XMLHTTP"); // create a new ActiveXObject } else if (window.XMLHttpRequest) // else if the window matches this { // then requestDlt = new XMLHttpRequest(); // the global variable is an XMLHttpRequest } if (requestDlt!=null) // if the request exists { requestDlt.onreadystatechange=RequestFunctionDelete; // when ready envoke RequestFunctionMessage requestDlt.open("GET",url); // the request will now open the assigned url requestDlt.send(null); // send the request } } function RequestFunctionDelete() { if (requestDlt.readyState==4) // if all has been sent { // and if (requestDlt.status==200) // if it is all OK { /* if in message view, hide it, and show inbox */ if (document.getElementById("messageView").style.display!="none") { var response=requestDlt.responseText; // the variable response will hold the response text alert(response); // display the response to the user $("#messageView").fadeOut(1000, function() // hide message { $("#inboxBox").fadeIn(1000); // show inbox }); } else { // else /* Warn user they are unable to access button in this view */ alert("select a message you would like to delete"); } } } } // And lastly, here is the PHP Script that is called: <?php header('Content-Type: text/xml'); header("Cache-Control: no-cache, must-revalidate"); $dbhost = 'localhost'; $dbuser = 'cjc16'; $dbpass = 'cjc16'; $dbname = 'cjc16'; $dbtable = 'mail'; $id=$_GET["mailID"]; $con = mysql_connect($dbhost, $dbuser, $dbpass); if (!$con) { die('Could not connect: ' . mysql_error()); } $dbselect = mysql_select_db($dbname,$con); $sql="DELETE FROM $dbtable WHERE mailID='$id'"; $result = mysql_query($sql); if ($result) { echo "Deleted"; } else { echo 'Unable to delete'; } mysql_close($con); ?> Mod edit: [code] . . . [/code] tags added. Ok, I submit the form, and when the next page displays, it says recieved with the persons name, but it wont post their email, and it wont ever send the message to the email address......... i've been playing with it all day long and just cannot figure it out, about to rip my hair out... any help would be appreciated. Contact.php page Code: [Select] <?php // Header Include include('includes/header.php'); ?> <!-- BEGIN SITE CONTENT INCLUDES HERE --> <!-- Index page included --> <table border="0" cellpadding="5" cellspacing="0" width="300" align="center"> <tr> <td><font face="verdana" size="2" color=#"000000"><b>Feedback Form</b></font></td> <tr> <td><form name="contact" method="post" action="contact_submit.php"> <font face="verdana" size="1" color="#1b4a1b">Your Name:<br /> <input type="text" name="name" size="25" /> <br /> Email:<br /> <input type="text" name"email" size="25" /> <br /> Comments:</font><br /> <textarea name="comments" rows="5" cols="30"></textarea> <br /><input type="submit" name="submit" value="Send" /> </form></td> </tr> </table> <br /><br /> <!-- / End Index Page --> <!-- / END SITE CONTENT INCLUDES HERE --> <!-- Footer Include --> <?php include('includes/footer.php'); ?> Form Processing Script contact_submit.php Code: [Select] <?php $to = "tonyagmatrix@gmail.com"; $re = "Feedback Form"; $msg = $comments; mail($to,$re,$msg); ?> <html><head><title>Message Recieved</title></head> <body> <h3>Thank you for your feedback <?PHP echo ($name); ?></h3> <br />We value your opinions and any questions will be replyed to your email address: <?php echo ($email); ?> </body></html> Does anyone have any idea wtf is wrong? Hey everyone. I hope you can help me getting through this problem, because I have no idea of what else to try. I'm a web designer and sometimes modify Javascript, but my main focus is HTML and CSS, meaning I have no idea how to code in Javascript, but most importantly, how to write something from scratch in PHP. So I designed a form that works pretty well, and integrated a PHP and Javascript script to make it work. This is the form: Code: [Select] <form name="form" id="form" method="post" action="contact.php"> <p>Hello,</p> <p>My name is <input type="text" name="name">, from <input type="text" name="location">, and I'd like to get in touch with you for the following purpose:</p> <p><textarea name="message" rows="10" ></textarea></p> <p>By the way, my email address is <input type="text" name="email" id="email" placeholder="john@doe.com">, and I can prove I'm not a robot because I know the sky is <input type="text" name="code" placeholder="Red, green or blue?">.</p> <p title="Send this message."><input type="submit" id="submit" value="Take care."></p> </form> And this is the script, in an external file called contact.php: Code: [Select] <?php $name = check_input($_REQUEST['name'], "Please enter your name.") ; $location = check_input($_REQUEST['location']) ; $message = check_input($_REQUEST['message'], "Please write a message.") ; $email = check_input($_REQUEST['email'], "Please enter a valid email address.") ; if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) {die("E-mail address not valid");} if (strtolower($_POST['code']) != 'blue') {die('You are definitely a robot.');} $mail_status = mail( "my@email.com", "Hey!", "Hello,\n\n$message\n\nRegards,\n\n$name\n$location", "From: $email $name" ); function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { ?> <html> <body> <b>Please correct the following error:</b><br /> <?php echo $myError; ?> </body> </html> <?php exit(); } if ($mail_status) { ?> <script language="javascript" type="text/javascript"> alert('Thank you for the message. I will try to respond as soon as I can.'); window.location = '/about'; </script> <?php } else { ?> <script language="javascript" type="text/javascript"> alert('There was an error. Please try again in a few minutes, or send the message directly to aalejandro@bitsland.com.'); window.location = '/about'; </script> <?php } ?> So what it does is this: if everything's OK, it sends an email with "Hey!" as the subject, "[name]" as the sender, "Hello, [message]. Regards, [name], [location]" as the body, and a popup saying the message was delivered appears. If something fails, it outputs the error in a new address, so the user will have to go back to the form and correct the error. What I actually want to happen is this: if everything's OK, a <p> which was hidden beneath the form appears saying the message was delivered, or, alternatively, make the submit button gray out and confirm the message was delivered. I found a script to make this happen, but with "Please wait...", so the user can't resubmit the form. If there's an error, I'd like another <p> which was hidden to appear with the specific error, so there'd be many <p>'s hidden with different IDs. If possible, I'd also like to change the CSS style of the input field, specifically changing the border color to red, so it'd be a change in class for the particular field. -- So in essence, I want the errors and the success messages to output in the same page as the form (without refresh), and a change of class in the input fields that have an error. Thanks in advance, and please let me know if it'll be possible. Hi, folks -- I've been working on this for quite awhile, and have done lots of searching, but I still cannot make it work. Using Xampp on Win 7 x64, with PHP 5.3. Here is my simple PHP code just trying to get something to work: $to = 'my_real_email@gmail.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: someone@localhost.com' ; mail($to, $subject, $message, $headers); ?> (NOTE: "my_real_email" is set to my actual email address.) Here are my php.ini settings: Code: [Select] [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from ; sendmail_from = postmaster@localhost ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path sendmail_path = "\"E:\xampplite\sendmail\sendmail.exe\" -t" ; Force the addition of the specified parameters to be passed as extra parameters ; to the sendmail binary. These parameters will always replace the value of ; the 5th parameter to mail(), even in safe mode. ; mail.force_extra_parameters = ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename mail.add_x_header = Off ; Log all mail() calls including the full path of the script, line #, to address and headers mail.log = "E:\xampplite\apache\logs\php_mail.log" I'm not getting an error and the email seems to be getting "logged", but I do not receive an actual email in my account. Thanks for any suggestions. I have the simple code below which seems to have worked on forms from a contact page on a website. Unfortunately, it seems to only send the forms if all fields are entered. I have played with the code but cannot seem to get it to send any field that has been completed on submit. Can someone help please? <?php $emailAddress = "bigL@gmail.com"; $thankyouPage = ""; session_start(); if (!empty($_POST)) { foreach ($_POST as $key=>$value) { $_POST[$key] = stripslashes($_POST[$key]); $_POST[$key] = htmlspecialchars($_POST[$key],ENT_QUOTES); } } if (isset($_POST['send']) AND isset($_SESSION['msgCount'])) { if ($_SESSION['msgCount'] >= "3") $alert = "Only 3 messages can be s +ent per session."; if (empty($alert)) { $_SESSION['msgCount']++; putenv('TZ=EST5EDT'); // eastern time $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n" +; $message = "<table cellpadding='5' border='1'>"; foreach ($_POST as $key => $value) if (!preg_match("(^send)",$key)) { $value = wordwrap($value,65,"<br />"); $message .="<tr><td><b>$key</b></td><td>$value</td></tr>"; } $message .= "</table>"; $message .= "<br />Time of the message: ".date(" F d h:ia")."<br +/>"; $message .= "IP Address: ".$_SERVER['REMOTE_ADDR']."<br />"; $message .= "Hostname: ".gethostbyaddr($_SERVER['REMOTE_ADDR'])."< +br />"; $subject = $_SERVER['HTTP_HOST']." Message"; mail($emailAddress,$subject,$message,$headers); if (!empty($thankyouPage)) { header('location: '.$thankyouPage); die(); } unset($_POST); $alert = "Your enquiry has been sent, we will respond as soon as p +ossible."; } } if (!isset($_SESSION['msgCount'])) $_SESSION['msgCount'] = 0; ?> Hi Guys I'm trying to get clients to: 1. upload an image 2. fill out details 3. submit image and details to me via email 1. Uploading the image is fine, they choose it and it displays on the next page 2. They fill in form details 3. then click submit to send to me - I get all details except the image How do I keep the image variable around to insert it into the details form and email it? The image appears to be displayed on the second page, then the variable disappears (is deleted) and isn't available in step 3 to submit as part of the email. I'm sure it's a simple fix - I'm pretty new with php and I've started kicking things so I thought it was time to ask for help. Upload-image-code <?php if($_FILES) { $img = $_FILES['filename']['img']; switch($_FILES['filename']['type']) { case 'image/jpeg' : $ext = 'jpg'; break; case 'image/png' : $ext = 'png'; break; default: $ext = ''; break; } if ($ext) { $n = "image.$ext"; move_uploaded_file($_FILES['filename']['tmp_name'], $n); echo "<span class='uploaded-photo'>uploaded image '$img' as '$n':</span> <br />"; echo "<img src='$n' />"; } else echo "'$img' is not a supported image file"; } //else echo "<span class='uploaded-photo'>No image has been uploaded</span>"; ?> $n is available to be displayed on page 2 and it works Page 2 contains the rest of the form, but when I submit the form $n isn't available to be sent with the other data (i have tried REQUEST $img as well. Submit form code <?php $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $phone = $_REQUEST['phone'] ; $address = $_REQUEST['address'] ; $pname = $_REQUEST['pname'] ; $pdescription = $_REQUEST['pdescription']; $plow = $_REQUEST['plow'] ; $phigh = $_REQUEST['phigh'] ; $purl = $_REQUEST['purl'] ; $ponline = $_REQUEST['ponline'] ; $n = $_REQUEST['n']; $img = $_REQUEST['img']; if (!isset($_REQUEST['email'])) { echo "we need your name and email address please" ; } elseif (empty($name)){ echo "please enter your name"; } elseif (empty($email)){ echo "please enter your email address"; } elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})", "$email")) { echo"please check your email address - it doesn't appear to be a valid format"; } else { mail( "eamail@address.com", "Subject", "$name\n $email\n $phone\n $address\n $pname\n $pdescription\n $plow\n $phigh\n $purl\n $ponline\n $n\n $img", "$email"); header( "Location: ../index.php" ); } ?> Would really appreciate any help - if you need full code please let me know. Thanks @webecho I'm admittedly very ignorant about email in general. I want some way to send emails in a way that just works (tm). The receiver doesn't need to be able to reply so I don't want to mess with SMTP logins or anything. I have a list of email addresses that I want my script to loop through and send an email to each. I messed with the mail() function and passed my own email address to it with a subject and body and executed the script but I never got the email. I assume I have to configure some server or something in php.ini. Now, this script is going to be redistributed so I want to reduce the hassle required to install/configure it. Knowing this, can somebody link me to an article explaining the simplest way to send a very basic email? No HTML, no attachments, no replying, just simple subject/body email. |