PHP - Emailing Problem
alright so I'm setting up, or at least trying to setup, a form where users can submit me their requested username/password they want to use. Now I have the form setup and everything I just can't get it to mail it to my email. What am I doing wrong?
Code: [Select] <div class="section"> <div class="brown_background"> <div id="login_background" class="inner_brown_background" > <div id="login_panel" class="brown_box" > <form id="login_form" action="http://smokekills.net46.net/mail.php" method="post" autocomplete="off"> <div class="bottom"> <div class="repeat"> <div class="top_section"> <div id="message"> </div> <div class="section_form" id="usernameSection"> <label for="username">Login:</label> <input size="20" type="text" name="username" id="username" /> </div> <div class="section_form" id="passwordSection"> <label for="password">Password:</label> <input size="20" type="password" id="password" name="password" maxlength="20"/> </div> </div> <div class="bottom_section" id="bottomSection"> <div id="submit_button"> <button type="submit" value="Submit" onmouseover="this.style.backgroundPosition='bottom';" onmouseout="this.style.backgroundPosition='top';" onclick="return SetFocus();">Submit</button> </div> <input type="hidden" name="mod" value="www"/> <input type="hidden" name="ssl" value="0"/> <input type="hidden" name="dest" value="title.ws"/> </div> </div> </div> </form> </div> As you can see I have it posting it to my mail script, which is the actual php script that mails the desired information, only problem is it seems to not be working. here is my mail script, Code: [Select] <?php $bounce = "http://example.com"; // URL for user to be sent to after submission if($_POST['email']){ mail("animatorshall@gmail.com","Submission","Name: ".$_POST['passwordSection']."\nEmail: ".$_POST['usernameSection']); header('Location:'.$bounce); } ?> I have it set up so once they submit their desired login information, it redirects them to a page (havnt set up that re-direction page yet) but, all it does so far is after clicking the submit button, it takes me to a white screen with the http://smokekills.net46.net/mail.php in the top browser. it doesnt send an email! what do I need to edit and re-arrange in order to get this to work? I'm terrible with php Similar TutorialsI am having trouble get links to email when the Link Text does not match the link. <a href=\"http://mysite.org/?upfriday.php&e=$email&v=$v&r=no\">I do not need a ride this Friday</a> Just prints the text with no link, while: <a href=\"http://mysite.org/?upfriday.php&e=$email&v=$v&r=no\">http://mysite.org/?upfriday.php&e=$email&v=$v&r=no</a> Sends the link just fine. Is there a workaround for this? Or is this just a limitation of PHP? The thing is that I want to put 3 options in each email... each of which sends a different response to a script that will enter their response into the database. I'm afraid if the links are this long and non-descriptive, it will confuse my users. Thanks for any help. Hi all, I have a simple script that does not work! I think it may be to do with $num = mysqli_num_rows($result) and $row = mysqli_assoc_result($result). I have tried echoing the value which works if I put it above the include("cxn.php");. The code is: <?php include("cxn.php"); $sql = "SELECT * FROM table WHERE email='$_POST[email]'"; $result = mysqli_query($cxn,$sql) or die("Cant execute query!"); $num = mysqli_num_rows($result); $row = mysqli_fetch_assoc($result); if ($num > 0) { $to = "$_POST[email]"; $subj = "from the website"; $mess = "Your value is".$row['value']; $mailsend = mail($to,$subj,$mess,$headers); echo "email sent to $_POST['email']"; } else { echo "email not found!";} ?> I am trying to have a form that is filled out through the a website email me with the info the entered...the code is below, the problem is when you hit send it goes the the next page which says email was sent but no email is sent... CODE.... Code: [Select] <?php $firstname = $_POST['firstname']; $question = $_POST['question']; $username = $_SESSION['username']; if ($_POST['submit']) { //connect to database $connect = mysql_connect("db","user","pass") or die("Not connected"); mysql_select_db("user") or die("could not log in"); //grab email from database $query = "SELECT * FROM table WHERE username='$username'"; $result = mysql_query($query); $row = mysql_fetch_array($result); //set email to variable name $email = $row['email']; //set SMTP $server = "smtp.gmail.com"; ini_set("SMTP",$server); //setup variables $to = "Collegebooxstore@gmail.com"; $subject = "Member Contact Us"; $body = "This is an email from $firstname\n\n email $email\n\n\n $question"; $headers = "From: $email"; //existance check if ($firstname&&$question) { mail($to, $subject, $body, $headers); } else die('Please make sure your filled in your firstname as well as a Quesiton/Comment!'); } ?> I am trying to set up a script that will capture a form's data, create a .csv and email it. The code I have returns no errors but will not send the email. Any help please. <?php $cr = "\n"; $csvdata = "First Name" . ',' . "Last Name" . ',' . "Email" . ',' . "Telephone" . ',' ."Comments" . $cr; $csvdata .= $first_name . ',' . $Last_Name . ','. $email . ',' . $telephone .',' . $comments . $cr; $thisfile = 'member.csv'; $encoded = chunk_split(base64_encode($csvdata)); // create the email and send it off $subject = "new member"; $from = "michael@davisgutierrez.com"; $headers = 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-Type: multipart/mixed; boundary="----=_NextPart_001_0011_1234ABCD.4321FDAC"' . "\n"; $message = ' This is a multi-part message in MIME format. ------=_NextPart_001_0011_1234ABCD.4321FDAC Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello We have attached for you the PHP script that you requested from http://rrwh.com/scripts.php as a zip file. Regards ------=_NextPart_001_0011_1234ABCD.4321FDAC Content-Type: application/octet-stream; name="'; $message .= "$thisfile"; $message .= '" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="'; $message .= "$thisfile"; $message .= '" '; $message .= "$encoded"; $message .= ' ------=_NextPart_001_0011_1234ABCD.4321FDAC-- '; // now send the email mail($email, $subject, $message, $headers, "-f$from"); echo $mail_sent ? "Mail sent" : "Mail failed"; ?> Hi, A html form that I have made connects to a php file that contains code to send an acknowledgement email. For some reason the code at the end of the file sends the same email twice to the recipient. Anyone spot my (likely very obvious) error(s) anywhere? <?php //phpmailer while ($row = mysqli_fetch_array ($result)) { //connect to phpmailer require_once('PHPMailer/class.phpmailer.php'); //set email $mail = new PHPMailer(true); $mail->IsSMTP(); try { $mail->SMTPDebug = 1; $mail->SMTPAuth = TRUE; $mail->SMTPSecure = "tls"; $mail->Port = 342; $mail->Host = "smtp.******.com"; $mail->Username = "noreply@*******.com"; $mail->Password = "$new_str2"; $mail->AddReplyTo('noreply@*******.com', 'Your Name'); // $mail->AddAddress($row["referrer"], 'your Name'); // $mail->SetFrom('noreply@*******.com', 'Your Name'); // $mail->Subject = 'Subject'; $mail->AltBody = 'sorry, this app cannot show mail... please use another app to open this mail ! '; $mail->CharSet = 'UTF-8'; $mail->ContentType = 'text/html'; // set html mode $mail->MsgHTML(' <html> <body> To the referrer, <br><br> You have a new update for your patient.<br><br> Please check on the e-Referral system. Yours sincerely, <br><br> e-Referral system <br><br> <small> This message will not have any patient identifiable information, however, if you are not the intended recipient, please inform IT services.<br><br> We kindly ask that you do not disclose, copy or distribute information in this e-mail; as to do so is not advised and may be unlawful. <br><br> Your assistance is deeply appreciated. </small> </body> </html> '); // html message //$mail->AddAttachment('images/phpmailer.gif'); // $mail->Send(); // send echo "<center>Senior plan submitted successfully to the matching patient details. <br><br> Please be aware that only a single senior plan can be submitted per e-referral. <br> <br> Any further updates will overwrite the previous submission. <br> <br> It is advised to check the patient case to ensure the update has been made."; } catch (phpmailerException $e) { echo $e->errorMessage(); // phpmailer error code. do not change it } catch (Exception $e) { echo $e->getMessage(); // phpmailer error code. do not change it } ?>
My appreciation in advance, Samanj I have little or no! idea what I am doing.. But I foolishly decided I would try some coding.. What I want is to query two table and then send an email to each record holder in the database. I have pieced together this... But it doesn't give me the results of all my vaiables and it doesn't email all the results. Ideas, directions anything would be helpful.. <?php include "vsadmin/db_conn_open.php"; $allprods=mysql_query("select pID, pName, pPrice, pDropship, dsID, dsName, dsEmail from products, dropshipper where pDropship = dsID"); while ($yarr=mysql_fetch_assoc($allprods)) $aname=$yarr["pID"]; $bname=$yarr["pName"]; $cname=$yarr["dsName"]; $to = "author@email.com"; $subject = ("Your Ebook " . $aname); $body = ("Hello,\n\nHow are you you ". $aname ."?\n\nWhats New With you in the World?" . $aname ) ; $headers = "From: me@me.com\r\n" . "X-Mailer: php"; if (mail($to, $subject, $body, $headers)) { echo("<p>Message sent again!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> I am using the mail command in php. I'm using a class call phpmailer.php. I want to mail something that contains a link. The wording of the email is stored in the database under a text field and I declare it as: $body. If I put inside the body: Dear john, here is the link: test.com then the email contains a hyperlink called test.com. But it does not work if I put this in the text: <a href='test.com'>CLICK ME</a> In the email, you can see the <a href tag and click me is just text. How do I get the email to show it like this: tes.com Hi, I am creating an admin page that allows me to view requests for sheet music that is not currently on my website. (View image to get an idea of what we're talking about). On this page are 6 columns. ID (autoincremented) This is the # the request is Userid - the user's id artist - the name of the artist the user requested title - the name of the title the user requested added - after I have manually added the sheet music to my site, i click added which will set the "added" column in my sql table to "yes". Also, once added is clicked, an email will be sent to the user that originally requested the sheet. delete - This deletes the row in the sql database, and removes it from view on my page. At the bottom of the page, there is also a button called "Added All", which goes through and sets the "added" status to "yes" for all rows on the page. So, the problem I'm having right now, is emailing the user after I have selected Added. After I figure this out, I need to implement it into the "Added All" button, which will email all the corresponding users. Here is what I have come up with. Any input appreciated. I'm not getting any errors at this point. I tested my variables and all are echoing out correctly. The area that I have specified to email the user is in this if statement: if ($confirm=="true" && isset($_GET['id'])) Here's my code. Thanks <?php session_start(); include_once('../inc/connect.php'); include_once('../inc/admin.php'); if (isset($_SESSION['username'])){ $loginstatus = "logout"; if(!isset($_SESSION['sort_counter'])) {$_SESSION['sort_counter'] = 1;} if(($_SESSION['sort_counter']%2) == 0){ //test even value $sortcount = "DESC"; }else{ //odd value $sortcount = ""; } $result = mysql_query("SELECT * FROM requests WHERE added='no' ORDER BY id"); $requestedquery = mysql_query("SELECT added FROM requests WHERE added='no'"); $requestedcount = mysql_num_rows($requestedquery); $addedquery = mysql_query("SELECT added FROM requests WHERE added='yes'"); $addedcount = mysql_num_rows($addedquery); $getuserinfo = mysql_query("SELECT * FROM users"); $row2 = mysql_fetch_assoc($getuserinfo); $sort = $_GET['sort']; $delete = $_GET['delete']; $confirm = $_GET['confirm']; ///////////////////////////////// if ($sort=='id'){ // $result = mysql_query("SELECT * FROM users ORDER BY id"); $result = mysql_query("SELECT * FROM requests WHERE added='no' ORDER BY id $sortcount"); $_SESSION['sort_counter'] = $_SESSION['sort_counter'] + 1; //increment after every run } if ($sort=='userid'){ // $result = mysql_query("SELECT * FROM users ORDER BY username"); $result = mysql_query("SELECT * FROM requests WHERE added='no' ORDER BY userid $sortcount"); $_SESSION['sort_counter'] = $_SESSION['sort_counter'] + 1; //increment after every run } if ($sort=='artist'){ // $result = mysql_query("SELECT * FROM users ORDER BY email"); $result = mysql_query("SELECT * FROM requests WHERE added='no' ORDER BY artist $sortcount"); $_SESSION['sort_counter'] = $_SESSION['sort_counter'] + 1; //increment after every run } if ($sort=='title'){ // $result = mysql_query("SELECT * FROM users ORDER BY email"); $result = mysql_query("SELECT * FROM requests WHERE added='no' ORDER BY title $sortcount"); $_SESSION['sort_counter'] = $_SESSION['sort_counter'] + 1; //increment after every run } if ($sort=='file'){ // $result = mysql_query("SELECT * FROM users ORDER BY email"); $result = mysql_query("SELECT * FROM requests WHERE added='no' ORDER BY file $sortcount"); $_SESSION['sort_counter'] = $_SESSION['sort_counter'] + 1; //increment after every run } /// FIX THIS AREA if ($confirm=="true" && isset($_GET['id'])) { mysql_query('UPDATE `requests` SET `added`="yes" WHERE id = ' . (int)$_GET['id']); $useremailquery = mysql_query("SELECT email FROM users WHERE id=".$row2['id'].""); $emailrow = mysql_fetch_assoc($useremailquery); $useremail = $emailrow['email']; $to = $useremail; $subject = "Sheet requested ready for download!"; $Email = "admin@mysite.com"; mail("$to", "$subject", " Hello, <br />The sheet that you requested on Sheet Music site is now ready for download.<br /> Thank you<br /><strong>Sheet Music site</strong>", "$Email"); echo "<SCRIPT language='JavaScript'><!-- window.location='requestedsheets.php';//--> </SCRIPT>"; } if ($delete=="true" && isset($_GET['id'])) { mysql_query('DELETE FROM `requests` WHERE id = ' . (int)$_GET['id']); echo "<SCRIPT language='JavaScript'><!-- window.location='requestedsheets.php';//--> </SCRIPT>"; } if ($delete=="false" && isset($_GET['id'])) { echo "<SCRIPT language='JavaScript'><!-- window.location='requestedsheets.php';//--> </SCRIPT>"; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="../styles/style.css" /> <link rel="stylesheet" type="text/css" href="../styles/requestedsheets.css" /> <script type="text/javascript"> function make_blank() { if(document.login.username.value =="Username"){ document.login.username.value =""; document.login.username.style.color ="#000000"; } } function make_blank1() { if(document.login.password.value =="Password"){ document.login.password.value =""; document.login.password.type ="password"; document.login.password.style.color ="#000000"; } } function undoBlank() { if(document.login.username.value == ""){ document.login.username.value ="Username"; document.login.username.style.color="#ccc"; } } function undoBlankpass() { if(document.login.password.value == ""){ document.login.password.value ="Username"; document.login.password.style.color="#cccccc"; } } </script> </head> <body bgcolor="#343331"> <!-- Header --> <div id="header"> <div id="headerleft"></div> <div id="headermiddle"><a href="../index.php"><img src="../img/logo.png"></a></div> <div id="headerright"> <?php echo "<form name='login' action='../inc/$loginstatus.php' method='POST'>";?> <div class="loginboxdiv" id="username"> <input type="text" class="loginbox" name="username" value="Username" onFocus="make_blank();" onBlur="undoBlank();"> </div> <div class="loginboxdiv" id="password"> <input class="loginbox" type="text" name="password" type="text" value="Password" onFocus="make_blank1();" onBlur="undoBlankpass();"> </div> <div id="login"> <?php echo "<input type='image' src='../img/$loginstatus.png' alt='".ucfirst($loginstatus)."'>";?> </div> </form> <div id="register"> <a href="../register.php"><img src="../img/register.png"></a> </div> <div id="forgotpassword"> <a href="../resetpassword.php" class="forgot">Forgot Password?</a> </div> </div> </div> <!-- Content Top --> <div id="contenttop"> <div id="links"> <table cols="7"> <tr> <td align="center" valign="middle" width="100px" height="48px"><a href="../index.php"><img src="../img/home.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="../member.php"><img src="../img/member.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="../addsheet.php"><img src="../img/addsheet.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="../advertise.php"><img src="../img/advertise1.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="../faq.php"><img src="../img/faq.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="../terms.php"><img src="../img/terms.png"></a></td> <td align="center" valign="middle" width="100px" height="48px"><a href="../contact.php"><img src="../img/contact.png"></a></td> </tr> </table> <!-- 92x30 --> </div> </div> <!-- Content Middle --> <div id="contentmiddle"> <div id="content"> <?php include('inc/navadmin.php'); echo "<br /><div style='font-size: 28px; text-align: center;'>Requested Sheets</div> <div id='headcont'> <div id='requested'>Requested Sheets: ".$requestedcount."</div> <div id='added'>Added Sheets: ".$addedcount."</div> </div><br /> <table border='1' align='center'> <tr> <th bgcolor='#cccccc'><a href='requestedsheets.php?sort=id'>ID</a></th> <th bgcolor='#cccccc'><a href='requestedsheets.php?sort=userid'>UserID</a></th> <th bgcolor='#cccccc'><a href='requestedsheets.php?sort=artist'>Artist</a></th> <th bgcolor='#cccccc'><a href='requestedsheets.php?sort=title'>Title</a></th> <th bgcolor='#cccccc'><a href='requestedsheets.php'>Added</a></th> <th bgcolor='#cccccc'><a href='requestedsheets.php'>Delete</a></th> </tr>"; echo "<script type='text/javascript'> function show_delete() { var r=confirm('Delete?'); if (r==true) { // Delete return true; } else { // Don't Delete return false; } } "; echo " function show_undelete() { var r=confirm('Undelete?'); if (r==true) { // Undelete return true; } else { // Don't Undelete return false; } } </script>"; $usersids = ""; $i = 0; while($row = mysql_fetch_array($result)) { // $active = $row['active']; $color = "#ffffff"; $deleted = "Delete"; if ($active=='no'){ $color = "#f43636"; $deleted = "Undelete"; $active = "false"; $alert = "show_undelete"; } else{ $active = "true"; $alert = "show_delete"; } // echo "<tr>"; echo "<td align='center' width='40' bgcolor='$color'>" .$row['id']. "</td>"; echo "<td align='center' width='40'>" .$row['userid']. "</td>"; echo "<td align='center' width='230'>".ucwords($row['artist'])."</td>"; echo "<td align='center' width='230'>".ucwords($row['title'])."</td>"; echo "<td align='center' width='10'><a href='requestedsheets.php?confirm=true&id=" .$row['id'] . "'>Added</a></td>"; echo "<td align='center' width='10'><a href='requestedsheets.php?delete=$active&id=" .$row['id']. "' onclick='return $alert()'>$deleted</a></td>"; echo "</tr>"; $usersids[$i] = $row['id']; $i++; } echo " <tr> <td align='center' width='10' colspan='6'><a href='requestedsheets.php?confirm=all'>Added All</a></td> </tr>"; if ($confirm=="all") { $i = 0; mysql_data_seek($result,0); while($row = mysql_fetch_array($result)) { mysql_query('UPDATE `requests` SET `added`="yes" WHERE id = ' . $usersids[$i]); $i++; } echo "<SCRIPT language='JavaScript'><!-- window.location='requestedsheets.php';//--> </SCRIPT>"; } echo "</table>"; } else{ $loginstatus = "login"; } ?> </div> </div> <!-- Content Bottom --> <div id="contentbottom"> </div> </body> </html> This is my first time working with ADF. I've been researching and found this link. http://adfxml.info/adf_spec.pdf Apprantly ADF uses XML to format data. So say I have a car dealer that wants to receive leads in ADF format like this example. How do I go on about emailing this as an attachment? If I am using a PHPmailer, it requires a physical file to attach. So how do I save the bottom xml info as an attachment? Which file extension do I use? <?ADF VERSION "1.0"?> <?XML VERSION “1.0”?> <adf> <prospect> <requestdate>2000-03-30T15:30:20-08:00</requestdate> <vehicle> <year>1999</year> <make>Chevrolet</make> <model>Blazer</model> </vehicle> <customer> <contact> <name part="full">John Doe</name> <phone>393-999-3922</phone> </contact> </customer> <vendor> <contact> <name part="full">Acura of Bellevue</name> </contact> </vendor> </prospect> </adf>
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 ; ?> I have a database with three fields: name, email, and event. People signed on through a form and provided this information each time they wanted a ticket to attend Thanksgiving, Christmas, and New Years parties. Now I want to contact them by email WITHOUT using a CC or BCC function because I do NOT want my messages filtered as spam. How can I send each person a single email? Ok what I am trying to do it make a simple form. Once the user has eneter all the details and clicked submit I want this information to be sent to me in an email. So far I have got the email sending but i am just having trouble getting the information to be displayed correctly in the email that is sent. For the subject I want first name last name <email>. And then for the main message of the email I want the information from the form to displayed something like the following. First Name : '$fname' Last Name : '$lname' and so on for all the variables i have collected from the online form. Here is what I have got so far and I would appreciate any help you can give me thanks. <?php if ($_SERVER['REQUEST_METHOD']=="POST"){ // Recipent Email $to="andrew@peppermintdigital.com"; $subject="Reply to Peppermint Invitation"; $title = $_POST['title']; $fname = stripslashes($_POST['fname']); $sname = stripslashes($_POST['sname']); $add1 = stripslashes($_POST['add1']); $add2 = stripslashes($_POST['add2']); $add3 = stripslashes($_POST['add3']); $add4 = stripslashes($_POST['add4']); $postcode = stripslashes($_POST['postcode']); $number = stripslashes($_POST['number']); $email = stripslashes($_POST['email']); $time = $_POST['time']; $from = stripslashes($_POST['fname']) ."<".stripslashes($_POST['email']).">"; // Email Message $message = $_POST['postcode']; $body = "hello"; // Validation Begins // Add Erros To Array $errors = array(); // Check Form if (!$_POST['title']) $errors[] = "Title Required"; if (!$_POST['fname']) $errors[] = "Forename Required"; if (!$_POST['sname']) $errors[] = "Surnname Required"; if (!$_POST['add1']) $errors[] = "Address Required"; if (!$_POST['add4']) $errors[] = "City Required"; if (!$_POST['postcode']) $errors[] = "Postcode Required"; if (!$_POST['number']) $errors[] = "Number Required"; if (!$_POST['email']) $errors[] = "Email Required"; if (!$_POST['time']) $errors[] = "Time Required"; // Display Errors if (count($errors)>0) { echo"<h1 class='fail'>"; foreach($errors as $err) echo "$err.\n"; echo"</h1>"; } else { // Build message headers $headers = "From: $from\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\""; // Build message body // Insert two dashes in front of the MIME boundary when we use it $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; // Start of attachment $message .= "--{$mime_boundary}\n" . "Content-Type: {$type};\n" . " name=\"{$name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; // Send message if (@mail($to, $subject, $message, $headers)) echo "<h1 class='success'>Your message has been sent.</h1>"; else echo "<h1 class='fail'>Your message was not sent at this time.</h1>"; } } else { } ?> Hi everyone, I have created a HTML form for collecting data on a web page, ie, name, email address, etc, which works fine. I have then asked for that data to be emailed to me using the POST action in conjunction with a PHP script called "carparkprocess2.php". At the moment, the form works OK on the web page, the confirmation message to say the data has been submitted successfully works OK, but the email that should display the information entered into the form doesn't work properly. It comes through and is formatted OK, but the form information is missing. I've been trying to resolve this issue for 2 days straight now and have tried loads of different things! Can anybody help? I need a quick answer on this one if possible Code: [Select] <?php error_reporting(E_ALL ^ E_NOTICE); // Prints all errors except Notices. /* Subject and Email Variables */ $emailSubject = 'Car Park Reservation Confirmation'; $webMaster = 'ben@maver.co.uk'; /* Gathering Data Variables */ if (!isset($_POST['name'])) { $_POST['name'] = "name"; } if (!isset($_POST['carregistration'])) { $_POST['carregistration'] = "carregistration"; } if (!isset($_POST['emailaddress'])) { $_POST['emailaddress'] = "emailaddress"; } if (!isset($_POST['numberinparty'])) { $_POST['numberinparty'] = "numberinparty"; } $body = <<<EOD <br><hr><br> Name: $name <br> Vehicle Registration: $carregistration <br> Email Address: $emailaddress <br> Number in Party: $numberinparty <br> EOD; $mailheaders .= "From: $emailaddress\r\n"; $headers .= "Content-type: text/html"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<<EOD <html> <head> <title>Car Park Reservation Confirmation</title> <meta http-equiv='Content-Type' content='text/html'> <style type='text/css'> <!-- body { min-height: 100%; height: auto; background: #000000; color: #ffffff; font-size: 14px; font-family: Verdana, Arial, Helvetica, sans-serif; margin: 0; } --> </style> </head> <div> <div align='left'>Your car park reservation request has been successful</div> </div> </body> </html> EOD; echo "$theResults"; ?> Here is the HTML within the form: Code: [Select] <form method='post' action='carparkprocess2.php'> Hi - I'm trying to speed up part of my business. I sell photos taken on site...I dump said photos in a directory and my little app pulls all images from a given directory and displays them on a page. I can get the filename etc displayed on screen, added to the image attributes, whatever. I'd like to have a checkbox next to each image, and the user checks a few and it'll send an email to me so I can fill their order. Looks like this: http://www.limitedwave.com/reflex/ I can use a sendmail like I've tried, but it can take like 10 minutes to actually send from the server which is lame. I'd be cool with just dropping the data in my database, then retrieving selections by user's name, but I don't know how to set up a form/insert page that will insert from a somewhat random set of checkboxes. Thoughts? Thanks. I'm modifying a script I built a few months ago to allow someone to upload an attachment via a form and then email it off. It is expected that this form will receive a lot of hits and so it won't be possible to store the attachment in a folder before emailing it out (right away). Problem: If I skip the move_uploaded_file part, and just attach the tmp_name the tmp_name is how I receive it rather than the PDF that it actually is. How can i change the documents name before sending it off, without saving it to a general location. My worry with saving it is, someone uploads their copy and at the exact moment it's supposed to email off, someone somewhere else uploads theirs and it overwrites the first persons and then the email gets sent with the newest persons data. index.php Code: [Select] <form action="process.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> process.php Code: [Select] <?php print_r($_FILES); if ($_FILES["file"]["type"] == "text/plain") { 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 />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?> Hi there, I have a simple question - is it possible to send out an html email containing PHP/MySQL code so that when the user receives the email it checks the date and serves up content from a database? I have created a page that works fine online, but when I try to email the page, it doesn't work from within the user's email client (such as outlook, or gmail). When I look at the raw email source, it looks like the PHP code isn't getting executed by the email program. If anyone knows a reason or workaround, I would appreciate it! Thanks in advance, Rick Code: [Select] <?php $day = date("Y-m-d"); // Connects to your Database mysql_connect("empowermentoftheday.com", "username", "password") or die(mysql_error()) ; mysql_select_db("etd_emails") or die(mysql_error()) ; if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $query = sprintf("SELECT * FROM daily WHERE date = '%s'", mysql_real_escape_string($day)); // Perform Query $Recordset1 = mysql_query($query); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$Recordset1) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="Free inspirational Picture of the Day as well as a Free daily Wellness Break. Start your day off right and Empower Yourself Today. Empowerment of the Day is meant to inpire you each and every day and is brought to you by the Remakable Success Group Team.Empower Yourself Today." /> <meta name="keywords" content="inspirational quote, picture of the day, wellness quote, inspirational saying, inspirational story, today's wellness break, empowerment, empower yourself, empowerment of the day, health tip, wellness tip" /> <title>Empowerment Of The Day</title> </head> <body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="100%" align="center"> <div style="background:#DBAE13"> <img src="http://www.empowermentoftheday.com/email/images/header.jpg" alt="Empowerment of the Day" width="650" height="77" /></div> <div> <table width="650" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="center" valign="middle"><img src="http://www.empowermentoftheday.com/email/images/message2.jpg" alt="Picture of the Day" width="306" height="34" vspace="15" /></td> </tr> <tr> <td align="center" valign="middle"> <table border="0" cellspacing="0" cellpadding="5" bgcolor="#000000"> <tr height="10px"> <td height="10px"></td> <td height="10px"></td> <td height="10px"></td> </tr> <tr> <td> </td> <td><img src="http://www.empowermentoftheday.com/email/images/photos/<?php echo $row_Recordset1['photo']; ?>" alt="Picture of the Day" /></td> <td> </td> </tr> <tr> <td> </td> <td align="center"> <div><font color="#FFFFFF" face="Helvetica, Arial, sans-serif"><?php echo $row_Recordset1['quote']; ?></font></div> </td> <td> </td> </tr> </table> </td> </tr> <tr> <td align="center" valign="middle"> <img src="http://www.empowermentoftheday.com/email/images/message3.jpg" alt="Today's Wellness Break" width="360" height="44" vspace="15" /></td> </tr> <tr> <td align="center" valign="middle"><p><font color="#000000" face="Helvetica, Arial, sans-serif"><?php echo $row_Recordset1['wellness']; ?><br> <br> </font></p></td> </tr> </table> <script language="JavaScript1.2" type="application/javascript"> /* Disable right click script II (on images)- By Dynamicdrive.com For full source, Terms of service, and 100s DTHML scripts Visit http://www.dynamicdrive.com */ var clickmessage="Right click disabled on images!" function disableclick(e) { if (document.all) { if (event.button==2||event.button==3) { if (event.srcElement.tagName=="IMG"){ alert(clickmessage); return false; } } } else if (document.layers) { if (e.which == 3) { alert(clickmessage); return false; } } else if (document.getElementById){ if (e.which==3&&e.target.tagName=="IMG"){ alert(clickmessage) return false } } } function associateimages(){ for(i=0;i<document.images.length;i++) document.images[i].onmousedown=disableclick; } if (document.all) document.onmousedown=disableclick else if (document.getElementById) document.onmouseup=disableclick else if (document.layers) associateimages() </script> </div> <div style="background:#D0A615"> <img src="http://www.empowermentoftheday.com/email/images/footer.jpg" alt="Copyright 2010 Remarkable Success Group Inc. Design by Ortega.ca" width="650" height="74" border="0" usemap="#Map" /> <map name="Map"><area shape="rect" coords="456,28,617,55" href="http://www.ortega.ca" alt="Design by Ortega.ca" target="_blank"></map> </map></div> <!-- GOOGLE ANALYTICS --> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-2910054-6']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </td> </tr> </table> </body> </html> <?php mysql_free_result($Recordset1); ?> Guys thanks for helping me solve the problem i had but now i have another problem and i am lost. i have included the code below for you to have overview.
This is the code:
<table style="width:100%; margin-left:auto; margin-right:auto"> I do not receive email for my published php file which is: <?php ///// easend.php ///// $youremail = "acdelco40108@yahoo.com"; /*put the email address here, between quotes, the email address you want the message sent to*/ $to = $youremail; $email = $_POST['EMail']; $name2 = $_POST['Name']; $street2 = $_POST['Street']; $city2 = $_POST['City']; $state2 = $_POST['State']; $zip2 = $_POST['Zip']; $Phone = $_POST['Home_Phone']; $Cell = $_POST['Cell_Phone']; $education = $_POST['email1']; $comments = $_POST['email2'] ; $headers = "From:" . $email; $fields = array(); $fields{"Name"} = "Name"; $fields{"Street"} = "Street"; $fields{"City"} = "City"; $fields{"State"} = "State"; $fields{"Zip"} = "Zip"; $fields{"Home_Phone"} = "Home Phone"; $fields{"Cell_Phone"} = "Cell Phone"; $fields{"EMail"} = "Email"; $fields{"email1"} = "Education"; $fields{"email2"} = "Comments"; $subject = "We have received the following information from your employment application"; $body = "We have received the following information from your employment application:\n\n"; foreach($fields as $a => $b) { $body .= sprintf("%20s: %s\n",$b,$_POST[$a]); } mail ($to, $subject, $body, $headers); //send mail to owner #end create email vars $headers = "From:" . $to; mail ($email, $subject, $body, $headers); //send mail to user #end create email vars echo "<head><META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=ThankYou.html\"></head>"; ?> |