PHP - How To Create An Email Confirmation
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 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) 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'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 ************* */ 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? 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 JordanCI have a form on my website that currently uses the mail() function to send the information it collects and all works fine. I want to switch it over to open the email in Thunderbird on the user's machine so they can view it prior to sending. This should be much less complicated but I can't find answers anywhere, all I want to do is just open the email in the user's email client with the proper information/attachments included. Anyone? Thanks! Hi All, I don't really need help with the code, I just need to know the process... This will take place in a simple form. The user enters the payment information and checks off 'Send Receipt' option. From there, the payment data is stored in the DB. Then, I need to have a PDF generated of the receipt and finally email the tenant with confirmation and the PDF that was created. Once the data is inserted, I can use fPDF to merge the data to the PDF document I created. That part I don't understand is how to automatically save that file and attach it to an email. Ideas / suggestions? How to create a pdf dynamically and that pdf should sent as a email attachment.
Hi guys, I am thinking of create an free email system by sending an messages using with a username. Would I have to store the messages via in mysql? If I can do that, then I just curious that how would a user delete their messages if their messages is display on php page? What method would I have to use? I'm trying to after submission
1. create a csv
2. insert record into db
3. send email that's created in form submission - $msg.
4. send email with attachment to only the email I specify (if possible)
if not attach it to the email that's created at submission.
I've search and search and found different methods but doesn't work with my code.
I kept 3 lines at the top but can't get them to work ... either I don't get an email after submission or don't get an attachement.
Can some one help?
<?php $random_hash = md5(date('r', time())); $csvString = "..."; // your entire csv as a string $attachment = chunk_split(base64_encode($csvString)); $to = "email@email.com"; if(isset($_POST['submit'])) { // VALIDATION if(empty($_POST['firstName'])) { "First Name Required"; } if(empty($_POST['lastName'])) { "Last Name Required"; } if(empty($error)) { $to = "$to"; $subject = 'The Form'; $headers = "MIME-Version: 1.0 \r\n"; $headers .= "Content-Type: text/html; \r\n" ; $msg .="<html> <head></head> <body> <table width='100%' cellspacing='0' border='0' cellpadding='0'> <tr><td> <table width='100%' cellspacing='0' border='0' cellpadding='0'> <tr><td>This is the email sent.</td></tr> </table> </body> </html>"; include('con.php'); $con = mysqli_connect($host,$user,$pass,$dbName); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"thetable"); $firstName = mysqli_real_escape_string($con, $_POST['firstName']); $lastName = mysqli_real_escape_string($con, $_POST['lastName']); $sql = "SELECT * FROM thetable WHERE `firstName` = '{$firstName}' OR `lastName` = '{$lastName}'"; $result = mysqli_query($con,$sql); if(($result->num_rows)>= 1) { $theerror = "You exist"; } else { $sql="INSERT INTO thetable(firstName, lastName) VALUES ('$_POST[firstName]','$_POST[lastName]'"; $success = "Sent ... Insert it!!!"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } $result = @mail($to, $subject, $msg, $headers); } mysqli_close($con); { } } } ?> Edited by barkly, 27 October 2014 - 02:59 PM. Hi, i have tried everything i can think of to get this to work correctly. What is below here, is what i have last tried to work with..: basically the script allows the use to register an email account on a cpanel domain. Everything works perfectly but then i added a option for banned words now i cant get the script to work.. basically what happens is: the user creates an email account, if the account is not a banned word and does not exist, then the message echoes success, and the $_Post values are also entered into the database under the users name. and the email is also created with the $f fopen if success the email form also does not show.. so only one email per user.. i just cant get it to work with the banned words included.. what to note:: this is a function in a function.. $bannedemailwords='customerinformation,custinfo,customerinfo,custtext,custsupport,customersupport,admin,accounts'; $bannedmail=explode(',', $bannedemailwords); $bannedmail = array_unique($bannedmail); sort($bannedmail); foreach($bannedmail as $noemail) //the selected username if ($Config['enablemyemailapp_enable'] == '0' && $_POST['cfg_enablemyemailappaddress_enable'] !== $noemaill && $_POST['cfg_enablemyemailappaddressdomain_enable'] !== 'Select a domain'){ $cpuser = 'ausername'; $cppass = 'apassword'; $cpdomain = 'adomain'; $cpskin = 'askin'; $epass = 'somepassword'; $equota = 'somequota'; $euser = $_POST['cfg_enablemyemailappaddress_enable']; $epass = $_POST['emailspassword_enable']; $edomain = $_POST['cfg_enablemyemailappaddressdomain_enable']; if (!empty($euser) && $euser !=='nomail') while(true) { $f = fopen ("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass"a=$equota", "r"); if (!$f) { $enablemyemailapp_enable = '0'; $enablemyemailappaddress_enable = 'Replace with a Name'; $enablemyemailappaddressdomain_enable = 'Select a domain'; $msgemail = 'The email '.$euser.'@'.$edomain.' is a restricted email account.'; break; } $enablemyemailapp_enable = '1'; $enablemyemailappaddress_enable = $_POST['cfg_enablemyemailappaddress_enable']; $enablemyemailappaddressdomain_enable = $_POST['cfg_enablemyemailappaddressdomain_enable']; $msgemail ='<center><font color="#ff0033">Your Email '.$euser.'@'.$edomain.' has been created.</font></center>'; while (!feof ($f)) { $line = fgets ($f, 1024); if (ereg ("already exists", $line, $out)) { $enablemyemailapp_enable = '0'; $enablemyemailappaddress_enable = 'Replace with a Name'; $enablemyemailappaddressdomain_enable = 'Select a domain'; $msgemail ='<center><font color="#ff0033">The email account '.$euser.'@'.$edomain.' already exists.</font></center><br><center>Please try again!</center>'; break; } } echo $msgemail; $_POST['cfg_enablemyemailapp_enable']= $enablemyemailapp_enable; $_POST['cfg_enablemyemailappaddress_enable']=$enablemyemailappaddress_enable; $_POST['cfg_enablemyemailappaddressdomain_enable']=$enablemyemailappaddressdomain_enable; @fclose($f); break; } } Hello all I have a php and jquery/ajax call I am using to create a file/send an email. I get all the contents from my textboxes but I want a message to display on the screen afterwards being success or fail. In my .ajax call My call is exiting right before the ‘success:’ part. Why is my call not succeeding? Any tips/help will be appreciated Thank you Html page just a form with a submit button $(document).ready(function () { var form = $("#formData"); $(form).on("submit", function (event) { event.preventDefault(); $.ajax({ type: "post", url: "file.php", data: $(this).serialize(), beforeSend: function () { $("#status").html('<span style="color:red;">Loading everything actually creating a .TXT file of contents...</span>') //--works }, success: function (data) { var responseMsgType = "alert-" + data.type; var responseMsgText = data.message; // message below var alertBox = '<div class="alert ' + responseMsgType + ' alert-dismissable"><button type="button" class="close" ' + 'data-dismiss="alert" aria-hidden="true">×</button>' + responseMsgText + '</div>'; if (responseMsgType && responseMsgText) { $(form).find(".successArea").html(alertBox); $(form)[0].reset(); } } }); return false; }); <?php $controls = array('txtName' => 'Name', 'txtEmail' => 'Email', 'txtSubject' => 'Subject', 'txtMessage' => 'Message'); try { if(count($_POST)==0) { throw new \Exception ('Contact Form Message is empty'); } $headers = array('Content-Type: text/plain; charset="UTF-8";', 'From: ' . $email, 'Reply-To: ' . $email, 'Return-Path: ' .$email); $emailMessage = "You have a new message from your contact form" . PHP_EOL; $emailMessage .= "-------------------------------------------------------" . PHP_EOL; foreach($_POST as $key => $value){ if(isset($controls[$key])) { $emailMessage .= "$controls[$key]: $value". PHP_EOL; } } $mailMsg = "email6.txt"; if(file_exists($filename) == false) { $fh = fopen($mailMsg, "w"); fwrite($fh, $headers); fwrite($fh, $emailMessage); fclose($fh); } else { $fhexists = fopen($filename, "a"); fwrite($fhexists, $content); fclose($fhexists); } $responseMessage = array("type" => "success", "message" => $successMessage); } catch (\Exception $ex) { $responseMessage = array("type" => "errorM", "message" => $errorMessage); } if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { $encodedJSON = json_encode($responseMessage); header("Content-Type: application/json"); echo $encodedJSON; } else { echo $responseMessage["message"]; }
i wanting users to be able to update there email address and check to see if the new email already exists. if the email is the same as current email ignore the check. i have no errors showing up but if I enter a email already in the db it still accepts the new email instead of bringing the back the error message. Code: [Select] // email enterd from form // $email=$_POST['email']; $queryuser=mysql_query("SELECT * FROM members WHERE inv='$ivn' ") or die (mysql_error()); while($info = mysql_fetch_array( $queryuser )) { $check=$info['email']; // gets current email // } if($check!=$email){ // if check not equal to $email check the new email address already exists// $queryuser=mysql_query("SELECT * FROM members WHERE email='$email' "); //$result=mysql_query($sql); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { $error= "0"; header('LOCATION:../pages/myprofile.php?id='.$error.''); } } cheers I have created a registration form for my website. I want that, whenever any user register to my website an automated mail is send to the Email (with an confirmation link of registration) which he had given their.... I am able to send mails via smtp but dont know how to create a confirmation link url... I thought so that it must be the cookie which automatically generated on the registration.. I need your help.. Thanx in advance... hI, im trying to create a delete confirmation box. This particular line is showing error as below : Parse error: parse error, expecting `','' or `';'' in C:\wamp\www\i-document\search_admin.php on line 103 please help. thankz. echo "<td><a href=" . $rows['url'] . ">" . $rows['url'] . "</a></td>"; echo "<td><a href=edit_doc.php?id=" . $rows['id'] . ">Edit</a></td>"; echo "<td><a href=delete.php?id=" . $rows['id'] ." onClick="return confirm('Are you sure you want to delete?');">Delete</a></td>"; |