PHP - Php Mail Form - Can't Make Id Stick
Hello.
I have a mail form (volunteer_send.php) for a site administrator to contact people associated with a certain activity (identified by the event_id variable). The variable is passed via URL from a preceeding page (as a variable called 'id'). I have spent crazy hours trying to figure out if i have a syntax error or something because I cannot get the variable to pass. If I hard code the event_id in the select statement, then it works fine. Also, I changed the syntax of the select statement to event_id = event_id and it emailed everyone in the list while I was testing. woops. any insight would be great. Code: [Select] <?php include('dbconfig.php'); // Make a MySQL Connection mysql_connect("localhost", "$user", "$password") or die(mysql_error()); mysql_select_db("$database") or die(mysql_error()); $adminmail="event@xxxxxxxx.com"; // Pass the event id variable $event_id=$_GET['id']; if(isset($_POST['submit'])) { $subject=$_POST['subject']; $nletter=$_POST['nletter']; if(strlen($subject)<1) { print "You did not enter a subject."; } else if(strlen($nletter)<1) { print "You did not enter a message."; } else { $nletter=$_POST['nletter']; $subject=$_POST['subject']; $nletter=stripslashes($nletter); $subject=stripslashes($subject); $lists=$_POST['lists']; $nletter=str_replace("rn","<br>",$nletter); //the block above formats the letter so it will send correctly. $getlist="SELECT * from volunteer WHERE event_id = '$event_id' "; //select e-mails in ABC order $getlist2=mysql_query($getlist) or die("Could not get list"); while($getlist3=mysql_fetch_array($getlist2)) { $headers = "From: $adminmail \r\n"; //unlock adminmail above and insert $adminmail for email address $headers.= "Content-Type: text/html; charset=ISO-8859-1 "; //send HTML enabled mail $headers .= "MIME-Version: 1.0 "; mail("$getlist3[email]","$subject","$nletter",$headers); } print "Your Message Has Been Sent."; } } else { print "<form action='volunteer_send.php' method='post'>"; print "Subject:<br>"; print "<input type='text' name='subject' size='20'><br>"; print "Message:<br>"; print "<textarea name='nletter' cols='50' rows='6'></textarea><br>"; print "<input type='submit' name='submit' value='submit'></form>"; } ?> Similar TutorialsI apologize in advance, I know pretty much nothing about PHP - don't hate me, please! But I'm working on a form mailer, and it functions, but what I don't like is it leaves all the text fields, blank or not, in my email, which makes it difficult for my client to read, so theres a long list of txt field1: another text field: blah blah: all the way down the email - and I want it gone! haha. I've researched how to do this, but basically, I have no idea how to implement it into my code and don't have time right now to up and learn PHP. My code is as follows: Code: [Select] <?php //--------------------------Set these paramaters-------------------------- // Subject of email sent to you. $subject = 'PCI Tour/Excursion Request'; // Your email address. This is where the form information will be sent. $emailadd = 'MY EMAIL HERE'; // Where to redirect after form is processed. $url = 'FORWARDING URL'; // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty. $req = '0'; // --------------------------Do not edit below this line-------------------------- $text = "Results from form:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 20) {echo "Name of form element $key cannot be longer than 20 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } mail($emailadd, $subject, $text, 'From: '.$emailadd.''); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?> IT was a very simple copy-paste form, but I have no idea what on earth I'm doing. If anyone has any ideas I would GREATLY appriciate the help! Thanks! -Austin system: vista ultimate sp2 IIS 7 server installed and running PHP 5 fastCGI im not sure if this is within the purview of the forum but you all seem like smart people with an expertise in this area. i have a web site http://penumbraproductions.dyndns-remote.com/ . it is hosted locally on my desktop using the above mentioned IIS7 server options using dyndns to list the url cause my ISP has DHCP without static ip's for non-business accounts that has a contact form... form mail. i've tried numerous php codes to get it to send mail to my email account but none of them are working my IIS smtp setting a email to: archaismic@gmail.com smtp server: smtp.gmail.com port number: 465 using login credentials i've also tried to configuring the smtp options in IIS to dump the mail to a folder on my computer which also did not work attached is the feedback.php file im currently working with minus the captcha private key and the code for the form i'm using is: Code: [Select] <form action="feedback.php" method="post"> <table border="0" cellpadding="8" cellspacing="8"> <tr><td><label for="tswname">Name</label>:</td><td><input type="text" name="fullname" id="tswname" size="25" /></td></tr> <tr><td><label for="tswemail">Email address</label>:</td><td><input type="text" id="tswemail" name="email" size="25" /></td></tr> <tr> <td colspan="2"> <label for="tswcomments">Comments</label><br /> <textarea rows="15" cols="45" name="comments" id="tswcomments"></textarea> </td> </tr> <tr> <td align="center" colspan="2"> <script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6LcYjcASAAAAAH1NwZ0IH_TUO4XDANZqWu3Ei9yh"></script> <noscript> <iframe src="http://api.recaptcha.net/noscript?k=6LcYjcASAAAAAH1NwZ0IH_TUO4XDANZqWu3Ei9yh" height="300" width="500" frameborder="0" title="CAPTCHA test"></iframe> <br /> <label for="tswcaptcha">Copy and paste the code provided in above box he </label><br /> <textarea name="recaptcha_challenge_field" id="tswcaptcha" rows="3" cols="40"></textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge" /> </noscript> </td> </tr> <tr> <td align="center" colspan="2"> <input type="submit" value="Send Feedback" /> </td> </tr> </table> </form> ok guys, another issue for me i cannot find an answer for. according to this thread: https://stackoverflow.com/questions/8803994/php-mail-not-working-for-some-reason, mail() doesn't work when smtp is not configured properly. I checked my server files and I do not have a .ini file. am I spose to have one by default? and, according to this question in the godaddy community: https://www.godaddy.com/community/Using-WordPress/PHP-ini-how-to-make-changes-using-cPanel/td-p/119704, configuration of PHP in general should be done in the .user.ini file instead of in php.ini. the following code, which is what I have now, results in no mail being sent to my address so either my code is wrong or my configs are not set properly I'm guessing: if( empty($errors)) { $to = '$myemail'; $email_subject = "Demo Request Submitted"; $email_body = "A demo request was submitted through your website with the following information:" . "Contact Name: " . $contact . " </br>" . "Company: " . $company . " </br>" . "Email: ". $email . " </br>" . "Phone: " . $phone . " </br>" . "Best Time to Contact: " . $best_time_to_contact . " </br>" . "Message: " . $message; $headers = "From: " . $myemail . "\n"; $headers = "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n"; mail($to, $email_subject, $email_body, $headers); echo "Your demo request has been sent."; } else { echo $errors; } also, in the stackoverflow article I mentioned above, one of the responders suggests using PHPMailer as a better way to send mail using PHP. Is that true? I've always used mail() in the past and I've never been let down in terms of a message *not* being sent. PHP.net says the same thing as the response from stackoverflow as well. thanks! Edited November 21, 2019 by ajetrumpetI have a notification system that notifies users of new comments, inside the email I have images, some of the logo, some of different people, everything shows up fine on my computer (yahoo email), however in the iPhones email application no images show up, there are just the blue squares with the question marks in them. I'm not sure what I'm missing. Code: [Select] $from = "Kithell <notifications@kithell.com>"; $headers = "From:" . $from ."\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $subject = name($from_id, 'fl').$action; $message = '<html><body> <style>@charset "utf-8"; /* CSS Document */ .e-container { background-color: #FFF;position: relative;width: 90%;min-height:1px;margin-right: auto;margin-left: auto; } .e-container .e-m-header { padding: 2px; background-image: url(http://www.kithell.com/assets/tall-grey-header.png); background-repeat: repeat-x; border: 1px solid #CCC; background-position: bottom; display: block; text-align: center; } .e-container p { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #666; vertical-align: text-top; display: inline-block; } .e-container .e-usr-photo { display: inline-block; margin: 10px; float: left; background-color: #F4F4F4; } .e-container p a { font-weight: bold; color: #3F60A3; text-decoration: underline; padding: 0px; float: left; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 0px; } .e-container .e-quotes { font-size: 20px; font-weight: bold; color: #999; font-family: Tahoma, Geneva, sans-serif; display: block; padding: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 75px; margin-top:10px; } .e-container .e-message { font-size: 13px; color: #333; padding: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 10px; clear: none; display: inline; }</style> <div class="e-container"><div class="e-m-header"><img src="http://www.kithell.com/assets/kithell-logo.png" /></div><img class="e-usr-photo" src="http://www.kithell.com/'.photo($from_id, 55).'" /><br /><p><a target="_blank" href="http://www.kithell.com/#/profile&id='.$from_id.'">'.name($from_id, "fl").' </a> '.$action.'<div class="e-quotes">"<p class="e-message">'.nl2br(htmlentities(stripslashes($message))).'</p>"</div></p></div></body></html>'; mail($to,$subject,$message,$headers); This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=347009.0 hello dear PHP-experts, today i create a rescue-system for the emergency-situation: i am creating a little resque-usb for SUSE-DVD on USB-Stick currently plan to create a litle Rescue-USB while using Suse-ISO DVD on a USB medium 1:1 copied step 1. Suse-ISO download: he http://ftp5.gwdg.de/...e-CD-x86_64.iso step 2 copy the file onto a USB stick with the following command dd if=openSUSE-13.2-Rescue-CD-x86_64.iso of=/dev/sdX bs=32kwhere sdX=sdb or sdc is the USB stick ready - now i can test the rescue-usb I have a pretty good php mailer script, but how do I get the senders email? When I test the form, the users email doesn't appear in the "From" field. Anyone know what I need to add to my code? Thanks. <?php if (array_key_exists('send', $_POST)) { // mail processing script // remove escape characters from POST array if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); } $from = 'Emailer Form'; $to = 'myEmail.com'; $subject = 'Interested in Urban Style Ballroom Dancing'; // list expected fields $expected = array('name', 'phone', 'email', 'address', 'city', 'state', 'zip', 'emailerMessage'); // set required fields $required = array('name', 'phone', 'email', 'address', 'city', 'state', 'zip', 'emailerMessage'); // create empty array for any missing fields $missing = array(); // process the $_POST variables foreach ($_POST as $key => $value) { // assign to temporary variable and strip whitespace if not an array $temp = is_array($value) ? $value : trim($value); // if empty and required, add to $missing array if (empty($temp) && in_array($key, $required)) { array_push($missing, $key); } // otherwise, assign to a variable of the same name as $key elseif (in_array($key, $expected)) { ${$key} = $temp; } } // go ahead only if all required fields OK if (empty($missing)) { // build the message $message = "name: $name\n\n"; $message .= "phone: $phone\n\n"; $message .= "email: $email\n\n"; $message .= "address: $address\n\n"; $message .= "city: $city\n\n"; $message .= "state: $state\n\n"; $message .= "zip: $zip\n\n"; $message .= "emailerMessage: $emailerMessage\n\n"; // limit line length to 70 characters $message = wordwrap($message, 70); // send it $mailSent = mail($to, $subject, $message); if ($mailSent) { // $missing is no longer needed if the email is sent, so unset it unset($missing); } } } ?> Okay, really dumb question... If I want to make an HTML Form that is really an E-mail Form so that visitors on my website can e-mail me, how do I do that? (I had read in a book last year that if you use an HTML Form, you can reduce/eliminate spam?!) Debbie I have this in a file called mailform.php. It check for valid email and phone number. If wrong it echo error but it still send the mail to me. I need for it if error not to send then redirect to same page with problems. no error redirect to main page. I can get to redirect with no problem. I can't figure out how to make it not send if errors. I hope I am explaining this right. Code: [Select] $fname = $_POST['firstName']; $lname = $_POST['lastName']; $degree = $_POST['Degree_Certificate']; $company = $_POST['companyName']; $address = $_POST['street']; $city = $_POST['city']; $state = $_POST['stateProvReg']; $phone = $_POST['phone']; $email = $_POST['email']; $message = $_POST['description']; $receive = "we receive your Affiliate information"; $formcontent=" Thank you $receive \n First Name: $fname \n Last Name: $lname \n Degree: $degree \n Company: $company \n Address: $address \n City: $city \n State: $state \n Phone: $phone \n Email: $email \n Description: $message"; $recipient = "webtechnician@brainmaster.com, $email"; $subject = "Affiliate List"; $mailheader = "From: $email \r\n"; if (validatePhone($phone)) { echo $phone . ' is a valid phone number.'; } else { echo $phone . ' is not valid phone number.'; } if (check_email_address($email)) { echo $email . ' is a valid email address.'; } else { echo $email . ' is not a valid email address, please hit the back button.'; } function check_email_address($email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; die("hit the back button"); } } } return true; } function validatePhone($phone) { $numbersOnly = ereg_replace("[^0-9]", "", $string); $numberOfDigits = strlen($numbersOnly); if ($numberOfDigits == 7 or $numberOfDigits == 10) { echo $numbersOnly; } else { echo 'Invalid Phone Number'; } } function valIP($string) { if (preg_match( '^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$^', $string)) { echo $string; } else { echo 'Invalid IP Address'; } } mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "Thank You!"; header('Location: http://#'); Hey everyone. I am extremely new to PHP coding and I wanted to take a shot at making a basic mail form submission. I have done a lot of research and cannot get my test files to work. No e-mails get sent to me. I appreciate any help you can offer. Here are the following pages: http://www.insightguild.com/contactformpage.html http://www.insightguild.com/sendmail.php (coding is viewable when you navigate to this file) I am using Bluehost.com as my hosting server. Thanks I have not been able to get my mail form to send messages to my email. The thank you page pops up after I test it, but nothing is sent. I use GoDaddy, so I'm not sure if that is part of the problem. This is my first attempt at PHP, so I don't know what I'm doing! I got the code from the Site Wizard. Any help would be great! Here is the code in my HTLM page for the form: <div id="package"> <fieldset id="personalinfo"> <legend class="perlegend"><img src="Art/header_contact.png" class="perlegendheader" > <div id="collage"></div> </legend> <p> </p> <form action="gdform.php" method="post"> <input type="hidden" name="redirect" value="thankyou.html" /> <p> <label for="name"> Name</label> <br> <input name="name" type="text"/> </p> <p> <label for="email">Email</label> <span class="required">(required)</span><br> <input name="email" type="text"/> </p> <p> <label class="top" for="comments">Message</label> <br> <textarea name="comments" cols="32" rows="5"></textarea> </p> <p> <input name="Submit" type="submit" class="submit" value="SEND"/> </p> </form> <br class="clear" /> </p> </fieldset > <br> </div> Here is my PHP code (without my real email address): <?php // ------------- CONFIGURABLE SECTION ------------------------ $mailto = 'XXX@gmail.com' ; $subject = "Message from Martha Berry Design" ; $formurl = "http://www.marthaberrydesign.com/contact.html" ; $errorurl = "http://www.marthaberrydesign.com/error.html" ; $thankyouurl = "http://www.marthaberrydesign.com/thankyou.html" ; $email_is_required = 1; $name_is_required = 0; $comments_is_required = 0; $uself = 0; $use_envsender = 0; $use_sendmailfrom = 1; $use_webmaster_email_for_from = 0; $use_utf8 = 1; $my_recaptcha_private_key = '' ; // -------------------- END OF CONFIGURABLE SECTION --------------- $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ; $content_type = (!isset( $use_utf8 ) || ($use_utf8 == 0)) ? 'Content-Type: text/plain; charset="iso-8859-1"' : 'Content-Type: text/plain; charset="utf-8"' ; if (!isset( $use_envsender )) { $use_envsender = 0 ; } if (isset( $use_sendmailfrom ) && $use_sendmailfrom) { ini_set( 'sendmail_from', $mailto ); } $envsender = "-f$mailto" ; $fullname = (isset($_POST['fullname']))? $_POST['fullname'] : $_POST['name'] ; $email = $_POST['email'] ; $comments = $_POST['comments'] ; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['email'])) { header( "Location: $formurl" ); exit ; } if (($email_is_required && (empty($email) || !preg_match('/@/', $email))) || ($name_is_required && empty($fullname)) || ($comments_is_required && empty($comments))) { header( "Location: $errorurl" ); exit ; } if ( preg_match( "/[\r\n]/", $fullname ) || preg_match( "/[\r\n]/", $email ) ) { header( "Location: $errorurl" ); exit ; } if (strlen( $my_recaptcha_private_key )) { require_once( 'recaptchalib.php' ); $resp = recaptcha_check_answer ( $my_recaptcha_private_key, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'] ); if (!$resp->is_valid) { header( "Location: $errorurl" ); exit ; } } if (empty($email)) { $email = $mailto ; } $fromemail = (!isset( $use_webmaster_email_for_from ) || ($use_webmaster_email_for_from == 0)) ? $email : $mailto ; if (function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc()) { $comments = stripslashes( $comments ); } $messageproper = "This message was sent from:\n" . "$http_referrer\n" . "------------------------------------------------------------\n" . "Name of sender: $fullname\n" . "Email of sender: $email\n" . "------------------------- COMMENTS -------------------------\n\n" . $comments . "\n\n------------------------------------------------------------\n" ; $headers = "From: \"$fullname\" <$fromemail>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.15.0" . $headersep . 'MIME-Version: 1.0' . $headersep . $content_type ; if ($use_envsender) { mail($mailto, $subject, $messageproper, $headers, $envsender ); } else { mail($mailto, $subject, $messageproper, $headers ); } header( "Location: $thankyouurl" ); exit ; ?> Hi
I'm a beginner in php and are facing a problem i cant seem to find the correct solution on. $item5 = $_POST['PIGM1']; if (empty($item5)) { $email_body .= ''; } if (isset($item5)) { $email_body = '<html><head><style type="text/css">td { width: 450; }</style></head><body>'; $email_body .= '<table border="0" width="900">'; $email_body .= '<tr><td><strong>Header in table</strong></td><td></td></tr>'; $email_body .= '<tr><td><strong>Ordered</strong></td><td>' . $item5 . ' pcs. of some item</td></tr>'; $email_body .= '</table><br />'; } Can anyone help me in the right direction? Hi, I have a (rather long) form on my site that when submitted send the information to me in an email. Ideally I would like to have the form only send me the information that has been filled out at current it sends everything. but for now I just need to know how I can style the email so its not one long list. also the form only comes through if an email adress is filled in it says it sends but I never recieve it. heres an example of the code for sending the email $Date = Trim(stripslashes($_POST['Date'])); $Packing = Trim(stripslashes($_POST['Packing'])); $Dismantle = Trim(stripslashes($_POST['Dismantle'])); $DismantleYes = Trim(stripslashes($_POST['DismantleYes'])); $Plumbing = Trim(stripslashes($_POST['Plumbing'])); $PlumbingYes = Trim(stripslashes($_POST['PlumbingYes'])); $LRSofa = Trim(stripslashes($_POST['LRSofa'])); $LRArmChair = Trim(stripslashes($_POST['LRArmChair'])); $LROtherChair = Trim(stripslashes($_POST['LROtherChair'])); $LRSCabinet = Trim(stripslashes($_POST['LRSCabinet'])); $LRLCabinet = Trim(stripslashes($_POST['LRLCabinet'])); $LRBookcase = Trim(stripslashes($_POST['LRBookcase'])); $LROTable = Trim(stripslashes($_POST['LROTable'])); $LRCTable = Trim(stripslashes($_POST['LRCTable'])); $LRTVStand = Trim(stripslashes($_POST['LRTVStand'])); $Body .= "Date of move: "; $Body .= $Date; $Body .= "\n"; $Body .= "Packing: "; $Body .= $Packing; $Body .= "\n"; $Body .= "Dismantle: "; $Body .= $Dismantle; $Body .= "\n"; $Body .= $DismantleYes; $Body .= "\n"; $Body .= "Plumbing: "; $Body .= $Plumbing; $Body .= "\n"; $Body .= $PlumbingYes; $Body .= "\n"; $Body .= "\n"; $Body .= "Living Room: "; $Body .= "\n"; $Body .= "Sofas: "; $Body .= $LRSofa; $Body .= "\n"; $Body .= "Arm Chairs: "; $Body .= $LRArmChair; $Body .= "\n"; $Body .= "Other Chairs: "; $Body .= $LROtherChair; $Body .= "\n"; $Body .= "Small Cabinets: "; $Body .= $LRSCabinet; $Body .= "\n"; $Body .= "Large Cabinets: "; $Body .= $LRLCabinet; $Body .= "\n"; $Body .= "Bookcases: "; $Body .= $LRBookcase; $Body .= "\n"; $Body .= "Occassional Tables: "; $Body .= $LROTable; $Body .= "\n"; $Body .= "Coffee Tables: "; $Body .= $LRCTable; $Body .= "\n"; $Body .= "TV Stand: "; // send email $success = mail($EmailTo, $Subject, $Body, "From: ". $FName ." ". $LName ." <". $Email.">"); // redirect to success page if ($success){ header ('Location: thankyou.php'); } else{ header ('Location: error.php'); } Hello all, Just started learning a bit of PHP from resources i can find over the net. I am working on a mail form and it works perfectly with the english text. no errors or issues. But when i type in arabic my outlook receives it as : فات ثيات سثسقغتن غتن فغثتن ثغ ثغن صف يفغن فغ ن صفغن ثعغ صتنفغت صنثفع Could anyone point out where my problem is please ? Thanks in advance and appreciate yoru help guys. Cheers. HTML - test.html Code: [Select] <!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>Form</title> <link href="style_form.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="form1" name="form1" method="post" action="test.php"> <table width="830" border="0" cellspacing="0" cellpadding="5"> <tr> <td height="78" colspan="2" valign="top" background="images/fheader.jpg"><p> </p> <p> </p></td> </tr> <tr> <td width="300" valign="top" style="border-bottom: 2px white solid; border-top: 8px white solid;"><strong>Name: *</strong></td> <td style="border-bottom: 2px white solid; border-top: 8px white solid;"><textarea name="name" cols="58" rows="1" id="name"></textarea></td> </tr> <tr> <td width="300" valign="top" style="border-bottom: 2px white solid;"><strong>Occupation: *</strong></td> <td style="border-bottom: 2px white solid;"><textarea name="occupation" id="occupation" cols="58" rows="1"></textarea></td> </tr> <tr> <td width="300" valign="top" style="border-bottom: 2px white solid;"><strong>Nationality: *</strong></td> <td style="border-bottom: 2px white solid;"><textarea name="nationality" cols="58" rows="1" id="nationality"></textarea></td> </tr> <tr> <td width="300" valign="top" style="border-bottom: 2px white solid;"><strong>Country of residence: *</strong></td> <td style="border-bottom: 2px white solid;"><textarea name="country" id="country" cols="58" rows="1"></textarea></td> </tr> <tr> <td width="300" valign="top" style="border-bottom: 2px white solid;"><strong>Telephone number: *</strong></td> <td style="border-bottom: 2px white solid;"><textarea name="telephone" id="telephone" cols="58" rows="1"></textarea></td> </tr> <tr> <td width="300" valign="top" style="border-bottom: 2px white solid;"><strong>Email address: *</strong></td> <td style="border-bottom: 2px white solid;"><textarea name="email" id="email" cols="58" rows="1"></textarea></td> </tr> <tr> <td width="300" valign="top" style="border-bottom: 2px white solid;"><strong>Comments:</strong> *</td> <td style="border-bottom: 2px white solid;"><textarea name="j" id="j" cols="58" rows="4"></textarea></td> </tr> <tr> <td width="300" valign="top" style="border-bottom: 2px white solid;"><strong>Comments about us: *</strong></td> <td style="border-bottom: 2px white solid;"><textarea name="jd" id="jd" cols="58" rows="4"></textarea></td> </tr> <tr > <td width="300" valign="top" style="border-bottom: 2px white solid;"><strong>Comments about the website: *</strong></td> <td style="border-bottom: 2px white solid;"><textarea name="website" id="website" cols="58" rows="4"></textarea></td> </tr> <tr> <td width="300" valign="top" style="border-bottom: 2px white solid;"><strong>Other information you wish to provide:</strong></td> <td style="border-bottom: 2px white solid;"><textarea name="other" id="other" cols="58" rows="4"></textarea></td> </tr> <tr> <td valign="top"> </td> <td><input type="submit" name="Submit" id="Submit" value="Submit" /> <input type="submit" name="Reset" id="Reset" value="Reset" /></td> </tr> </table> </form> </body> </html> PHP - test.php <?php if(isset($_POST['Submit'])) { $to = "email@email.com"; $subject = "Feedback [Arabic]"; $name_field = $_POST['name']; $occupation_field = $_POST['occupation']; $nationality_field = $_POST['nationality']; $country_field = $_POST['country']; $telephone_field = $_POST['telephone']; $email_field = $_POST['email']; $j_field = $_POST['j']; $jd_field = $_POST['jd']; $website_field = $_POST['website']; $other_field = $_POST['other']; $headers = "MIME-Version: 1.0 \n" ; $headers .= "Content-Type: text/plain;charset=UTF-8 \n"; $body = mb_convert_encoding($body, "UTF-8","AUTO"); mb_language("uni"); $body = "Name: $name_field\n\n Occupation: $occupation_field\n\n Nationality: $nationality_field\n\n Country of residence: $country_field\n\n Telephone: $telephone_field\n\n Email: $email_field\n\n Comments: $j_field\n\n Comments about us: $jd_field\n\n Comments about website: $website_field\n\n Other information: $other_field\n\n"; mb_send_mail($to, $subject, $body); } else { echo "error: no data sent!"; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Sending...</title> <meta http-equiv="refresh" content="1;url=fthankyou_ar.html"> <meta http-equi </head> <div align="center"> <p><img src="/images/loadbar.gif" width="232" height="11"></p> <p><b>Prcessing and redirecting ...</b></p> </div> </body> </html> I have this code as my session_init.php Code: [Select] <?php $_SESSION['APP_MX'] = "mail.mywebsite.com"; $_SESSION['APP_SERVER'] = "mywebsite.com"; $_SESSION['SITE_EMAIL'] = "admin@mywebsite.com"; $_SESSION['MYSQL_SERVER1'] = "localhost"; $_SESSION['MYSQL_LOGIN1'] = "root"; $_SESSION['MYSQL_PASS1'] = "password"; $_SESSION['MYSQL_DB1'] = "sample"; $_SESSION['LOGGEDIN'] = ""; $_SESSION['USERID'] = 0; $_SESSION['EMAIL'] = ""; $_SESSION['FNAME'] = ""; $_SESSION['LNAME'] = ""; $_SESSION['SESSION'] = true; ?> and I'm calling it here Code: [Select] <?php if(!isset($_SESSION['SESSION'])) require('../email/session_init.php'); $fname = $_POST["fname"]; $lname = $_POST["lname"]; $email= $_POST["email"]; $company = $_POST["company"]; $subject = $_POST["subject"]; $phone = $_POST["phone"]; $msg = $_POST["msg"]; $mail = "Hello $fname,\n\nThank your for your email.\nWe look forward to your evaluation of our product.\n\n"; $mail .= "Here is the information you have given us:\n\n"; $mail .= "Name: ".$fname." ".$lname."\n"; $mail .= "Company: ".$company."\n"; $mail .= "Email Address: ".$email."\n"; $mail .= "Phone: ".$phone."\n\n"; $mail .= "Subject: ".$subject."\n"; $mail .= "Your Message:\n".$msg."\n\n\n"; $mail .= "Best Regards,\nCustomer Service\n\n"; // If any lines are larger than 70 characters, we will use wordwrap() $message = wordwrap($msg, 70); mail($email, $subject, $mail, "From: admin@".$_SESSION['APP_SERVER']."\r\n"); $mail = str_replace("\n", "<br>", $mail); ?> And I'm getting this error Quote Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 26, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\php\website_interactivity\email\email_sent.php on line 33 I wonder if there's any modification that I need to do in my php.ini file. Anyone? I am trying to send the data entered in to the form to myself and to the user. At the moment I am getting the data sent to myself but cant find the way to send it to the user. I am using this code below <?php mail("webmaster@edgwaretown.co.uk", $subject, $message, $from); ?> How can I get the user to get the data by email as well? Thanks Gary I need this form to be sent to a mail after you press the button and to see the content that is sent , what is the easiest way to do this? http://fhcs.be/ Code: [Select] <?php // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions session_start(); $dranken=array(); $DrinkResult=mysql_query("SELECT name,price FROM products" )or die(mysql_error()); while($DrinkRow=mysql_fetch_assoc($DrinkResult)) { $dranken[]=$DrinkRow; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head></head> <body> <?php if (!isset($_POST['submit'])) { ?> <form method="post" action="mail.php"> <input type="submit" value="Toon Output" name="submit"/> <?php echo "<table>"; foreach ($dranken as $DrinkRow) { $optionlist = "<select name='{$DrinkRow['name']}_aantal'>"; for($i=0;$i<10;++$i) { $optionlist .= "<option value='$i'>$i</option>"; } $optionlist .= "</select>"; echo "<tr><td>". $DrinkRow['name']."</td><td>".$DrinkRow['price']."</td>"; echo "<td>$optionlist</td></tr>"; } echo "</table>"; ?> </form> <?php } else { echo "<table>"; $totaalPrijs = 0; foreach ($dranken as $DrinkRow) { $aantal = $_POST[ $DrinkRow['name'] . "_aantal"]; if ($aantal > 0) { $prijsperDrank = $aantal * $DrinkRow['price']; echo $DrinkRow['name'] . " : " . $aantal . " Prijs: " . $prijsperDrank . "</br>"; $totaalPrijs=$totaalPrijs + $prijsperDrank; } } if($totaalPrijs>0) { echo " totaal: " .$totaalPrijs; } echo "</table>"; } ?> </body> </html> Okay, below is my mailer for a contact form i created. On one site it works fine. I even have it sending to several addresses from the othersite. However this site it doesnt want to work. PHP5 and mail() function is active. <?php $Name = Trim(stripslashes($_POST['fullname'])); $EmailFrom = Trim(stripslashes($_POST['email'])); $EmailTo = "james@jd-creations.co.uk"; $Subject = Trim(stripslashes($_POST['subject'])); $answer = Trim(stripslashes($_POST['answer'])); $Comments = Trim(stripslashes($_POST['message'])); $Subject = "The Reason - Contact Us"; // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (Trim($answer)!=="20") $validationOK=false; if (Trim($Name)=="") $validationOK=false; if (Trim($Comments)=="") $validationOK=false; if (Trim($Subject)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=../contact/error2.php\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Email: "; $Body .= $EmailFrom; $Body .= "\n"; $Body .= "Comments: "; $Body .= $Comments; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=../contact/sent.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=../contact/error.php\">"; } ?> now i know it is wroking because it takes me to the sent.php page. not error.php i think it worked once. now not at all. How to add SMTP authentication for PHP mail form which is using POST function... |