PHP - I Am Trying To Get A User Name From Email Form Into A Html Thanks Message
Hi I built a really simple customer review form https://kickasssoftwear.uk/dev/reviews.html (it's only been optimised for mobile view so far) and it works using the php mail script on this page https://kickasssoftwear.uk/dev/empty2.php - the emails are being sent to me and the format of the emails is OK, and the form redirects to the empty2 page with a mailsent message in the address bar. I know I can leave that page as is and write a nice thank you message in the html - but what I really want to do is have the customers name there too, Thanks 'name' your review has been sent, but I can't get it to work - it's been 4 whole days now and I really need to eat & sleep! Please if anyone has suggestions or advice for a noob, please help. Thanks Similar TutorialsThe PHP code sends me an email from the server, but the user input is empty or "blank". I only receive: "From: \ Email: \ Subject: \ Message: " and that's it. How do I fix my PHP and/or HTML code to receive user input from the form? Attached is my existing HTML and PHP code that doesn't send me any "user input" from the form. Thanks to anyone who can help!!
Hi all I have a script that I have patched together and got to work in pieces. I'm up to the last part. I have the form working and emailing. It also will upload an image by itself and put it in a folder. Now i just need to tie those together and have the image put in the email as an attachment then deleted from server. I have it at a stage where it sends me the users details.. and it tries to send the photo but it comes through as junk txt. I think its the MIME encoding stuff that I have wrong.. not sure? Here's what I have so far. Code: [Select] $attachment = $path_of_uploaded_file; $fileatt = $attachment; // Path to the file $fileatt_type = "application/octet-stream"; // File Type $start= strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1; $fileatt_name = substr($attachment, $start, strlen($attachment)); // Filename that will be used for the file as the attachment $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers = "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\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); Thanks Wolfsta I am trying to eliminate this issue but I have had no luck here is my current code: Code: [Select] $from = 'help@my.com'; $body = "<html>\n"; $body .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif;\">\n"; $body .= $message; $body .= "</body>\n"; $body .= "</html>\n"; $boundary = uniqid('np'); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers = "From: $from"; $headers .= "\nMIME-Version: 1.0\n" ."Content-Type: multipart/alternative;\n" ." boundary=\"{$mime_boundary}\""; $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; \n" . "Content-Transfer-Encoding: 7bit\n\n" . $body . "\n\n" . "--{$mime_boundary}--\n"; mail($to, $subject, $message, $headers, '-f'.$from); I have tried adding the plain text part but nothing has worked, could someone else look at this and show me what I need to add so that it has the text/plain MIME part as well? Everything about the email is sending except the message text does anyone know what the issue could be? here is the block of code that sends the email Thanks in advance Code: [Select] $image = "http://www.visualrealityink.com/dev/clients/arzan/snell_form/images/email.png"; echo "got to process form"; $target_path = "upload/"; $path = $target_path = $target_path . basename( $_FILES['file']['name']); $boundary = '-----=' . md5( uniqid ( rand() ) ); $message .= "Content-Type: application/msword; name=\"my attachment\"\n"; $message .= "Content-Transfer-Encoding: base64\n"; $message .= "Content-Disposition: attachment; filename=\"$path\"\n\n"; echo $path; $fp = fopen($path, 'r'); do //we loop until there is no data left { $data = fread($fp, 8192); if (strlen($data) == 0) break; $content .= $data; } while (true); $content_encode = chunk_split(base64_encode($content)); $message .= $content_encode . "\n"; $message .= "--" . $boundary . "\n"; $message .= $image . "<br />" . $_POST['name'] . "submitted a resume on our website. Please review the applications and contact the candidate if their resume is a fit for any open opportunities with the company. <br><br> Thank you. <br><br> SEI Team"; $headers = "From: \"Me\"<me@example.com>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\""; mail('george@visualrealityink.com', 'Email with attachment from PHP', $headers, $message); Actually, what i want to do is to use the email to fetch the $email,$password and $randomnumber from database after Hi all New here. I have a basic email form that takes name phone email etc, also has 3 file upload boxes for photos. I have taken most of the code from free examples off the net and patched it together. It had an error message if something went wrong. I wanted to put an html page instead of just the txt. So read that I could end tag the php then do html then begin tag the php again. Problem is some of the error message was from a different part of the php code. How can i get this displayed on the html. Code: [Select] <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "email@email.com"; $email_subject = "JoinUs Model Form"; function died($error) { // your error code can go here ?> <title>title</title> <style type="text/css"> body { background-color: #000; text-align: center; } body,td,th { color: #FFF; font-family: Arial, Helvetica, sans-serif; font-size: 24px; } </style> </head> <body link="#FFFFFF" onload="setTimeout('history.back()',10000)"> <p><img src="../images/logo.png" width="326" height="144" alt="sdadfsd" longdesc="http://www.dgfsfdg.com" /><br /> </p> <br /> <p>We are very sorry, but there were error(s) found with the form you submitted.</p> <p>These errors appear below.</p> ####### this is where i want the below errors to appear in same format as html ######### <p>Click back to fix your error(s) or you will be taken back to the form automatically in 10 seconds...</p> <h6> </h6> <h6>© asafdsodf 2012</h6> </body> </html> <?php die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } // Where the file is going to be placed $target_path = "uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['form2']['photo1']); $target_path = $target_path . basename( $_FILES['form2']['photo2']); $target_path = $target_path . basename( $_FILES['form2']['photo3']); $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $comments = $_POST['comments']; // required $age = $_POST['age']; $city = $_POST['city']; $state = $_POST['state']; $height_feet = $_POST['height_feet']; $height_inches = $_POST['height_inches']; $photo1 = $_FILES['form2']['photo1']; $photo2 = $_FILES['form2']['photo2']; $photo3 = $_FILES['form2']['photo3']; $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($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form 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 .= "Age: ".clean_string($age)."\n"; $email_message .= "Height: ".clean_string($height_feet) .clean_string($height_inches)."\n"; $email_message .= "City: ".clean_string($city)."\n"; $email_message .= "State: ".clean_string($state)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; $email_message .= "".clean_string($comments)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; $email_message .= "Comments: ".clean_string($comments)."\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); ?> <!-- include your own success html here --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>asdf </title> <style type="text/css"> body { background-color: #000; text-align: center; } body,td,th { color: #FFF; font-family: Arial, Helvetica, sans-serif; font-size: 24px; } </style> </head> <body link="#FFFFFF"> <p><img src="./images/logo.png" width="326" height="144" alt="asdfahjdsfka" longdesc="http://www.kasdfhdskaha.com" /><br /> </p> <p>Thank your for applying to adskfha asdfasd. We will be in touch with you very soon.</p> <p>You will be redirected back to the site in 3 seconds...</p> <h6> </h6> <h6>© 2012</h6> </body> </html> <?php } ?> Thanks Wolfsta I'm having a problem getting my contact form information to arrive in the desired email account. The email account itself if provided by my web host. It has the ability to send and receive emails. The validation works perfectly eg when i type in incorrect/ miss out information it displays the appropriate error message. When i put in the proper information it displays the "Thank you for contacting us. We will be in touch with you very soon" message but not email arrives in the specified email account. Could someone please check over my code and see if there is something that I am missing? Below are the html form and php codes. Code: [Select] <form action="send_form_email.php" method="post" > <table width="400" border="0"> <tr> <td width="150" valign="top"> <label for="first_name">*First Name:-</label> </td> <td valign="top" align="right"> <input type="text" name="first_name" maxlength="50" size="37"> </td> </tr> <tr> <td width="150" valign="top"> <label for="last_name">*Last Name:-</label> </td> <td valign="top" align="right"> <input type="text" name="last_name" maxlength="50" size="37"> </td> </tr> <tr> <td width="150" valign="top"> <label for="email">*Email Address:-</label> </td> <td valign="top" align="right"> <input type="text" name="email" maxlength="50" size="37"> </td> </tr> <tr> <td width="150" valign="top"> <label for="phone">Telephone Number:-</label> </td> <td valign="top" align="right"> <input type="text" name="phone" maxlength="50" size="37"> </td> </tr> <tr> <td width="150" valign="top"> <label for="contact">Contact Time:-</label> </td> <td valign="top" align="right"> <select name="contact"> <option value="Anytime from 9am - 9pm!">Anytime from 9am - 9pm!</option> <option value="9am - 1pm">9am - 1pm</option> <option value="1pm - 2pm">1pm - 2pm</option> <option value="2pm - 6pm">2pm - 6pm</option> <option value="6pm - 9pm">6pm - 6pm</option> <option value="Please do not contact me by phone!">Please do not contact me by phone!</option> <option value="">_________________________________</option> </select> </td> </tr> <tr> <td width="150" valign="top"> <label for="find">How did you hear about MPM?</label> </td> <td valign="top" align="right"> <select name="find"> <option value="Search Engine">Search Engine</option> <option value="Facebook Ad">Facebook Ad</option> <option value="Facebook Profile">Facebook Profile</option> <option value="Gumtree Ad">Gumtree Ad</option> <option value="Recommendation">Recommendation</option> <option value="">_________________________________</option> </select> </td> </tr> <tr> <td colspan="2" valign="top"> <br> </td> </tr> <tr> <td colspan="2" valign="top"> <label for="comments">*Enquiry:-</label> </td> </tr> <tr> <td colspan="2" valign="top"> <center> <textarea name="comments" maxlength="1000" cols="47" rows="10"></textarea> </center> </td> </tr> <tr> <td colspan="2" valign="top"> <br> </td> </tr> <tr> <td colspan="2" align="center" valign="top"> * = Required Field </td> </tr> <tr> <td colspan="2" align="center" valign="top"> <input type="submit" value=" Send your enquiry! " /> </td> </tr> </table> </form> Code: [Select] <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "mrpaul@mrpaulmedia.co.uk"; $email_subject = "New customer information:"; function died($error) { // your error code can go here 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['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['phone']) || !isset($_POST['contact']) || !isset($_POST['find']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['phone']; // not required $contact = $_POST['contact']; // not required $find = $_POST['find']; // not required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "^[a-z .'-]+$"; if(!eregi($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!eregi($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "New customer 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 .= "Preferred Time of Contact: ".clean_string($contact)."\n"; $email_message .= "How did the customer find out about Mr Paul Media?: ".clean_string($find)."\n"; $email_message .= "Comments: ".clean_string($comments)."\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); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> I'd be very grateful for any help! I am building a website that allows a client to email me documents (DocX, PDF, TXT,ZIP, etc) along with a simple HTML based form. I used DreamWeaver to create the form and the upload area. I figured out how to script the PHP code to send the text fields to my email address (and validate them), but I can't figure out how to get the attachments to send. I am BRAND NEW to PHP and just trying to figure all thing out. Any help would be appreciated. I have attached two .txt files to this post. One is the HTML code for the forum and one is the actual PHP code I am using to send the form to my email. Thanks for your help! [attachment deleted by admin] I am brand new at php coding so I am struggling to understand why my php code is not working in my website. I would like my html form to send me data to my email. Whatever I try, it just will not work. I have ftp'ed it to my website and I checked with my web host, they do support php. Anyone who can help out a newbie, please?
This is my very simple form to capture email addresses of new clients: <form action="send_mail.php" method="post"> <input name="Email"
placeholder="Enter your email..." required="" type="email"> This is the php coding I have placed in a document called send_mail.php:
<?php /* Hi guys, sorry for such a newbish question. Any help would be greatly appreciated. HTML FORM: Code: [Select] <form action="form.php" method="post" onsubmit="return validateForm()" name="form"> <b>First Name:*</b> <input type="text" name="first_name" size="50" /> <b>Last Name:*</b> <input type="text" name="last_name" size="50" /> <b>Phone:*</b> <input type="text" name="phone" size="50" /> <b>Email:*</b> <input type="text" name="email" size="50" /> <p><b>What is your favorite color?*</b></p> <p align="left"> <select name="se"> <option value="W">White</option> <option value="G">Green</option> <option value="Y">Yellow</option> </select> <input type="submit" value="Submit"/> </form> FORM.PHP script Code: [Select] <?php $se = $_POST['se']; $seURL = ''; switch ($se) { case 'W': $seURL = "http://url1.com"; break; case 'G': $seURL = "http://url2.com"; break; case 'O': $seURL = "http://url3.com"; break; default: $seURL = ""; } if ($seURL != "") { /* Redirect browser */ /* make sure nothing is output to the page before this statement */ header("Location: " . $seURL); } // get posted data into local variables $EmailFrom = "noreply@domain.com"; $EmailTo = "email@domain.com"; $Subject = "Form"; $first_name = Trim(stripslashes($_POST['first_name'])); $last_name = Trim(stripslashes($_POST['last_name'])); $phone = Trim(stripslashes($_POST['phone'])); $email = Trim(stripslashes($_POST['email'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "first_name: "; $Body .= $first_name; $Body .= "\n"; $Body .= "last_name: "; $Body .= $last_name; $Body .= "\n"; $Body .= "phone: "; $Body .= $phone; $Body .= "\n"; $Body .= "email: "; $Body .= $email; $Body .= "\n"; $Body .= "color: "; $Body .= $se; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // send email to user if ($se=="W") $EmailFrom = "noreply@domain.com"; $to = $email; $subject = "form email"; $body = "thank you for filling out our form"; if (mail($to, $subject, $body, "From: <$EmailFrom>")) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> [code] MOD EDIT: [nobbc][code] . . . [/code][/nobbc] tags added . . . I am trying to build a form that will process all the user inputted information, and put those contents into an html table so that I can send the info to both my customer and myself. I figured out how to send an email to myself as html, but the user email is arriving as plain text with all the html tags. Someone had suggested PHPMailer, but I cannot figure out how to format it properly to work with my setup. I am new to PHP so this is a learning curve. I have included a sample of my process form with fictitious email addresses. Any help is much appreciated. Thank you in advance for the help! Code: [Select] <?php header("Location: ../contactthank.php"); ?> <?PHP $field_Type = $_POST['field_Type']; $field_Service_Provider = $_POST['field_Service_Provider']; $field_Brand = $_POST['field_Brand']; $field_Model = htmlspecialchars($_POST['field_Model']); $field_Size = $_POST['field_Size']; $field_Charger = $_POST['field_Charger']; $field_Case = $_POST['field_Case']; $field_Software = $_POST['field_Software']; $field_Manual = $_POST['field_Manual']; $field_Box = $_POST['field_Box']; $field_Condition = $_POST['field_Condition']; $field_FirstName = htmlspecialchars($_POST['field_FirstName']); $field_LastName = htmlspecialchars($_POST['field_LastName']); $field_Email = $_POST['field_Email']; $field_ZipCode = (int)$_POST['field_ZipCode']; $field_Comments = $_POST['field_Comments']; ?> <?php $reference = (rand(100000000000,99999999999999)); echo $reference; ?> <?php $to = "email@mail.com"; $subject = "Submission# $reference"; $headers = 'From: $field_Email' . "\r\n"; $message = '<html> <head> <title>Cell Phone Form Submission</title> </head> <body> <h1>Thank you for your submission. We will get back to you shortly</h1> <table border="1"> <tr> <td>Reference#</td> <td>' . $reference . '</td> </tr> <tr> <td>I want to</td> <td><b>Sell</b></td> </tr> <tr> <td>Service Provider</td> <td>' . $field_Service_Provider . '</td> </tr> <tr> <td>Model</td> <td>' . $field_Model . '</td> </tr> <tr> <td>Size</td> <td> ' . $field_Size . '</td> </tr> <tr> <td>Accessories</td> <td>' . $field_Charger . " " . $field_Case . " " . $field_Software . " " . $field_Manual . " " . $field_Box . '</td> </tr> <tr> <td>Condition</td> <td>' . $field_Condition . '</td> </tr> <tr> <td>Name</td> <td>' . $field_FirstName . " " . $field_LastName . '</td> </tr> <tr> <td>Email</td> <td>' . $field_Email . '</td> </tr> <tr> <td>Zip Code</td> <td>' . $field_ZipCode . '</td> </tr> <tr> <td>Comments</td> <td>' . $field_Comments . '</td> </tr> </table></body> </html> '; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $user = "$field_Email"; $usersubject = "Form Submission# $reference"; $userheaders = "From: email@mail.com\n"; $usermessage = '<html> <head> <title>Form Submission</title> </head> <body> <h1>Thank you. We will get back to you shortly</h1> <table border="1"> <tr> <td>Reference#</td> <td>' . $reference . '</td> </tr> <tr> <td>I want to</td> <td><b>Sell</b></td> </tr> <tr> <td>Service Provider</td> <td>' . $field_Service_Provider . '</td> </tr> <tr> <td>Model</td> <td>' . $field_Model . '</td> </tr> <tr> <td>Size</td> <td> ' . $field_Size . '</td> </tr> <tr> <td>Accessories</td> <td>' . $field_Charger . " " . $field_Case . " " . $field_Software . " " . $field_Manual . " " . $field_Box . '</td> </tr> <tr> <td>Condition</td> <td>' . $field_Condition . '</td> </tr> <tr> <td>Name</td> <td>' . $field_FirstName . " " . $field_LastName . '</td> </tr> <tr> <td>Email</td> <td>' . $field_Email . '</td> </tr> <tr> <td>Zip Code</td> <td>' . $field_ZipCode . '</td> </tr> <tr> <td>Comments</td> <td>' . $field_Comments . '</td> </tr> </table></body> </html> '; mail($to,$subject,$message,$headers); mail($user,$usersubject,$usermessage,$userheaders,$headers); ?> HTML code: Code: [Select] <form method="post" action="viewpage.php?page_id=5"> Email: <input name="email" type="text"><br> Full Name: <input name="name" type="text"><br> Age: <input name="age" type="text"><br> Summoner Name: <input name="summon" type="text"><br> Do you have vent? <input name="vent" type="text"><br> Do you have a mic? <input name="mic" type="text"><br> How often can you be on? <input name="online" type="text"><br> What level are you? <input name="level" type="text"><br> Who do you like to play as? <input name="champs" type="text"> </form><br> Can you help donate to the clan for vent and the site?<br> <textarea name="name" rows="7" cols="25"></textarea><br> Before you say anything about the PHP not scripted to do all fields, I already know this I'm trying to figure out how to send multiple ones in one message: PHP Code: Code: [Select] <?php if (isset($_POST['submit'])) { $to = "hidden for privacy"; $subject = "LoL Recruitment"; $email = $_REQUEST['email'] ; $message = ($_REQUEST['name'], $_REQUEST['age']) ; $headers = "From: $email"; $sent = mail($to, $subject, $message, $headers) ; if($sent) { print "Your mail was sent successfully"; } else { print "We encountered an error sending your mail"; } } ?> I'm willing to bet my Code: [Select] $message = ($_REQUEST['name'], $_REQUEST['age']) ;if FAR wrong Hi all I have a script that creates an email message, but I want to add a link to it to take the user to PayPal. Here's my code: $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=utf-8\n"; $headers .= "From: '".$_SERVER['HTTP_HOST']." Booking System' <info@".$_SERVER['HTTP_HOST']."> \n"; $subject = "Booking Confirmed!"; $message = "Dear ".$name.",<br /> <br /> This is confirmation of your booking. <br />"; $message .= "<table cellspacing=0 cellpadding=4 border=0>"; $message .= "<tr><td>Date</td><td>Time From</td><td>Time To</td></tr>"; $message .= $tempVar; $message .= "</table>"; $message .="<br />Reservation Status: Confirmed<br/>"; $message .="<br /><br />Kind Regards, <br /> ".$_SERVER['HTTP_HOST']." Team"; mail($email,$subject,$message,$headers); Can anyone help me add a line to the above to add the link in? Many thanks Pete I have an HTML form that I have a "select" drop-down menu that is selecting the name of the person you should send to. The names are being pulled from the Database, and here is what that code for the drop-down in the form looks like: <?php echo '<select name= "First_Name" , "Last_Name">'; while( $array = mysql_fetch_assoc($result) ) { $text_for_select = $array["First_Name"] . " " . $array["Last_Name"]. " " . $array["District"]; $value_for_select = $array["First_Name"] . " " . $array["Last_Name"] . "_" . $array["id"]; echo "<option></option>\n"; echo "<option value=\"$value_for_select\">$text_for_select</option>\n"; } echo '</select>';?> This works perfectly. However, what I want it to do is send the form to the email address of the person that is selected in the drop-down. The email address' are already entered in each record of the database in a field called "Email". I am using the $value_for_select variable to pull the id of the record, but I am unsure how to then tell the form to send to the email address of that record? Anybody know a way that this can be done? Here is the code of the for that should be sent: <?php if($_POST){ $to = $email; $subject = "WHAT SHOULD THIS BE"; $message = "Date: $date\n\r". "Dear $First_Name, $Last_Name,\n\r". "Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah..\n\r". "Sincerely,\n". "$name \n". "$street \n". "$city, $zip \n". "$email \\n". $headers = "From: $email"; mail($to, $subject, $message, $headers); // SUCCESS! echo '<p class="notice">'. 'Thank you for your submission. '. '</p>'; // clear out the variables for good-housekeeping unset($date,$legislator,$bill,$name,$street,$city,$zip,$email); $_POST = array(); } ?> Please help! Greetings Fellow PHPFreaks! LovableCodeMan here - newbie to this forum an pretty new to this PHP thing that all these youngsters are raving about - who knew?! Anyway, so I have an HTML form set up with a PHP document attached in order to send the data from the form to an email -a pretty basic setup by todays standards. In the PHP document, you can see that there is a section for the user (sender@xyz.com) to submit the information in the form to us & is sent to our email address "receiver@xyz.com". The bottom segment is to send a confirmation email back to the sender - to "sender@xyz.com" - as a thank you and a "We will get back to you ASAP" etc etc etc. The confirmation email sent to the sender@xyz.com works flawlessly when pressing the "Send Your Message" button, but then I just see "https://www.xyz.com/scripts/mail.php" in the address bar and no email is received by receiver@xyz.com - aka "Us". This is the PHP document - confidential information redacted & the "sender@xyz.com" & "receiver@xyz.com" replace the real email addresses. <!doctype html> <?php $title = $_POST['title']; $first = $_POST['first']; $surname = $_POST['surname']; $email = $_POST['email']; <!------- sender@xyz.com---> $internationalCode = $_POST['internationalCode']; $number = $_POST['number']; $userMessage = $_POST['userMessage']; $company = $_POST['company']; $Industrytype = $_POST['Industrytype']; $inc_status = $_POST['inc_status']; $state = ['state']; $email_from = "$first $surname <smtp server login>"; $Password = 'smtp server password'; $email_subject = "Website Enquiry from $first $surname"; $messageTo = "receiver@xyz.com"; $email_body = "User title: $title. \n". "The department this message is for is: $department.\n". "User First Name: $first.\n". "User Surname Name: $surname. \n". "User email: $email.\n". "International Dialing Code: $internationalCode. \n". "User Contact Number: $number.\n". "State of Incorporation: $state.\n". "File: $attachment.\n". "Company Name: $company, $inc_status.\n". "Industry type: $Industrytype.\n". "User Message is: $userMessage.\n"; $headers = "From: $email_from" . "\r\n" . "Reply to: $first $surname". "\r\n"; mail($messageTo, $email_subject, $email_body, $headers, "-fweb_support@xyz.com"); header('Location: https://www.xyz.com/thank_you.html'); <!--------Confirmation email send to sender@xyz.com below----------------> $respond_subject = "Thank you for your message"; /* Prepare autoresponder message */ $respond_message = " Hi $first, Thank you for messaging to us. We will aim to reply to you within 24 hours. In the meantime, why not follow our other stories via, as well as following, our Facebook page. Simply go to https://www.facebook.com/xyz/ Yours sincerely, The Support Team receiver@xyz.com. "; $headers = 'From: <Sender> <no-reply@xyz.com>' . "\r\n" . 'Reply-To: $email' . "\r\n" .<!------- sender@xyz.com---> 'X-Mailer: PHP/' . phpversion(); /* Send the message using mail() function */ mail($email, $respond_subject, $respond_message, $headers, "-fno-reply@xyz.com"); //} ?>
This is the HTML document:
<!doctype html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> </head> <body> <form role="form-inline" method="POST" action="../scripts/mail.php"> <div class="form-group"> <div class="row"> <div class="col-lg-2 col-md-4 col-sm-4 col-xs-4 select "> <select class="" id="standard-select" name="title"> <option selected disabled>Title *</option> <option>Dr.</option> <option>Mr.</option> <option>Mrs.</option> <option>Ms.</option> <option>Prof.</option> <option>Rev.</option> <option>Pastor.</option> <option>Miss.</option> </select> </div> <div class="col-lg-4 col-md-4 col-sm-8 col-xs-8"> <input name="first" type="text" placeholder="First Name *" required/> </div> <div class="col-lg-6 col-md-4"> <input name="surname" type="text" placeholder="Surname *" required/> </div> </div> <div class="row"> <div class="col-lg-6 col-md-4 col-sm-6 col-xs-12"> <input name="email" type="email" placeholder="Email *" required/> </div> <label for="standard-select"></label> <div class="col-lg-2 col-md-4 col-sm-6 col-xs-5 select"> <select class="" name="internationalCode" id=""> <option data-countryCode="GB" value="44" Selected>UK (+44)</option> <option data-countryCode="US" value="1" >USA (+1)</option> <optgroup label="Other countries"> <option data-countryCode="DZ" value="213">Algeria (+213)</option> <option data-countryCode="AD" value="376">Andorra (+376)</option> <option data-countryCode="AO" value="244">Angola (+244)</option> <option data-countryCode="AI" value="1264">Anguilla (+1264)</option> <option data-countryCode="AG" value="1268">Antigua & Barbuda (+1268)</option> <option data-countryCode="AR" value="54">Argentina (+54)</option> <option data-countryCode="AM" value="374">Armenia (+374)</option> </optgroup> </select> </div> <div class="col-lg-4 col-md-4 col-sm-12 col-xs-7"> <input type="tel" name="number" placeholder="Telephone Number *" required/> </div> </div> <div class="row"> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 select"> <select name="inc_status" required> <option selected disabled>Incorporation status *</option> <option>Limited by Guarantee</option> <option>Limited by Shares</option> <option>CIC</option> <option>CIO</option> <option>Unincorporated</option> <option>LLP</option> <option>LLC</option> <option>Other</option> </select> </div> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 select"> <select name="state" disabled> <option selected disabled>State of incorporation *</option> <option value="AL">Alabama</option> <option value="AK">Alaska</option> <option value="AZ">Arizona</option> <option value="AR">Arkansas</option> <option value="CA">California</option> <option value="CO">Colorado</option> <option value="CT">Connecticut</option> <option value="DE">Delaware</option> <option value="DC">District Of Columbia</option> <option value="FL">Florida</option> </select> </div> </div> <div class="row"> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"> <input name="company" type="text" placeholder="Company *" required/> </div> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 select"> <select class="" name="Industrytype" id="select" value=""> <option selected disabled value="">Industry *</option> <option value="Appraisal/Disposition">Appraisal/Disposition</option> <option value="Business Services">Business Services</option> <option value="Consulting">Consulting</option> <option value="Business Broker">Business Broker</option> <option value="Distribution">Distribution</option> <option value="Education">Education</option> <option value="Financial Services (Non-Lender)">Financial Services (Non-Lender)</option> <option value="Government">Government</option> <option value="Healthcare">Healthcare</option> <option value="Insurance">Insurance</option> <option value="Investment Banking">Investment Banking</option> <option value="Law">Law</option> <option value="Lender">Lender</option> <option value="Logistics">Logistics</option> <option value="Manufacturing">Manufacturing</option> <option value="Media/Print/Broadcast/Internet">Media/Print/Broadcast/Internet</option> <option value="Other">Other</option> <option value="Private Equity/Venture Capital">Private Equity/Venture Capital</option> <option value="Real Estate Services">Real Estate Services</option> <option value="Receivables">Receivables</option> <option value="Retail">Retail</option> <option value="Technology">Technology</option> <option value="Turnaround/Restructuring">Turnaround/Restructuring</option> <option value="Utility">Utility</option> <option value="Wholesale">Wholesale</option> </select> </div> </div> <div class="row"> <div class="col-lg-12"> <textarea name="userMessage" placeholder="Please type your message here. Do not include any personal information such as your NIN or any banking information."></textarea> </div> </div> <div class="row"> <div class="col-lg-6 col-md-12 col-sm-12 col-xs-12"> <div class="" style="background-color: #E0DDDD; padding: 20px;"> <p style="font-size: 12px; color: #0d0155">Information is held under the provision of the General Data Protection Regulation (GDPR). We will not pass your details on to any other organisation. We will process your information in accordance with our privacy policy. By send this message, you agree to xxxxxxx's <a style="color: #0D0155; text-decoration: underline;" href="/privacy/online_privacy_notice.html" target="_new" class="inline_link__new_window">Online Privacy Policy</a> </p> </div> </div> <div class="col-lg-6 col-md-12 col-sm-12 col-xs-12"> <input type="submit" id="submit" name="submit" value="Send your message"/> </div> </div> </div> </form> </body> </html> Anyone know where I'm going wrong, it "half works" so I'm Half Way There - & yes, I am Livin' on a Prayer! Thanks in advance! The LovableCodeman I have a page which contains php scripts for the values that will be send through email. my problem is when i send it, it doesn't read the php script. The body only read plain html text. how can I output my php script values through html I have a bit of php code to send me an email when someone logs in to my site. I want to include the person's name and two other bits from my database, but I can't get the formatting correct. I keep getting errors when I try to load the page. Here's the code which obviously has mistakes. The first code works, it's the second one that does not work for the $message line .
if (mysql_num_rows($exe) == 1) { $message_m = "Someone with RefCode ".$RefC." has viewed the homepage for the first time."; mail("ray.fellers@gmail.com", "Good News! Someone just logged in to view the home page", $message_m); setcookie("has_entered_correct_refcode", "true", time()+27000000, "/"); setcookie("has_entered_correct_refcode_value", $_POST["refcode"], time()+27000000, "/"); header("Location: /index.php"); die(); if (mysql_num_rows($exe) == 1) { $message_m =" "'.$_POST['fname'].'," with RefCode "'.$RefC.'," and refund amount of "'.$_POST['refvalact'].'," has viewed the homepage."; mail("ray.fellers@gmail.com", "Good News! Someone just logged in to view the home page", $message_m); setcookie("has_entered_correct_refcode", "true", time()+27000000, "/"); setcookie("has_entered_correct_refcode_value", $_POST["refcode"], time()+27000000, "/"); header("Location: /index.php"); die(); }Thanks for any help to resolve this. Hi all, I am just starting out in the world of php and have got this far with a lot of googling. But I'm really stuck with this part now. I have a function that works perfectly for display on a page, eg <?php echo quickquote(); ?> function quickquote() { global $db; global $cart; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $quickquote[] = 'Quote Required:<br />'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM products WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $quickquote[] = ''.$qty.''; $quickquote[] = ' x '; $quickquote[] = '' . $model . ''; $quickquote[] = ' (' . $type . '- '; $quickquote[] = ''. $basin . '- '; $quickquote[] = ''. $top . ')'; $quickquote[] = '<br />'; } $quickquote[] = 'End of Quick Quote Request'; } else { $quickquote[] = 'The quote cart is empty.'; } return join('',$quickquote); } However, i am trying to include this in an email message: if(!$error) { $messages="From: $email <br>"; $messages.="Name: $name <br>"; $messages.="Email: $email <br>"; $messages.="Phone: $phone <br>"; $messages.="Message: $message <br>"; $messages.="Quick Quote Request: $quickquote <br>"; $mail = mail($to,$subject,$messages,$headers); The email also works perfectly with the exception that the data is not there from $quickquote. I've tried all sorts of variations and suggested solutions from the web but nothing I've tried has been successful so far. It's amazing that I've got this far so I don't want to give up on it, but I'm just completely stumped ... All information and help very much appreciated. Cheers K Hi I have a problem with parsing a query into the email message. Where messege shuld be a complete resoult of a query. Please take a look on code below: Code: [Select] $message = "\r\n" . 'Order details:' . '<br><br><table><tr><td>Name</td><td>Amount</td><td>Unit</td><td>Price</td><td>Total</td></tr>' . "\r\n"; /// till here is fine $result2 = mysql_query("SELECT * FROM orderslist WHERE supplier='$supplier'") or die(mysql_error()); $data = array(); $data['' . $row2['id']] = $_POST['' . $row2['id']]; $value = $_POST['' . $row2['id']]; while($row2=mysql_fetch_array($result2)) { $value = $_POST['' . $row2['id']]; if ( $value == ""){ } else { $total = $value * $row2['price']; /// this part below i have a problem with do not now how to join this part with the top part ($message) echo " <tr> <td class='H4'><strong>$row2[name]</strong></td> <td class='H4' align='center'>$value</td> <td class='H4'>$row2[unit]</td> <td class='H4'>$row2[price]</td> <td class='H4'>$total</td></tr>"; } } echo "</table>"; I think that has something to do with "\r\n" and dots, but i do not get that fully. If someone could help me on this one will be gratefull. Thank you very much in advance. |