PHP - Double Email Problem!
Would you please help me to fix the problem of sending two emails instead of just one every time I run the following code using this url:
http://domain.org/image.php?path=dir/file.jpg Code: [Select] <?php $email="email@domain.org"; $body = "the body"; $subject="the subject"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Image Visit Receipt <rr@mrdv.org>' . "\r\n"; mail($email,$subject,$body,$headers); if ($HTTP_GET_VARS["path"]) { $imagepath="/home2/mydomain/public_html/files/images/".$HTTP_GET_VARS["path"]; if (file_exists($imagepath)) { $image=imagecreatefromjpeg($imagepath); header('Content-Type: image/jpeg'); imagejpeg($image); exit; } } ?> Similar TutorialsI have search the net and at the end tried 2 things that didn't solved the problem. It is known that certain browsers can refresh th epage 2 times without us knowing bacause it's doing it all by himself and so fast we don't even see it blink ! So I have following code for the normal sql-insert : Code: [Select] $Opdracht = "INSERT INTO tbl_link(userid,linkcat,linksubid,linklang,linkactive,linktitle) VALUES('$userid',1,0,'$lang',1,'$newML')"; it was inserted 2 times... I did some session check : at the top of the page : Code: [Select] session_start(); if(isset($_SESSION['itel'])){ $_SESSION['itel'] = $_SESSION['itel']+ 1; } else { $_SESSION['itel'] = 1; } echo "<br>session: ". $_SESSION['itel']; And it gave me number 2 ! This means the page was loaded 2 times, thus inserted 2 times. ! Than I tried : Code: [Select] $Opdracht = "INSERT INTO tbl_link(userid,linkcat,linksubid,linklang,linkactive,linktitle) VALUES('$userid',1,0,'$lang',1,'$newML') ON DUPLICATE KEY UPDATE linkid=LAST_INSERT_ID(linkid), linktitle='$linktitle'"; I got no error back but again 2 rows were created instead of 1... These are the fields in the table tbl_link : linkid userid linkcat linksubid linksuborder linklang linkactive linktitle articleid Unfortunately certain fields may be double in multiple rows, the only unique key is "linkid" and that's AUTO_INCREMENT. The only thing I can use is that userid and linktitle may NOT be reproduced 2 times (inserted) !!! Hi Guys, I'm having a problem with some file upload code I wrote and I was wondering if you could help me figure out why it's not working?? Here it is; Code: [Select] if($_POST['photo'] == "") $photo_update = "images/item_pictures/default_item.png"; else { if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 200000000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] ."<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; //Check image doesn't exist in first folder then uploads if doesn't. if (file_exists("images/item_pictures/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "images/item_pictures/" . $_FILES["file"]["name"]); echo "Stored in: " . "images/item_pictures/" . $_FILES["file"]["name"]; } //Check image doesn't exist in second*admin*folder then uploads if doesn't. if (file_exists("admin/images/item_pictures/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "admin/images/item_pictures/" . $_FILES["file"]["name"]); $photo_update = "admin/images/item_pictures/" . $_FILES["file"]["name"]; echo "Stored in: " . $uploaded_file; } } } else { echo "Invalid file"; } } Thanks in advance Jacbey I'm so sorry for this question but I not really know how to play with single and double quote. If I have a query like this: Code: [Select] mysql_query('UPDATE table SET Status=1,Sending=Done WHERE ID IN ('.implode(',', $done).')'); And I wish to add Code: [Select] SentAt='$date' in the query as well , and I try this: Code: [Select] mysql_query('UPDATE table SET Status=1,Sending=Done,SentAt='$date' WHERE ID IN ('.implode(',', $done).')'); Not working...how should I write it? Thank you. 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 a little problem with my email script that I can't figure out why it's doing this. The email gets sent but no from email address is in the email and no text. Here is the HTML code for the form. Code: [Select] <form id="facilitator" name="facilitator" method="post" action="http://www.mysite.com/emailf/email.php"> <table width="100%" border="0" align="center"> <tr> <td width="176"><div align="right"> <label for="email2">Email:</label> </div></td> <td width="167"><div align="left"> <input name="email" type="text" id="email" size="35" maxlength="80" /> </div></td> </tr> <tr> <td><div align="right"> <label for="name">Full Name:</label> </div></td> <td><div align="left"> <input name="name" type="text" id="name" size="35" maxlength="80" /> </div></td> </tr> <tr> <td><div align="right"> <label for="phone">Phone Number:</label> </div></td> <td><div align="left"> <input name="phone" type="text" id="phone" size="35" maxlength="14" /> </div></td> </tr> <tr> <td><div align="right"> <label for="comments">Comments:</label> </div></td> <td><div align="left"> <textarea name="comments" id="comments" cols="38" rows="5"></textarea> </div></td> </tr> <tr> <td><div align="right"></div></td> <td><div align="left"></div></td> </tr> <tr> <td><div align="right"> <label for="clear"></label> <input type="reset" name="clear" id="clear" value="Reset Form!" /> </div></td> <td><div align="left"> <label for="submit"></label> <input type="submit" name="submit" id="submit" value="Submit Email!" /> </div></td> </tr> <tr> <td colspan="2"><div align="right"></div> <div align="left"></div></td> </tr> </table> </form>This is the PHP code to send the email. Code: [Select] <?php /* Subject and Email Variables */ $emailSubject = 'Facilitor at Warfighter Tech!'; $webMaster = 'myemail@email.com'; /* Gathering Data Variables */ $emailField = $POST['email']; $nameField = $POST['name']; $phoneField = $POST['phone']; $commentsField = $POST['comments']; $body = <<<EOD <br><hr><br> Email: $email <br> Name: $name <br> Phone Number: $phone <br> Comments: $comments <br> EOD; $headers = "From: $email\r\n"; $headers .= "Content=type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<<EOD <html> <head> <title>Warfighter Tech Facilitor Job</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- body { background-color: #f1f1f1; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; line-height: normal; font-weight: normal; color: #666666; text-decoration: none; } --> </style> </head> <div> <div align="left">Thank you for your interest! Your email will be answered very soon!</div> </div> </body> </html> EOD; echo "$theResults"; ?> This is what I get in an email. I get the Subject but no return email address and this is whats in the email. <br><hr><br> Email: <br> Name: <br> Phone Number: <br> Comments: <br> Can anyone help me out? Thanks 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 no email arrives in the specified email account. Could someone please check over my code and see if there is something that I am missing? Its driving me mental! 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'])) { $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(); } 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"; $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 } ?> I'd be very grateful for any help! Hello, i am not good at php so need some help.I have a php page with check box from where i am trying to send mail to multiple recipient. i can send mail but with little problem. when i select eg. 3 check box to send email then 1st email recipient is ok but 2nd email goes with 1st and 2nd recipient and 3rd email goes 1st,2nd,3rd recipient. i guess having problem with 'foreach'. will someone pls help me to send individual email to individual recipient with my MySQL query's. Here is my code for mail.php page Code: [Select] <?php require_once('auth.php'); ?> <html> <head> <title>PHPMailer - SMTP basic test with authentication</title> </head> <body> <?php include("Connections/connection.php"); //error_reporting(E_ALL); error_reporting(E_STRICT); date_default_timezone_set('Europe/Dublin'); require_once('php_mailer/class.phpmailer.php'); //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $mail = new PHPMailer(); //$body = file_get_contents('contents.php'); //$body = eregi_replace("[\]",'',$body); $sender_name = $_SESSION['sender_name']; $sender_email = $_SESSION['sender_email']; $sender_password = $_SESSION['sender_password']; $id_user = $_POST["id_user"]; foreach ($id_tariff as $idt) { $query = sprintf("SELECT From_Date, To_Date, first, last, city, country, Email_1, Email_2, account_name FROM user_info where id_user = $id_user"); $result = mysql_query($query) or die(mysql_error()); $body = " <table width='100%' border='1' cellspacing='0' cellpadding='3' bordercolor='#ffcccc'> <tr> <th bgcolor='#cc3333'>From</th> <th bgcolor='#cc3333'>To</th> <th bgcolor='#cc3333'>First Name</th> <th bgcolor='#cc3333'>Last Name</th> <th bgcolor='#cc3333'>City</th> <th bgcolor='#cc3333'>country</th> </tr> "; while($row = mysql_fetch_array($result)){ $body .="<tr>"; $body .="<td>".$row['From_Date']."</td>"; $body .="<td bgcolor='#FFE8E8'>".$row['To_Date']."</td>"; $body .="<td>".$row['first']."</td>"; $body .="<td bgcolor='#FFE8E8'>".$row['last']."</td>"; $body .="<td>".$row['city']."</td>"; $body .="<td bgcolor='#FFE8E8'>".$row['country']."</td>"; $body .="</tr>"; $to1 = $row['Email_1']; $to2 = $row['Email_2']; $account_name = $row['account_name']; } $body .="</table>"; $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "smtp.gmail.com"; // SMTP server $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; $mail->Host = "smtp.gmail.com"; // sets the SMTP server $mail->Port = 465; // set the SMTP port for the GMAIL server $mail->Username = "$sender_email"; // SMTP account username $mail->Password = "$sender_password"; // SMTP account password $mail->SetFrom($sender_email,$sender_name); $mail->AddReplyTo("$sender_email","$sender_name"); $mail->Subject = "Hello Dear $account_name"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; $mail->MsgHTML($body); $mail->AddAddress($to1,$account_name); $mail->AddAddress($to2,$account_name); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "YOUR E-MAIL HAS SENT"; } } ?> </body> </html> Thanks in advance. Hello I have a problem with my html email - My code can send the email but i can't see the email on my yahoomail or gmail... Here is the code Code: [Select] <?php $to = 'slightbrand@gmail.com'; $subject = 'Test HTML Email'; $headers = "From: slightbrand@yahoo.com\r\n"; $headers .= "Reply-To: slightbrand@yahoo.com\r\n"; $headers .= "CC: slightbrand1@ymail.com\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message = '<html><body>'; $message .= '<table style="width:100%; border:none;">'; $message .= '<TR> <TD colspan="2"> Thanks for using Mobile Nets</TD> </TR>'; $message .= '<TR><TD style="width:80px;"><b>Name</b></TD><TD> Dummy </TD></TR>'; $message .= '<TR><TD style="width:80px;"><b>Age</b></TD><TD> 16 </TD></TR>'; $message .= '<TR><TD style="width:80px;"><b>Address</b></TD><TD> Address of me </TD></TR>'; $message .= '<TR><TD style="width:80px;"><b>Message</b></TD><TD> Test Email </TD></TR>'; $message .= '</table>'; $message .= '</body></html>'; if(mail($to, $subject, $message, $headers)){ echo "Email Sent"; }else{ echo "Error while trying to send the email"; } ?> Can someone tell me what the problem is? thanks Hi there, I've set up a basic password change that sends an email to the client when they change their password. The email notify's the client that their password has been changed and what the password is. The current problem I'm receiving is that when the user changes their password the message confirms that an email has been sent however, the email never arrives. The original email only arrives when the client changes their password again and they receive their first password change not their new password change. Can you help?? my code is below: Code: [Select] <?php $host="localhost"; // Host name $username="root"; // Mysql username $password="*******"; // Mysql password $db_name="testpwreset"; // Database name //Connect to server and select database. $con=mysql_connect("$host", "$username", "$password"); mysql_connect("$host", "$username", "$password") or die("cannot connect to server"); mysql_select_db("$db_name") or die("cannot select DB"); // value sent from form $email_to=$_POST['email_to']; $old_password=$_POST['old_password']; $new_password=$_POST['new_password']; $new_password2=$_POST['new_password2']; if ($new_password != $new_password2) {die("Your passwords do not match");} // table name $tbl_name=members; mysql_query("UPDATE $tbl_name SET password = '$new_password' WHERE email = '$email_to' AND password = '$old_password'"); // retrieve password from table where e-mail = $email_to(*****@gmail.com) $sql="SELECT password FROM $tbl_name WHERE email='$email_to' AND password = '$old_password'"; $result=mysql_query($sql); // if found this e-mail address, row must be 1 row // keep value in variable name "$count" $count=mysql_num_rows($result); // compare if $count =1 row if($count==1){ $asdf=mysql_query("UPDATE $tbl_name SET password = '$new_password' WHERE email = '$email_to' AND password = '$old_password'"); $rows=mysql_fetch_array($result); // keep password in $your_password $your_password=$rows['password']; // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to=$email_to; // Your subject $subject="Your Tafe FTP Password"; // From $header="from: your name \<your email\>"; // Your message $messages= "Your password for login to the Orange Tafe IT Ftp Server is: $your_password \r\n"; // send email $sentmail = mail($to,$subject,$messages,$header); } // else if $count not equal 1 else { echo "Cannot find your email in our database"; } // if your email succesfully sent if($sentmail){ echo "Your Password Has Been Sent To Your Email Address."; } else { echo "Cannot send password to your e-mail address"; } ?> 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 Can someone explain whats wrong with this code: if ($this->email != $this->confemail){ $this->errors[] = 'The email addresses you entered did not match!'; } I'm trying to make a "Confirm email" field by comparing "email" with "confemail" and if they are not the same you should get this message 'The email addresses you entered did not match!'. But instead i get this no matter what i type into the fields? I wrote a bunch of code just to realize that there's a huge security hole in my script. Here's a how I've built it: 1. first you enter the new email address into the input box and click submit 2. an email gets sent to you where you have to click on an activation link to confirm the change, and of course the email gets send to the inbox to make sure it's a valid email the activation link looks as follows: Code: [Select] http://localhost/changeemail_confirm.php?id=$dbuser_id&email=$user_email The dbuser_id gets taken from the session variable, and the user email is the new entered user email. 3. After clicking the link you get directed to an activation page, I thought about letting the user enter his password and letting it match with the password in the database as added security, so he can't just change the user_id in the link so that the email of another user gets changed. the query on the activation page looks like this: "UPDATE user SET email = '$user_email' WHERE nickname = '$dbuser_name' AND WHERE user_id = '$id'"; The $id is being taking from the activation link per GET, and the $dbuser_name is being taking from the session variable. And now this is the problem where I'm stuck, even though I've added a bunch of security, and even the necessary to enter a password there's still a major security hole, which is the user can easily change the email in the activation link to something else, something that is not a valid email. E.g. this Code: [Select] http://localhost/changeemail_confirm.php?id=35&email=mail@phpmail.local can become to this, when the user manually edits the url and pastes it into his browser: Code: [Select] http://localhost/changeemail_confirm.php?id=35&email=MAIL@ANYTHING.com How can I prevent this, is there any way I could tell the script the CONFIRMED and VALID email, with a more secure way? BTW this script works as it is, it's just that the user can manually change the email to something else what makes this script worthless for now. Hi, I am trying to send mail from my localhost but i am getting the below error ""Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in F:\test\xampp\htdocs\sendmail.php on line 42'" I am using xampp server. Can anyone please tell me what is the error My "php.ini" code is [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = smtp.gmail.com ; http://php.net/smtp-port smtp_port = 587 ; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from = xxxxxxxx@gmail.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path ;sendmail_path = "\"F:\test\xampp\sendmail\sendmail.exe\" -t" ; Force the addition of the specified parameters to be passed as extra parameters ; to the sendmail binary. These parameters will always replace the value of ; the 5th parameter to mail(), even in safe mode. ;mail.force_extra_parameters = ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename mail.add_x_header = Off ; Log all mail() calls including the full path of the script, line #, to address and headers ;mail.log = "F:\test\xampp\apache\logs\php_mail.log" Hi there guys, can any1 help me out to sort this thing. I'm using a simple php email script to send emails from online form (registration). Since i'm using unicode (cyrilic) font, i'm recieving an unreadable email from my php script. Here's the script (mailer.php): Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset="UTF-8" /> <title>Mecavnik</title> </head> <body> <!-- Reminder: Add the link for the 'next page' (at the bottom) --> <!-- Reminder: Change 'YourEmail' to Your real email --> <?php $ip = $_POST['ip']; $hp1 = $_POST['hp1']; $hp2 = $_POST['hp2']; $hp3 = $_POST['hp3']; $hp4 = $_POST['hp4']; $hp5 = $_POST['hp5']; $IP = $_POST['IP']; $hp6 = $_POST['hp6']; $hp7 = $_POST['hp7']; $hp8 = $_POST['hp8']; $hp9 = $_POST['hp9']; $hp10 = $_POST['hp10']; $hp11 = $_POST['hp11']; if (eregi('http:', $notes)) { die ("Ne ne! ! "); } if(!$hp8 == "" && (!strstr($hp8,"@") || !strstr($hp8,"."))) { echo "<h2>Error</h2>\n"; $badinput = "<h2>Error</h2>\n"; echo $badinput; die ("Error."); } if(empty($hp1) || empty($hp2) || empty($hp3) || empty($hp4) || empty($hp5) || empty($hp6) || empty($hp7) || empty($hp8 )) { echo "<h2>123</h2>\n"; die ("Error."); } $datum = date("l, F j, Y, g:i a") ; $subject = "Custom subject"; $message = "Firma: $hp1 \n Ime: $hp2 \n Prezime: $hp3 \n Email: $hp8 \n Telefon: $hp4 \n Konfekcijski broj: $hp5 \n Spavanje: $hp6 \n Prevoz: $hp7 \n "; $from = "From: $hp8 \n"; mail("evlj@something.bla", $subject, $message, $from); ?> <?php header( 'Location: http://blabla/123/123.html' ) ; ?> </p> </body> </html> Email that i have previously recieved: Code: [Select] Firma: Тестирам Ime: Упишите Ваше име Prezime: Упишите Ваше презиме Thanks in advance 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! Hi FYI I'm a n00b in this particular forum & php n00b really but I'm having a problem & cant find a solution anywhere! I need to be able to send an email from a form. Within the form is a dropdown field for different regions. When a region is selected it sets the email address for that region into an input/text field. I need to pickup that value and send the email to that address but not sure how. Have been told to use echo$email & that perhaps my variable is empty but I haven't got a clue where to put it or what that means. Help please?! my code: include ('maketable.php'); include ('mailbot.php'); include ('auditFile.php'); $office = $_REQUEST["office"]; $callername = $_REQUEST["callername"]; $callerphone = $_REQUEST["callerphone"]; $callaction = $_REQUEST["callaction"]; $callerInfo = "Callers Name=".$callername; $commentInfo = "Callers Phone No=".$callerphone; $callDetail = "Action Taken=".$callaction; $title = "DOC Call Results"; $stylesheet = "stylesheet.css"; $logo = "tcclogo.jpg"; $display = makeHeader($title,$stylesheet,$logo); $display .= makeTable("Caller Details",$callerInfo,1); $display .= makeTable("",$commentInfo,1); $display .= makeTable("",$callDetail,1); $display .= '</body></html>'; $info = $callerInfo."; ".$commentInfo."; ".$callDetail; auditFile($title, $info); echo $email; mailbot($title,$display,"email","info@tcc.co.nz","ThankYou.html"); hi guys I have two functions and they work well, but now i have a problem in the last if the email is sent like www.yoursite.com/reset_password.php?userid=0&code= and not http://your.url/set_new_password.php?userid=564979&code=54c4a2767c2f485185ab72cdcf03ab59 so, the problem is that i can get the value of hash and the userid. If i do an echo "$hash" in the function code(); it shows the value like 564979&code=54c4a2767c2f485185ab72cdcf03ab59 my question is, how i can do the same in the last if? above two functions. Same occur in the last select select userid from password_reset where code=? none userid is showed, it is always zero. Code: [Select] <? function check($sql, $db, $email) { if(!empty($_POST['email'])) { $email = $_POST["email"]; if ($sql = $db->prepare("select email from users where email=?")) { $sql->bind_param('s', $email); $sql->execute(); $sql->bind_result($email); if ($sql->fetch()) { return true; } else { return false; } } } } function code($sql, $db, $hash, $pwdHasher, $userExists, $sendPass) { if (check($sql, $db, $email)) { $pwdHasher = new PasswordHash(8, FALSE); $hash = $pwdHasher->HashPassword($userExists["email"]); $sendPass=$hash; ($sql = $db->prepare('insert into password_reset (code) values (?)')); $sql->bind_param('s', $hash); $sql->execute(); $sql->fetch(); return true; } } if (code($sql, $db, $hash, $pwdHasher, $userExists, $sendPass)) { ($sql = $db->prepare("select userid from password_reset where code=?")); $sql->bind_param('s', $hash); $sql->execute(); $sql->bind_result($hash); $sql->fetch(); echo $hash; $pwrurl = "www.yoursite.com/reset_password.php?userid=" .$hash . "&code=" . $sendPass; $mailbody = "Dear user,<br><br>If this e-mail does not apply to you please ignore it. It appears that you have requested a password reset at our website www.yoursitehere.com<br> To reset your password, please click the link below. If you cannot click it, please paste it into your web browser's address bar.<br> <a href='$pwrurl'>$pwrurl</a> <br> <br> Thanks,\nThe Administration"; $mail->MsgHTML($mailbody); $mail->AddAddress($email,"Membro"); $mail->IsHTML(true); if(!$mail->Send()) { echo "Deu erro: " . $mail->ErrorInfo; } else { echo "Enviado com sucesso"; } $sql->close(); $db->close(); } ?> any help? thanks Hey guys im having a problem with emailing a link using local host mail. I'm using out look express with Mercury. I shorten the email below as much as possible. Its really wierd the target for the link is correct but clicking on it gives me this res ieframe.dll res://ieframe.dll/syntax.htm#http//localhost/stargate/users/account_settings.php? npd=82b1e0df295ee681f1fa2f213ade823d $to = $_POST['resendemail']; $from = "stargate@localhost.com"; $subject = "Stargate System Lords Password Recovery"; $message = "<html> <body background=\"#4B4B4B\"> <h1>Stargate System Lords Password Recovery</h1> Dear ".$users1['name'].", <br> <center> <a href="localhost/stargate/users/account_settings.php?npd=$new_password ">Log In</a> <p> <br /> </font> </body> </html>"; $headers = "From: Stargate Game Password Recovery <stargate@localhost.com>\r\n"; $headers .= "Content-type: text/html\r\n"; mail($to, $subject, $message, $headers); Hello all, I used simple php email function but it send an email in junk folder or spam. Can anyone tell me why is this so? Her is the code: $host = "ssl://smtp.gmail.com"; $port = "465"; $to = " xx@gmail.com"; // note the comma $subject = " $_POST[company_website] "; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: About Wholesale Account' . "<$_POST[email]>\r\n"; $headers .= 'Cc: mail@gmail.com' . "\r\n"; $headers .= 'Bcc: cc@gmail.com' . "\r\n"; mail($to, $subject, $message, $headers); 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); |