PHP - I Need My Send Button To Send Form To My Email Address
Similar TutorialsI have made a shopping cart where I can add items from my sql table. But I dont know how to send the table to my email. this is my cart.php Can someone give me some tips? Thanks in advance. you can also check it out on http://fhcs.be/cart-demo3/ <?php // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions require_once('inc/functions.inc.php'); // Start the session session_start(); // Process actions $cart = $_SESSION['cart']; $action = $_GET['action']; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; } else { $cart = $_GET['id']; } break; case 'delete': if ($cart) { $items = explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($_GET['id'] != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } $cart = $newcart; } break; case 'update': if ($cart) { $newcart = ''; foreach ($_POST as $key=>$value) { if (stristr($key,'qty')) { $id = str_replace('qty','',$key); $items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($id != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } for ($i=1;$i<=$value;$i++) { if ($newcart != '') { $newcart .= ','.$id; } else { $newcart = $id; } } } } } $cart = $newcart; break; } $_SESSION['cart'] = $cart; ?><!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> <title>PHP Shopping Cart Demo &#0183; Cart</title> <link rel="stylesheet" href="css/styles.css" /> </head> <body> <div id="shoppingcart"> <h1>Your Shopping Cart</h1> <?php echo writeShoppingCart(); ?> </div> <div id="contents"> <h1>Please check quantities...</h1> <?php echo showCart(); ?> <p><a href="index.php">Back to bookshop...</a></p> </div> </body> </html> I'm trying to after submission
1. create a csv
2. insert record into db
3. send email that's created in form submission - $msg.
4. send email with attachment to only the email I specify (if possible)
if not attach it to the email that's created at submission.
I've search and search and found different methods but doesn't work with my code.
I kept 3 lines at the top but can't get them to work ... either I don't get an email after submission or don't get an attachement.
Can some one help?
<?php $random_hash = md5(date('r', time())); $csvString = "..."; // your entire csv as a string $attachment = chunk_split(base64_encode($csvString)); $to = "email@email.com"; if(isset($_POST['submit'])) { // VALIDATION if(empty($_POST['firstName'])) { "First Name Required"; } if(empty($_POST['lastName'])) { "Last Name Required"; } if(empty($error)) { $to = "$to"; $subject = 'The Form'; $headers = "MIME-Version: 1.0 \r\n"; $headers .= "Content-Type: text/html; \r\n" ; $msg .="<html> <head></head> <body> <table width='100%' cellspacing='0' border='0' cellpadding='0'> <tr><td> <table width='100%' cellspacing='0' border='0' cellpadding='0'> <tr><td>This is the email sent.</td></tr> </table> </body> </html>"; include('con.php'); $con = mysqli_connect($host,$user,$pass,$dbName); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"thetable"); $firstName = mysqli_real_escape_string($con, $_POST['firstName']); $lastName = mysqli_real_escape_string($con, $_POST['lastName']); $sql = "SELECT * FROM thetable WHERE `firstName` = '{$firstName}' OR `lastName` = '{$lastName}'"; $result = mysqli_query($con,$sql); if(($result->num_rows)>= 1) { $theerror = "You exist"; } else { $sql="INSERT INTO thetable(firstName, lastName) VALUES ('$_POST[firstName]','$_POST[lastName]'"; $success = "Sent ... Insert it!!!"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } $result = @mail($to, $subject, $msg, $headers); } mysqli_close($con); { } } } ?> Edited by barkly, 27 October 2014 - 02:59 PM. I am creating a Registration form and want to have a command button in the middle of the form that, when clicked, will send the user an email with an activation code. How can I do that? When the user clicks the button, I would like it to fire off an email, however I do not want the user to be taken off of the form or to lose anything the entered. I suppose you would normally do this with JavaScript, but since I don't know that, I am looking for a PHP solution for now. Thanks. Hi
First time post. I have read online and there are so many different answers I do not know which to choose.
I have a form on a website which works fine as it is.
I just want to add a function that when the the visitor clicks submit they get a copy of the email as well.
This is the code I have:
<p>Please read through our terms of business below. If you are happy with them and understand them please complete your details and press the agree button. We will email confirmation of receipt</p> <div class="content_image"> <img src="images/questionnaire.jpg" alt="" width="350" height="225" /> </div> <form id="questionnaire" method="post" action="terms-of-business-send.php" name="questionnaire"> <fieldset> <div> <label>Your Full Name:</label><br /> <input type="text" id="c_name1" name="c_name1" class="qfield clear" /> </div> <div> <label>Your Email:</label><br /> <input type="text" id="email" name="email" class="qfield clear" /> </div> <div> <label>Your Contact Tel:</label><br /> <input type="text" id="tel" name="tel" class="qfield clear" /> </div> </fieldset> <fieldset> <ol> <li> <h2>I agree I have read and understood the terms of business</h2> <input type="radio" name="q1" value="1" /> yes I agree<br /> </li> </ol> <div> </div> </fieldset> <input type="submit" value="Agree"> <input type="reset" value="Reset"> <h4 id="error">There were errors on the form, please make sure your name and email have been filled out correctly.</h4> </form> Then the send file is <?php $c_name1 = $_POST['c_name1']; $email = $_POST['email']; $tel = $_POST['tel']; $q1 = $_POST['q1']; //$to = 'enquiries@email.net'; $to = 'enquiries@cemail.net'; $subject = 'Terms of Business Completed'; $msg = "$c_name1 has completed a Terms of Business from.\n\n" . "Their email is: $email\n" . "Their contact number is: $tel\n" . "-----------------------------\n\n" . "1: $q1\n\n" . "Terms of business copy here" . "-----------------------------\n" . " END OF FORM -------\n" . "-----------------------------\n\n"; mail($to, $subject, $msg, 'From: website Terms of Business Form'); echo '<h2>Thanks for confirming our Terms of Business ' . $c_name1 . '</h2>'; ?> I kind of understand what is going on but am not proficient enough. Any help much appreciated. Rich Hi, I've created a basic form which uploads a document to my server. How do I generate an email with the uploaded document as an attachment? Here's the HTML: <form enctype="multipart/form-data" action="form1.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> Here's the PHP: <?php $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> Thanks in advance! I am stumped here, can not figure out a efficient way to collect all the data on this page and send it to my to user's id number. I am trying to format the email to include question #1 and then next to it radio1 (answer yes/no) , question#2 and so on followed by the viewers input from the last part of the form. Does any one know of some thing im missing here? <?php session_start(); // If the session vars aren't set, try to set them with a cookie if (!isset($_SESSION['user_id'])) { if (isset($_COOKIE['user_id']) && isset($_COOKIE['username'])) { $_SESSION['user_id'] = $_COOKIE['user_id']; $_SESSION['username'] = $_COOKIE['username']; } } ?> <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Social Filter - View Profile</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <h3>View Profile</h3> <font size="2"> <?php require_once('appvars.php'); require_once('connectvars.php'); // Make sure the user is logged in before going any further. if (!isset($_SESSION['user_id'])) { echo '<a href="signup.php">Create your own account</a>.</p>'; } else { echo('<p class="login">You are logged in as ' . $_SESSION['username'] . '. <a href="logout.php">Log out</a>.</p>'); } // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Grab the profile data from the database if (!isset($_GET['user_id'])) { $query = "SELECT username, first_name, last_name, gender, birthdate, city, state, picture, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20 FROM mismatch_user WHERE user_id = '" . $_SESSION['user_id'] . "'"; } else { $query = "SELECT username, first_name, last_name, gender, birthdate, city, state, picture, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20 FROM mismatch_user WHERE user_id = '" . $_GET['user_id'] . "'"; } $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 1) { // The user row was found so display the user data $row = mysqli_fetch_array($data); echo '<table cellpadding="0" cellspacing="0" border="0"><TR><TD> '; if (!empty($row['picture'])) { echo '<table cellpadding="0" cellspacing="0" border="1"><TR><td class="label">Pictu </td><td><img src="' . MM_UPLOADPATH . $row['picture'] . '" width="120" height="140" alt="Profile Picture" /></td></tr></table></td><td>'; } if (!empty($row['username'])) { echo '<table cellpadding="1" cellspacing="0" border="0"><TR><td class="label">Username:</td><td>' . $row['username'] . '</td></tr>'; } if (!empty($row['first_name'])) { echo '<tr><td class="label">First name:</td><td>' . $row['first_name'] . '</td></TR>'; } if (!empty($row['last_name'])) { echo '<tr><td class="label">Last name:</td><td>' . $row['last_name'] . '</td></TR>'; } if (!empty($row['gender'])) { echo '<tr><td class="label">Gender:</td><td>'; if ($row['gender'] == 'M') { echo 'Male'; } else if ($row['gender'] == 'F') { echo 'Female'; } else { echo '?'; } echo '</td></tr>'; } if (!empty($row['birthdate'])) { if (!isset($_GET['user_id']) || ($_SESSION['user_id'] == $_GET['user_id'])) { // Show the user their own birthdate echo '<tr><td class="label">Birthdate:</td><td>' . $row['birthdate'] . '</td></tr>'; } else { // Show only the birth year for everyone else list($year, $month, $day) = explode('-', $row['birthdate']); echo '<tr><td class="label">Year born:</td><td>' . $year . '</td></tr>'; } } if (!empty($row['city']) || !empty($row['state'])) { echo '<tr><td class="label">Location:</td><td>' . $row['city'] . ', ' . $row['state'] . '</td></tr>'; } echo '</td></tr></table></td></Tr></table><hr></font><FONT color="#666666" size="1" face="Courier"><table cellpadding="20" cellspacing="0" border="0"><tr><td>'; if (!isset($_GET['user_id']) || ($_SESSION['user_id'] == $_GET['user_id'])) { echo '<p>Would you like to <a href="editprofile.php">edit your profile</a>?</p>'; } } // End of check for a single row of user results else { echo '<p class="error">There was a problem accessing your profile.</p>'; } if (!empty($row['q1'])) { echo '1. ' . $row['q1'] . '<BR><input type="radio" name="radio1" id="yes1" value="yes" /> <label for="yes1">YES</label> or <input type="radio" name="radio1" id="no1" value="no" /> <label for="no1">NO</label><BR>'; } else { echo ' User has not made a application yet...<BR>'; } if (!empty($row['q2'])) { echo '2. ' . $row['q2'] . '<BR><input type="radio" name="radio2" id="yes2" value="yes" /> <label for="yes2">YES</label> or <input type="radio" name="radio2" id="no2" value="no" /> <label for="no2">NO</label><BR>'; } else { echo ' <BR>'; } if (!empty($row['q3'])) { echo '3. ' . $row['q3'] . '<BR><input type="radio" name="radio3" id="yes3" value="yes" /> <label for="yes3">YES</label> or <input type="radio" name="radio3" id="no3" value="no" /> <label for="no3">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q4'])) { echo '4. ' . $row['q4'] . '<BR><input type="radio" name="radio4" id="yes4" value="yes" /> <label for="yes4">YES</label> or <input type="radio" name="radio4" id="no4" value="no" /> <label for="no4">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q5'])) { echo '5. ' . $row['q5'] . '<BR><input type="radio" name="radio5" id="yes5" value="yes" /> <label for="yes5">YES</label> or <input type="radio" name="radio5" id="no5" value="no" /> <label for="no5">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q6'])) { echo '6. ' . $row['q6'] . '<BR><input type="radio" name="radio6" id="yes6" value="yes" /> <label for="yes6">YES</label> or <input type="radio" name="radio6" id="no6" value="no" /> <label for="no6">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q7'])) { echo '7. ' . $row['q7'] . '<BR><input type="radio" name="radio7" id="yes7" value="yes" /> <label for="yes7">YES</label> or <input type="radio" name="radio7" id="no7" value="no" /> <label for="no7">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q8'])) { echo '8. ' . $row['q8'] . '<BR><input type="radio" name="radio8" id="yes8" value="yes" /> <label for="yes8">YES</label> or <input type="radio" name="radio8" id="no8" value="no" /> <label for="no8">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q9'])) { echo '9. ' . $row['q9'] . '<BR><input type="radio" name="radio9" id="yes9" value="yes" /> <label for="yes9">YES</label> or <input type="radio" name="radio9" id="no9" value="no" /> <label for="no9">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q10'])) { echo '10. ' . $row['q10'] . '<BR><input type="radio" name="radio10" id="yes10" value="yes" /> <label for="yes10">YES</label> or <input type="radio" name="radio10" id="no10" value="no" /> <label for="no10">NO</label><BR></td><TD>'; } else { echo '<BR></td><td>'; } if (!empty($row['q11'])) { echo '11. ' . $row['q11'] . '<BR><input type="radio" name="radio11" id="yes11" value="yes" /> <label for="yes11">YES</label> or <input type="radio" name="radio11" id="no11" value="no" /> <label for="no11">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q12'])) { echo '12. ' . $row['q12'] . '<BR><input type="radio" name="radio12" id="yes12" value="yes" /> <label for="yes12">YES</label> or <input type="radio" name="radio12" id="no12" value="no" /> <label for="no12">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q13'])) { echo '13. ' . $row['q13'] . '<BR><input type="radio" name="radio13" id="yes13" value="yes" /> <label for="yes13">YES</label> or <input type="radio" name="radio13" id="no13" value="no" /> <label for="no13">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q14'])) { echo '14. ' . $row['q14'] . '<BR><input type="radio" name="radio14" id="yes14" value="yes" /> <label for="yes14">YES</label> or <input type="radio" name="radio14" id="no14" value="no" /> <label for="no14">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q15'])) { echo '15. ' . $row['q15'] . '<BR><input type="radio" name="radio15" id="yes15" value="yes" /> <label for="yes15">YES</label> or <input type="radio" name="radio15" id="no15" value="no" /> <label for="no15">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q16'])) { echo '16. ' . $row['q16'] . '<BR><input type="radio" name="radio16" id="yes16" value="yes" /> <label for="yes16">YES</label> or <input type="radio" name="radio17" id="no16" value="no" /> <label for="no16">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q17'])) { echo '17. ' . $row['q17'] . '<BR><input type="radio" name="radio17" id="yes17" value="yes" /> <label for="yes17">YES</label> or <input type="radio" name="radio17" id="no17" value="no" /> <label for="no17">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q18'])) { echo '18. ' . $row['q18'] . '<BR><input type="radio" name="radio18" id="yes18" value="yes" /> <label for="yes18">YES</label> or <input type="radio" name="radio18" id="no18" value="no" /> <label for="no18">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q19'])) { echo '19. ' . $row['q19'] . '<BR><input type="radio" name="radio19" id="yes19" value="yes" /> <label for="yes19">YES</label> or <input type="radio" name="radio19" id="no19" value="no" /> <label for="no19">NO</label><BR>'; } else { echo '<BR>'; } if (!empty($row['q20'])) { echo '20. ' . $row['q20'] . '<BR><input type="radio" name="radio20" id="yes20" value="yes" /> <label for="yes20">YES</label> or <input type="radio" name="radio20" id="no20" value="no" /> <label for="no20">NO</label><BR></td><td></font></font>'; } else { echo '<BR></td><td valign="top"></font></font><FONT color="#000000" size="1">'; } mysqli_close($dbc); ?> <script> function autotab(original,destination){ if (original.getAttribute&&original.value.length==original.getAttribute("maxlength")) destination.focus() } </script> <fieldset> <legend>Your Contact Information</legend> </font></font><FONT color="#cccc99" size="2" face="Impact"> <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> <table width="100%" border="0" cellpadding="2"> <tr> <td><div align="right"> <label for="vieweremail">Email</label> </div></td> <td><div align="left"> <input name="vieweremail" type="text" id="vieweremail" size="35" maxlength="90" /> </div></td> </tr> <tr> <td><div align="right"> <label for="veiwername">Name</label> </div></td> <td><div align="left"> <input name="veiwername" type="text" id="veiwername" size="35" maxlength="100" /> </div></td> </tr> <tr> <td><div align="right"> <label for="viewerphone">Phone Number</label> </div></td> <td><div align="left"> <input name="Phone1" type="text" id="phone1" onkeyup="autotab(this, document.form1.phone2)" size="3" maxlength="3" /> <input name="phone2" type="text" id="phone2" onKeyup="autotab(this, document.form1.phone3)" size="3" maxlength="3" /> <input name="phone3" type="text" id="phone3" onKeyup="autotab(this, document.form1.viewercomments)" size="4" maxlength="4" /> </div></td> </tr> <tr> <td><div align="right"> <label for="viewercomments">Comments</label> </div></td> <td><div align="left"> <textarea name="viewercomments" cols="26" rows="4" id="viewercomments"></textarea> </div></td> </tr> <tr> <td><div align="right"> <label for="viewerpic">Your Picture (optional)</label> </div></td> <td><div align="left"> <input name="viewerpic" type="file" id="viewerpic" size="22" /> </div></td> </tr> <tr> <td><div align="right"> <label for="clear"></label> <input type="reset" name="clear" id="clear" value="Clear Form!" /> </div></td> <td><div align="left"> <label for="submit"></label> <input type="submit" name="submit" id="submit" value="Send Email" /> </div></td> </tr> </table> </form> </fieldset> <BR><BR><BR><BR><BR><BR> </td></tr></table> </body> </html> Here is the send mail script im using.... trying to anyways.<?php require_once('appvars.php'); require_once('connectvars.php'); // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (isset($_POST['submit'])) { $from = 'cupid@cupidsomething.com'; $subject = $_POST['subject']; $text = $_POST['q1, q2,q3,q4....ect...etc....cet.....eece.c.']; $output_form = false; if (empty($subject) && empty($text)) { echo 'You forgot the email subject and body text.<br />'; $output_form = true; } if (empty($subject) && (!empty($text))) { echo 'You forgot the email subject.<br />'; $output_form = true; } if ((!empty($subject)) && empty($text)) { echo 'You forgot the email body text.<br />'; $output_form = true; } } else { $output_form = true; } if ((!empty($subject)) && (!empty($text))) { $query = "SELECT user_id FROM email_list WHERE user_id = '$user_id'; $result = mysqli_query($dbc, $query) or die('Error querying database.'); while ($row = mysqli_fetch_array($result)){ $to = $row['email']; $first_name = $row['first_name']; $last_name = $row['last_name']; $msg = "Dear $first_name $last_name,\n$text"; mail($to, $subject, $msg, 'From:' . $from); echo 'Email sent to: ' . $first_name . '<br />'; } mysqli_close($dbc); } if ($output_form) { ?> Any help would be greeeeatly appreciated. Here is a live example of this at www.interestingspecies.com/mismatch/20 sendmail.php Code: [Select] <?php $email = $_POST['email']; $to = $_POST['recipent']; $subject = "SUBJECT HERE."; $message = "YOUR MESSAGE HERE"; $header = "From: $email " . "\r\n"; $send = mail($to, $subject, $message, $header); echo "Your invitations have been sent!"; ?> and this is invite.php Code: [Select] <style> #container_mail { width:300px; margin:0 auto; background:#151521; padding:5px; background-color:#ffffff; border:1px solid black; /* for IE */ filter:alpha(opacity=60); /* CSS3 standard */ opacity:0.6; } #inner_container_mail { background:url(../images/inner_container.jpg) top repeat-x #181824; padding:10px 10px 10px 25px; } </style> <?php include_once 'common.php'; require_once("pages/validation.php"); ?> <script type="text/javascript" src="ajax/jquery.js"></script> <div id="container_mail"> <div id="inner_container_mail"> <div id="content"> <?if( isset($_POST['send']) && (!validateEmail($_POST['email']) ) ):?> <div id="error"> <ul> <?if(!validateEmail($_POST['email'])):?> <li><strong><?=$errormail?></strong> <?=$errormail1?></li> <?endif?> </ul> </div> <?elseif(isset($_POST['send'])):?> <div id="error" class="valid"> <ul> <li><strong><?=$congratulations?></strong> <?=$congratulations?></li> </ul> </div> <p> <?endif?> </p> <form method="post" id="customForm" action="pages/invite_mail.php"> <div> <label for="email"><?= $email; ?></label> <input id="email" name="email" type="text" /> <span id="emailInfo"><?= $yourmail; ?></span> </div> <div> <label for="recipent"><?= $email; ?></label> <input id="recipent" name="recipent" type="text" /> <span id="emailInfo"><?= $yourmail; ?></span> </div> <div> <input id="send" name="send" type="submit" value="<?=$submit;?>" /> </div> </form> </div> <script type="text/javascript" src="ajax/jquery.js"></script> <script type="text/javascript" src="ajax/validation_email.js"></script> </body> </html> </div> </div> </div> </body> </html> how to send the corent location in website to friend for example now my location is http://www.phpfreaks.com/forums/index.php?action=post;board=1.0 how to send this ? sorry for my english .. I am brand new at php coding so I am struggling to understand why my php code is not working in my website. I would like my html form to send me data to my email. Whatever I try, it just will not work. I have ftp'ed it to my website and I checked with my web host, they do support php. Anyone who can help out a newbie, please?
This is my very simple form to capture email addresses of new clients: <form action="send_mail.php" method="post"> <input name="Email"
placeholder="Enter your email..." required="" type="email"> This is the php coding I have placed in a document called send_mail.php:
<?php /* Code: [Select] <?php $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $dropdown = $_POST['dropdown']; $formcontent=" From: $firstname \n Surname: $lastname \n Email: $email \n Dropdown: $dropdown"; $recipient = "martin@sittingspiritually.co.uk, siobhan@sittingspiritually.co.uk"; $subject = "Newsletter Sign Up"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); if ( mail($recipient, $subject, $formcontent, $mailheader) ){ header('Location: http://www.sittingspiritually.co.uk/thankyou.php'); } else { die ("error"); } ?> I have recently created a small snippet of php code for posting mail and it's sweet apart from 1 thing. I have two email addresses in the recipient section. It only sends to the last name in the list. Is this because i have written recipient? Should it be recipients? I need this mail to be delivered to both of the email addresses. I'm sure it's simple for someone with expert knowledge. Thanks in advance for any help. Hi all, What I am trying to achieve is, I thought quite simple! Basically, a user signs up and chooses a package, form is submitted, details added to the database, email sent to customer, then I want to direct them to a paypal payment screen, this is where I am having issues! Is their any way in php to submit a form without user interaction? Here is my code for the form process page Code: [Select] <?php include('config.php'); require('scripts/class.phpmailer.php'); $package = $_POST['select1']; $name = $_POST['name']; $email = $_POST['email']; $password = md5($_POST['password']); $domain = $_POST['domain']; $a_username = $_POST['a_username']; $a_password = $_POST['a_password']; $query=mysql_query("INSERT INTO orders (package, name, email, password, domain, a_username, a_password) VALUES ('$package', '$name', '$email', '$password', '$domain', '$a_username', '$a_password')"); if (!$query) { echo "fail<br>"; echo mysql_error(); } else { $id = mysql_insert_id(); $query1=mysql_query("INSERT INTO customers (id, name, email, password) values ('$id', '$name', '$email', '$password')"); if (!$query1) { echo "fail<br>"; echo mysql_error(); } if($package=="Reseller Hosting") { //email stuff here - all works - just cutting it to keep the code short if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } ?> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <input type="hidden" name="business" value="subscription@jollyhosting.com"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="item_name" value="Jolly Hosting Reseller Packages"> <input type="hidden" name="no_shipping" value="1"> <!--1st month --> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="a3" value="3.00"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <input type="hidden" name="src" value="1"> <input type="hidden" name="sra" value="1"> </form>'; <?php } //last } //end ?> if anyone out there fancy's helping the needy please can you cast your eyes over my mess! and possibly help me find my way out of this maze? So im useing a third party form, and a third party php script.......... cant get them to work together . form script : [color=red//-------------------------------------------------[/color] <form action="phpquote.php" method="post" id="reserve-form"> <div class="box"> <div class="left-top-corner"> <div class="right-top-corner"> <div class="border-top"></div> </div> </div> <div class="border-left"> <div class="border-right"> <div class="xcontent"> <h5>Get an online quote for your journey</h5> <p>please fill in all fields for your quote.</p> <fieldset> <div class="field"> <label>Customer Information</label> <input type="text" id="name" value="Name" onblur="if(this.value==''){this.value='Name'}" onfocus="if(this.value=='Name'){this.value=''}" /> </div> <div> <input type="text" id="number" value="Phone" onblur="if(this.value==''){this.value='Phone'}" onfocus="if(this.value=='Phone'){this.value=''}" /> </div> </fieldset> <fieldset class="style1"> <div class="field"> <label>Travel Date/ Time</label> <select id="year"> <option>2010</option> <option>2011</option> </select> <select class="sel-1" id="month"> <option>Jan</option> <option>Feb</option> <option>Mar</option> <option>Apr</option> <option>May</option> <option>Jun</option> <option>Jul</option> <option>Aug</option> <option>Oct</option> <option>Sep</option> <option>Nov</option> <option>Dec</option> </select> <select class="sel-2" id="date"> <option>1</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> <option>24</option> <option>25</option> <option>26</option> <option>27</option> <option>28</option> <option>29</option> <option>30</option> <option>31</option> </select> </div> <div class="field"> <select class="sel-2" id="time"> <option>00</option> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option></select> <select class="sel-2" id="time"> <option>00</option> <option>15</option> <option>30</option> <option>45</option> </select> </div> <div class="field"> <label>No. Passangers</label> <select id="year"> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> </select> </div> </fieldset> <fieldset class="style2"> <div class="field"> <label>Pickup Information</label> <input type="text" id="where" value="Pickup Address" onblur="if(this.value==''){this.value='Pickup Address'}" onfocus="if(this.value=='Pickup Address'){this.value=''}" /> </div> <div> <select id="where"> <option>or Airport</option> <option>Stansted</option> <option>Gatwick</option> <option>Heathrow</option> <option>Luton</option> </select> </div> </fieldset> <fieldset class="style2 style3"> <div class="field"> <label>Drop-off Information</label> <input type="text" id="to" value="Drop-off Address" onblur="if(this.value==''){this.value='Drop-off Address'}" onfocus="if(this.value=='Drop-off Address'){this.value=''}" /> </div> <div> <select id="to"> <option>or Airport</option> <option>Stansted</option> <option>Gatwick</option> <option>Heathrow</option> <option>Luton</option> </select> </div> </fieldset> </div> </div> </div> <div class="left-bot-corner"> <div class="right-bot-corner"> <div class="border-bot"><a href="#" class="link2" onclick="document.getElementById('reserve-form').submit()"><em><b>Get Quote</b></em></a></div> </div> </div> </div> </form> //----------------------------------------------------------------------------- php script //----------------------------------------------------------------------------- <?php //--------------------------Set these paramaters-------------------------- // Subject of email sent to you. $subject = 'Results from Contact form'; // Your email address. This is where the form information will be sent. $emailadd = 'm.mcdade@hotmail.co.uk'; // Where to redirect after form is processed. $url = 'http://www.mock.thetaxirank.co.uk/thankyou.html'; // 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.'">'; ?> //----------------------------------------------------------------------------- any advice will be appreciated..... thanks in advance to any kind souls !!! I have a contact form with a file upload button, when you click on “submit” you are redirected on Paypal everything works fine but, I would like to send the contact form only when visitors have paid on Paypal. I’ve searched on google but I have not found a way to do this. Can anyone help? Cheers, Aidan. Hey guys, how do I send checkbox variables to my e-mail address once a user has checked it on the html form. Here is my html form: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Form</title> <script type="text/javascript"> //email form validation function everif(str) { var at="@" var punct="." var lat=str.indexOf(at) var lstr=str.length var lpunct=str.indexOf(punct) if (str.indexOf(at)==-1){ alert("Valid email must be entered") return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ alert("Valid email must be entered") return false } if (str.indexOf(punct)==-1 || str.indexOf(punct)==0 || str.indexOf(punct)==lstr){ alert("Valid email must be entered") return false } if (str.indexOf(at,(lat+1))!=-1){ alert("Valid email must be entered") return false } if (str.substring(lat-1,lat)==punct || str.substring(lat+1,lat+2)==punct){ alert("Valid email must be entered") return false } if (str.indexOf(punct,(lat+2))==-1){ alert("Valid email must be entered") return false } if (str.indexOf(" ")!=-1){ alert("Valid email must be entered") return false } return true } function evalid(){ var emailID=document.contact_form.mail if (everif(emailID.value)==false){ emailID.focus() return false } //empty field validation var naam=document.contact_form.naam if ((naam.value==null)||(naam.value=="")){ alert("Fields marqued with * must be entered") naam.focus() return false } var telefoon=document.contact_form.telefoon if ((telefoon.value==null)||(telefoon.value=="")){ alert("Fields marqued with * must be entered") telefoon.focus() return false } var branche=document.contact_form.branche if ((branche.value==null)||(branche.value=="")){ alert("Fields marqued with * must be entered") branche.focus() return false } return true } </script> </head> <body> <form name="contact_form" method="post" id="contactform" action="doeactie.php" onSubmit="return evalid()"> <table border="0"> <tr> <td><label for="bedrijfsnaam">Company name</label></td> <td colspan="2"><input name="bedrijfsnaam" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="naam">Name *</label></td> <td colspan="2"><input name="naam" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="mail">E-mail *</label></td> <td colspan="2"><input type="text" name="mail" class="text" size="30" /></td> </tr><tr> <td><label for="adres">Address</label></td> <td colspan="2"><input name="adres" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="plaatsnaam">City</label></td> <td colspan="2"><input name="plaatsnaam" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="postcode">Zip</label></td> <td colspan="2"><input type="text" name="postcode" class="text" size="10" /></td> </tr><tr> <td><label for="branche">Niche *</label></td> <td colspan="2"><input name="branche" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="telefoon">Phone *</label></td> <td colspan="2"><input name="telefoon" class="text" type="text" size="30" /></td> </tr><tr> <td><label for="bericht">Question or Comment</label></td> <td colspan="2"><textarea name="message" class="text" onkeyup="return limitarelungime(this, 255)" cols="35" rows="5"></textarea></td> </tr> </table> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td></td> <td height="25"></td> </tr> <tr> <td></td> <td height="30" valign="top"><font face="arial" size="2"><b>I would also like to receive information about :</b></font></td> </tr> <tr> <td><input type="checkbox" name="emailmarketing" id="emailmarketing" value="emailmarketing" /></td> <td height="25"><font face="arial" size="2">E-mail Campaign</font></td> </tr> <tr> <td><input type="checkbox" name="zoekmachopt" id="zoekmachopt" value="zoekmachopt" /></td> <td height="25"><font face="arial" size="2">SEO</font></td> </tr> <tr> <td><input type="checkbox" name="socialmedia" id="id" value="socialmedia" /></td> <td height="25"><font face="arial" size="2">Social Media</font></td> </tr> <tr> <td><input type="checkbox" name="videomarketing" id="videomarketing" value="videomarketing" /></td> <td height="25"><font face="arial" size="2">Video Marketing</font></td> </tr> <tr> <td><input type="checkbox" name="webshop" id="webshop" value="webshop" /></td> <td height="25"><font face="arial" size="2">Webshop</font></td> </tr> <tr> <td><input type="checkbox" name="cms" id="cms" value="cms" /></td> <td height="25"><font face="arial" size="2">Content Management System</font></td> </tr> <tr> <td><input type="checkbox" name="grafisch" id="grafisch" value="grafisch" /></td> <td height="25"><font face="arial" size="2">Graphic Design</font></td> </tr> <tr> <td></td> <td align="left"><br /><input type="submit" name="Submit" value="Send"></td> <td align="right"></td> </tr> </table> </form> </body> </html> and this is the PHP script that processes this. Everything works except for the checkbox part. <?php session_start(); if(isset($_POST['Submit'])) { $youremail = 'blabla@gmail.com'; $fromsubject = 'Request from form'; $bedrijfsnaam = $_POST['bedrijfsnaam']; $naam = $_POST['naam']; $mail = $_POST['mail']; $adres = $_POST['adres']; $plaatsnaam = $_POST['plaatsnaam']; $postcode = $_POST['postcode']; $branche = $_POST['branche']; $telefoon = $_POST['telefoon']; $message = $_POST['message']; $to = $youremail; $mailsubject = 'Bericht ontvangen van'.$fromsubject.' Actie Pagina'; $body = $fromsubject.' Bedrijfsnaam: '.$bedrijfsnaam.' Naam Contact Persoon: '.$naam.' E-mail: '.$mail.' Adres: '.$adres.' Plaatsnaam: '.$plaatsnaam.' Postcode: '.$postcode.' Branche: '.$branche.' Telefoonnummer: '.$telefoon.' vraag of Wens: '.$message.' |---------End Message----------|'; echo "thank you for your request we will contact you asap."; mail($to, $subject, $body); } else { echo "Error Please <a href='form.html'>try again</a>"; } ?> Any help would be great! Thanks guys 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); I am working on a phpmailer script that sends an order confirmation email to the customer AND the client at the same time. If I have the customer email and client email set both to the originating domain's email addresses (myname@myserver.com), then it sends fine. However, if I try to send to an outside mail server (eg. someone@gmail.com), I get the following errors: Code: [Select] SMTP -> FROM SERVER:220 myserver.com ESMTP Exim 4.63 Sat, 18 Sep 2010 15:08:21 -0700 SMTP -> FROM SERVER: 250 myserver.com Hello localhost [127.0.0.1] 250-SIZE 52428800 250-PIPELINING 250-AUTH LOGIN PLAIN 250-STARTTLS 250 HELP SMTP -> FROM SERVER:250 OK SMTP -> FROM SERVER:250 Accepted SMTP -> FROM SERVER: SMTP -> ERROR: RCPT not accepted from server: SMTP Error: The following recipients failed: someone@gmail.com Message could not be sent. Mailer Error: SMTP Error: The following recipients failed: someone@gmail.com SMTP server error: I'm not sure what's going on here. Any SMTP or phpmailer geniuses here that can shed some light on what needs to happen here for this to send to any address? Hi, I'm trying to setup a quick PHP script that will grab the email from the url (see below) and after inserting into MySQL db - which is working fine - the script will complete two additional tasks: 1. send that same captured email out to a external db as in shown via http://domain1.com/insert.php?email=$lead (example), but then send to a DIFFERENT source - the originator of the lead - a portback acknowledgement using Header (sending the status and email to http://domain2.com/check.php?e=$lead&s=$status for their records). See the code below: ------------------------- Code: [Select] $lead = $_REQUEST['e_mail']; // will grab email from posted url string and assign to local variable $result = mysql_query($command); // this is just to execute the MySQL insert which works just fine but included here to explain validation below // Create API Call string to insert lead into iContact folder $requestURL = "http://domain1.com/insert.php?email=$lead"; // Execute API Call to CAKE $xml = simplexml_load_file($requestURL) or die("feed not loading"); if ($result) { $status = 1; // mark lead as sucess // send postback on lead status header("Location: http://domain2.com/check.php?e=$lead&s=$status"); } -------- Problem: I'm getting all sorts of errors with the simplexml_load_file() function and can't figure out why it won't work. Any input appreciated as this the only way I know how to pass the lead onward and then inform/update the other party of receipt of information. thanks! Hello Guys,
I need your help as many PHPers here is more experienced in PHP coding than me. I have specific project I am working on and need a piece of code that can send an email from HTML form using PHP to the email address that is entered manually on the form, instead of standard sent to PHP code that is fixed within PHP script and executed during submission. I want sth that can grab manually enetered recipient's e-mail address, paste it to the PHP code and then use it to send the email to the recipient, instead of fixed sent to code. Something would say dynamically changed during the entry that can inject into PHP code the new address email entered on the form and then submit to it. Any ideas will be great.
Thanks.
Edited March 27, 2019 by slawotrend Hello, i have been looking for and answer on the internet but i couldn't find it! I'm new on PHP based on and example i wrote something like this for my website: //basic variables $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "example@mysite.org"; $Subject = "Registration u10"; $teamname = Trim(stripslashes($_POST['teamname'])); $affiliation = Trim(stripslashes($_POST['affiliation'])); $premier = Trim(stripslashes($_POST['premier'])); $challenge = Trim(stripslashes($_POST['challenge'])); $girls = Trim(stripslashes($_POST['girls'])); $boys = Trim(stripslashes($_POST['boys'])); //about 15 more variables go in here but i don't want to put them to save some space // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // email body text //this includes the info of all the variables at the top even the ones I didn't write in here (but you get the point ) $Body = ""; $Body .= "Team Name: "; $Body .= $teamname; $Body .= "\n"; $Body .= "\n"; $Body .= "AYSleague: "; $Body .= $aysleague; $Body .= "\n"; $Body .= "\n"; $Body .= "Flash Tournament: "; $Body .= $flashtournament; $Body .= "\n"; $Body .= "\n"; $Body .= "Spring 2011: "; $Body .= $spring2011; $Body .= "\n"; $Body .= "\n"; $Body .= "Summer 2011: "; $Body .= $summer2011; $Body .= "\n"; $Body .= "\n"; $Body .= "fall 2011: "; $Body .= $fall2011; $Body .= "\n"; $Body .= "\n"; // send email to my inbox with the information above $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // if everything goes OK it will redirect them to another page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=thanksu12.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; } ?> the problem that i have is: (i divided it in 2 sections) 1- i need to sent a second email to the coach 2- that email only needs to have the information of 6 variables not the whole thing I don't know how to do it, if someone knows how to do it, i will appreciate some help!! thanks! Hi guys, i have a custom made php that collect all the info in admin page (long story short), there's a button called "Approve" I would like to send back an email to user who applied with picture, once Approved button is pressed, so here's the script: <?php session_start(); $user = '123'; $pass = '123'; $to = $data['email']; $subject = 'blablabla'; $message = 'test123'; if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $pass) { header('WWW-Authenticate: Basic realm="Enter password to access this page."'); header('HTTP/1.0 401 Unauthorized'); echo"You must be logged in to see this page."; exit; } ################## PROTECTED CONTENT ######################## require('./config.php'); ?> <!DOCTYPE HTML> <html> <head> <title>ADMIN PANEL</title> <style type="text/css"> body{width: 960px; margin: auto; margin-top: 20px; padding: 5px 20px; box-shadow: 0px 0px 2px #000000; border-radius: 5px;background:transparent url(images/bg_header.gif) top left repeat-x;} a:link,a:active,a:visited{color: inherit; text-decoration: none;} a:hover{text-decoration: underline;} .button{background:transparent url(images/grad.PNG) bottom left repeat-x; padding: 3px 5px; border-radius: 4px; border: 1px solid #cccccc;} .button:hover{border-color:orangered;text-decoration:none;} .approve .img{max-height: 200px; max-width: 200px; position: absolute; right: 5px; top: 5px;} .approve{display: block; height: 200px; overflow: hidden; box-shadow: 0px 0px 2px #000000; margin-top: 20px; padding: 20px; position: relative; font:13px verdana;} textarea,input{padding: 3px;font: 13px helvetica,verdana;border:1px solid rgb(51,151,251);border-radius: 4px;width: 300px; display: block; margin: 5px 0px;} input:hover,textarea:hover{border-color:orangered;cursor:pointer;} form{font:bold 13px verdana;} input[type='submit'],input[type='button']{width: auto;} </style> </head> <body> <?php echo" <div id='head'> <h1 align='center'>ADMIN PANEL</h1> <h4 align='center'><a href='index.php' class='button'>Homepage</a> <a class='button' href='admin.php'>Approval Queue</a> <a class='button' href='admin.php?edit'>Edit Image info.</a> <a class='button' href='?edit&view'>View Image Info.</a></h4> </div>"; if (isset($_GET['edit'])) { if (isset($_GET['pid'])) { $pic = mysql_query('SELECT * from `' . $table_name . '` WHERE pid = ' . intval($_GET['pid'])); if (mysql_num_rows($pic) == 1) { if (isset($_POST['submit'])) { $approved = isset($_POST['approved']) && $_POST['approved'] == '1' ? 1 : 0; mysql_query('UPDATE `' . $table_name . '` SET ' . 'first_name = "' . $_POST['first'] . '",' . 'last_name="' . $_POST['last'] . '",' . 'phone="' . $_POST['phone'] . '",' . 'email="' . $_POST['email'] . '",' . 'first_name="' . $_POST['first'] . '",' . 'approved=' . $approved . ',' . 'address="' . $_POST['addr'] . '",' . 'admin_desc="' . $_POST['admin_desc'] . '"' . ' WHERE pid = ' . intval($_GET['pid'])) or exit("Unable to edit" . mysql_error()); echo'<h3>EDITED</h3>'; $pic = mysql_query('SELECT * from `' . $table_name . '` WHERE pid = ' . intval($_GET['pid'])); } $data = mysql_fetch_array($pic); if (isset($_GET['view'])) { echo' <strong>Uploaded by </strong>' . $data['first_name'] . ' ' . $data['last_name'] . ' <br /> <img src="' . $default_dir . $data['image_name'] . '" style="max-width: 200px; max-height:200px; float: right;" /> <br /> <br /> <b>First_name :</b> ' . $data['first_name'] . ' <br /> <br /> <b>Last_name :</b> ' . $data['last_name'] . ' <br /> <br /> <b>Phone :</b> ' . $data['phone'] . ' <br /> <br /> <b>Email :</b> ' . $data['email'] . ' <br /> <br /> <b>Approved :</b> ' . ($data['approved'] == 1 ? 'Yes' : 'No') . ' <br /> <br /> <b>Address :</b> ' . $data['address'] . ' <br /> <br /> <b>Admin_description :</b> <br /> <br />' . $data['admin_desc'] . ' <br /> <br /> <a href="?edit&pid=' . $data['pid'] . '" class="button">Edit</a> <br /> <br /> '; } else { echo'<form method="POST" action="?edit&pid=' . intval($_GET['pid']) . '"> Editting photo: <a style="color:rgb(51,151,251);" href="' . $default_dir . $data['image_name'] . '">' . $data['image_name'] . '</a> uploaded by ' . $data['first_name'] . ' ' . $data['last_name'] . ' <br /> <img src="' . $default_dir . $data['image_name'] . '" style="max-width: 200px; max-height:200px; float: right;" /> <br /> First_name : <input type="text" name="first" value="' . $data['first_name'] . '" /> Last_name : <input type="text" name="last" value="' . $data['last_name'] . '" /> Phone : <input type="text" name="phone" value="' . $data['phone'] . '" /> Email : <input type="text" name="email" value="' . $data['email'] . '" /> Approved : <input type="text" name="approved" value="' . $data['approved'] . '" /> 0 or 1 Address : <textarea name="addr">' . $data['address'] . '</textarea> Admin_description : <textarea name="admin_desc">' . $data['admin_desc'] . '</textarea> <input type="submit" name="submit" value="Edit" /> </form>'; } } else { echo"NO SUCH PICTURE EXISTS"; } } else { echo" <h3>Search for image to " . (isset($_GET['view']) ? 'view' : 'edit') . " it: </h3> <form id='form' method='POST' action='admin.php?edit" . (isset($_GET['view']) ? '&view' : '') . "'> Uploader's first name: <input type='text' name='name' value='' /> OR Image name: <input type='text' name='img' value='' /> OR Email: <input type='text' name='email' value='' /> <input type='submit' name='submit' value='Search' /> </form>"; if (isset($_POST['submit'])) { $name = empty($_POST['name']) ? '%' : '%' . $_POST['name'] . '%'; $email = empty($_POST['email']) ? '%' : '%' . $_POST['email'] . '%'; $img = empty($_POST['img']) ? '%' : '%' . $_POST['img'] . '%'; $query = mysql_query( 'SELECT * from `' . $table_name . '` where ' . 'first_name like "' . $name . '" and ' . 'email like "' . $email . '" and ' . 'image_name like "' . $img . '"'); if (mysql_num_rows($query) > 0) { while ($pic = mysql_fetch_array($query)) { echo"<hr/><strong>Uploaded by $pic[first_name] $pic[last_name] " . date(' \a\t H:i \o\n d/m/Y', intval($pic['image_name'])) . "</strong> - <a href='$default_dir$pic[image_name]' target='_blank'>$pic[image_name]</a> <a href='?edit" . (isset($_GET['view']) ? '&view' : '') . "&pid=$pic[pid]' class='button'>" . (isset($_GET['view']) ? 'View' : 'Edit') . "</a>"; } } else { echo "NO IMAGE MATCHES THAT DESCRIPTION"; } } } exit; } if (isset($_GET['approve'])) { if (mysql_query('UPDATE `' . $table_name . '` SET approved = 1 WHERE pid = ' . intval($_GET['approve']))) { if (@mail($to, $subject, $message)) { echo('<p>Mail sent successfully.</p>'); } else { echo('<p>Mail could not be sent.</p>'); } echo"<h2>APPROVEDs</h2>"; } } It's not whole script though. Hello, I have a registration page and when a user registers I want to send their email an activation code. To test I have the following code. <?php //Send activation Email $to = $Email_address; $subject = "www.WEBSITE.com/"; $message = "Welcome to my website!\r\rYou, or someone using your email address, has completed registration at WEBSITE. You can complete registration by clicking the following link:\rhttp://www.WEBSITE.com/register.php?action=verify&$activationKey\r\r If this is an error, ignore this email and you will be removed from our mailing list.\r\rRegards,\ "; $headers = 'From: noreply@abc.com' . "\r\n" . 'Reply-To: noreply@abc.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); if (mail($to, $subject, $message, $headers)) { echo 'Success'; } else { echo 'Error'; } ?> I have the last if else to see if it is sent to not. I do get a Success message, but I don't get an email at the address (I have checked the spam folder). I have checked the email address and it is correct. I have even waited a few hours and nothing. Why is the email not getting to my account? |