PHP - How To Create A Pdf Dynamically And Send It Has Email Attachement
How to create a pdf dynamically and that pdf should sent as a email attachment.
Similar TutorialsHi Friends ,
I'm new to this forum and to the PHP world , please help me with the folowing code as it drives me creazy . I'm making a project for my studies a webpage to send email with attachement ,
if I send it without attachement , the mail goes through . if I attach any attachement it wont send the mail this is the code , please help :
<?php 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. 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); 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 We recently migrated over to a new AMP platform that I built from source and now we can't dynamically generate images. It seems like GD is properly included into PHP (although I didn't know then I could do it using dynamic modules): My PHP configure is as follows: ================================================== './configure' '--prefix=/export/appl/pkgs/php/v5.3.9' '--with-apxs2=/export/appl/pkgs/httpd/latest/bin/apxs' '--with-mysql=/export/appl/pkgs/mysql/latest' '--with-mysqli=/export/appl/pkgs/mysql/latest/bin/mysql_config' '--with-gd=/export/appl/pkgs/libgd/latest' '--with-pear' '--with-png-dir=/export/appl/pkgs/libpng/latest' '--with-jpeg-dir=/export/appl/pkgs/jpeg/latest' '--with-curl=/export/appl/pkgs/curl/latest' '--with-freetype-dir=/export/appl/pkgs/freetype/latest' '--with-mhash=/export/appl/pkgs/mhash/latest' '--with-mcrypt=/export/appl/pkgs/libmcrypt/latest' '--enable-pcntl' '--enable-soap' '--enable-mbstring' '--with-zlib-dir=/export/appl/zlib/v1.2.5' '--with-ldap' ================================================== The GD section in phpinfo is as follows: ================================================== GD Support enabled GD Version 2.0 FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.4.6 GIF Read Support enabled GIF Create Support enabled JPEG Support enabled libJPEG Version unknown PNG Support enabled libPNG Version 1.5.5 WBMP Support enabled Directive Local Value Master Value gd.jpeg_ignore_warning 0 0 ================================================== I get broken image icons in IE and Chrome, and I get an "image cannot be displayed" msg in FF. I'd appreciate someone clubbing me with a cluestick. - Joe I have a slideshow that I am having to modify for my needs. The data file uses an array and i need this to be dynamic. I need to loop through all images in a directory and create the array. I have the directory being stored in a variable already. Now i just need to loop though all images in that directory to create the array like you see in the below code. You can also see the directory variable at the top. Can someone give me a hand with this please? Code: [Select] <?php echo $slideimagefolder; //http://localhost:82/images/groupphotos/1/1/ $slides = array( // --- Start slide list --- // slide elements array( "slidelink" => "http://www.frontpageslideshow.net", "title" => "Frontpage Slideshow 1.7", "category" => "About Frontpage Slideshow", "tagline" => "Image taken from the movie \"Shoot 'em up\"", "text" => "\"Frontpage SlideShow\" is the most eye-catching way to display your featured articles, stories or even products in your php based website or CMS, like Time.com, Joost.com or Yahoo! Movies do. \"Frontpage SlideShow\" creates an uber-cool slideshow with text snippets laying on top of images. These \"slides\" are being rotated one after the other with a nice fade effect. The slideshow features navigation and play/pause buttons, so the visitor has complete control over the slideshow's \"playback\"! And best of all, Frontpage Slideshow can be skinned!", "slideimage" => "ao4.jpg" ), // slide elements array( "slidelink" => "http://www.frontpageslideshow.net", "title" => "Use Frontpage Slideshow on any PHP based site!", "category" => "About Frontpage Slideshow", "tagline" => "Image taken from the movie \"The Kingdom\"", "text" => "JoomlaWorks has developed this modification of Frontpage Slideshow to work on every website that supports PHP as a minimum requirement. We call this modification the \"Static PHP\" version of Frontpage Slideshow. It's ideal for use on non-Joomla!/Mambo websites, like for example your corporate PHP based website or your Wordpress blog or Drupal website! You can obviously use this version on any CMS that is based on PHP!", "slideimage" => "the_kingdom_20070820114258369.jpg" ), // slide elements array( "slidelink" => "http://www.frontpageslideshow.net/content/view/14/37/", "title" => "FPSS is Search Engine Friendly!", "category" => "About Frontpage Slideshow", "tagline" => "Image taken from the movie \"Invaders\"", "text" => "Unlike Flash based slideshows, Frontpage Slideshow uses unobtrusive javascript and some CSS wizardry only. The content of the slides is laid out as html code, which means it can be \"read\" by search engines. The proper usage (and order) of h1, h2, p (and more) tags will make sure Google (or any other search engine) regularly \"scans\" your latest/featured items.", "slideimage" => "TVD_TR_02183_2.jpg" ), // slide elements (***TIP***: copy this data block and paste it below itself to add more slides) array( "slidelink" => "http://www.joomlaworks.gr", "title" => "About JoomlaWorks", "category" => "", "tagline" => "Image taken from the movie \"Transformers\"", "text" => "JoomlaWorks is a team of professional web designers and developers dedicated to delivering high-quality extensions and templates for Joomla! (the most popular open source Content Management System (CMS) worldwide) and Mambo (award winning CMS). JoomlaWorks has established a solid reputation in the Joomla! & Mambo communities, having developed some of the most popular and innovative free & commercial extensions & templates, since 2006.", "slideimage" => "2007_transformers_014_1.jpg" ), // --- End slide list --- ); ?> Friends, I have a PHP script that populates a calendar based on an array as follows: $days = array(2=>array('javascript:showWhatsOnText(2);','linked-day'), 3=>array('javascript:showWhatsOnText(3);','linked-day'), 4=>array('javascript:showWhatsOnText(4);','linked-day')); echo generate_calendar(2011, 4, $days, 1, '#'); where, for instance, the 2, 3 4 are the days of the month, By extracting a series values from a MySQL database how would I generate this array dynamically. E.g I have startday, startmonth, name and text fields in the database and would need to loop through them all to create the array. I tried playing around with something like this without any luck: $queryCat1 = "SELECT * FROM $dbCalendarEvents ORDER BY id ASC"; // WHERE visible = '1' $result1 = mysql_query($queryCat1) or die (mysql_error()); $num1 = mysql_num_rows($result1); $i=0; $daysArray = array(); while ($i < $num1) { $startday=mysql_result($result1,$i,"startday"); $startmonth=mysql_result($result1,$i,"startmonth"); $name=mysql_result($result1,$i,"name"); $name=mysql_result($result1,$i,"name"); $copy=mysql_result($result1,$i,"copy"); $daysArray[$i] = $startday=>array('/weblog/archive/2004/Jan/02','linked-day'); $i++; } Your help is appreciated. Hi, I want to create a .html file dynamically on the server. Below is the code for that but i was not able to create the file. I have given all the read, write and execute permission on the folder. $filerand = rand(); $fileName = "test.html"; $filepath = $_SERVER['DOCUMENT_ROOT'] . "\\testfolder\\" . $fileName . ".html"; echo $filepath; $bodytxt = "Welcome to my webpage"; $ourFileHandle = fopen($filepath, 'w') or die("can't open file"); fwrite($ourFileHandle, $bodytxt); fclose($ourFileHandle); Thanks in advance Hi, i coded a very simple forum "website" with registration, login, and a place where everyone posts comments. I wanted to make some sort of profile page for each user so they would each have their own URL too (e.i. test/barney or test/simpsons). each of these pages would have different content, depending on what barney or simpsons puts on that page. i've been looking everywhere trying to find documentation but i don't think i know how to search it correctly. I checked a lot of mod_rewrite documentation but i don't understand if i'm suppose to call a php function to create a profile page or something. Any guidance would be greatly appreciated Thanks! Hi guys i have to create text field & enter data and store in the data base. here im able to create text field but couldn't insert the data. so could anyone please check this code for me. <body> <form method="POST" action="cell.php"> Enter the number of question <input type="text" name="question"> <input type="submit"> <?php $value=$_POST['question']; for($i=0;$i<$value;$i++) { echo "Question NO:"; echo '<input type="text" name="qno">'."\t"; echo "Enter Marks:"; echo '<input type="text" name="marks">'."\t"; echo "<br>"; } ?> </form> <form name="form1" method="post" action="cellresult.php"> <label> <input type="submit" name="Submit" value="Submit"> </label> </form> </body> cellresult.php <body> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test", $con); $sql="INSERT INTO cell (QNO,MARKS) VALUES ('$_POST[qno]','$_POST[marks]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> </body>
The code below currently sends a separate Email with data from each row of a table when a Save All button is pressed. So, if I have 4 rows of data, 4 Email will be sent. $email="to@email.com"; $from="from@email.com"; $msg=""; $subject="Registers Info for: ".$values["first_name"]." ".$values["last_name"].""; $msg.= "Student: ".$values["first_name"]." ".$values["last_name"]."\r\n"; $msg.= "Absent or Present: ".$values["attendance_status"]."\r\n"; $msg.= "Class: ".$values["classname"]."\r\n"; $msg.= "Class Date: ".$values["attendance_date"]."\r\n"; $msg.= "Amount Received: ".$values["cash_received"]."\r\n"; $msg.= "Paid For: ".$values["cash_whatfor"]."\r\n"; $ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from)); if(!$ret["Sent"]) echo $ret["message"];
Edited February 27, 2020 by leemo Hi, This problem has been driving me crazy all day. I am relatively new to PHP. I basically am trying to populate a database with data from site users. I am using session variables to store their data temporarily as they navigate through the sign up process. A user will input how many 'categories' they wish to populate on page 1. Page 2 will then ask them to specify the details of each category. Eg Category 1: Title, Description, Amount. Category 2: Title, etc. So far I have been able to do this, I now want to store what they have input in session variables. My thoughts were to take the number of categories they have sepcified and create that number of arrays using a loop. Each array will store the details on each category. My code is as follows: Code: [Select] $count=$_POST['count']; //Get how many categories were added //Create an array for each category for ( $counter = 0; $counter <= $count; $counter++){ ${'Categoryarr'.$counter} = array(); }; for ( $counter = 0; $counter <= $count; $counter++){ $Categoryarr[$counter][1]=$_POST['amount_'.$count]; $Categoryarr[$counter][2]=$_POST['desc_'.$count]; $Categoryarr[$counter][3]=$_POST['title_'.$count]; }; When I output the code, I seems to have created the specified number of arrays, but has populated all of them with the same data from the last category. Does anyone know where I am going wrong? Thanks, Bernard Hi, I have a table row that has a dropdown and two textboxes in it. I would like to use a button that allows me to add another row beneath the existing row. It cannot be added to the bottom of the table as there is further content beneath. The content of the dropdown comes from a database query. The dropdown on the new row should have the selection in the first row greyed out. I expect this will need to be a js function but i dont really know where to start with it being dynamic content. This is the table as it stands if this provides clarity of my intentions - picture below echo "<form method='post' id='staffOrderForm'>"; $stmt->close(); echo "<table id='staffOrderTable' class='table table-striped table-bordered mt-3 text-center'>"; foreach($daterange as $date){ echo" <tr> <th class='table-dark' colspan='3'>".$date->format("l - jS F Y")."</th> </tr> <tr> <th class='' colspan='3'>Management </th> </tr> <tr> <th class='col-4'>Name</th> <th class='col-4'>Start Time</th> <th class='col-4'>End Time</th> </tr> <tr> <td> <select class='custom-select managerSelect'>"; $managerRoleId = 1; $stmt = $conn->prepare(" SELECT user_firstname, user_lastname, user_id FROM ssm_user WHERE user_role_id = ? "); $stmt->bind_param("i", $managerRoleId); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($ufn, $uln, $uid); while($stmt->fetch()){echo "<option>".$ufn." ".$uln."</option>";}; echo"</select> </td> <td><input class='form-control' type='' name=''></td> <td><input class='form-control' type='' name=''></td> </tr> <tr> <th colspan='3'>Chefs</th> <tr/> <tr> <th class='col-4'>Name</th> <th class='col-4'>Start Time</th> <th class='col-4'>End Time</th> </tr> <tr> <td> <select class='custom-select chefSelect'>"; $chefRoleId = 2; $stmt = $conn->prepare(" SELECT user_firstname, user_lastname, user_id FROM ssm_user WHERE user_role_id = ? "); $stmt->bind_param("i", $chefRoleId); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($ufn, $uln, $uid); while($stmt->fetch()){echo "<option>".$ufn." ".$uln."</option>";}; echo"</select> </td> <td><input class='form-control' type='' name=''></td> <td><input class='form-control' type='' name=''></td> </tr>"; } echo "</table></form>"; I appreciate that i will likely have to add a button with an onclick but from there i am pretty lost. As always i appreciate the help provided. hey i am using a MySql database and i need to create a dynamic HTML table with one of its columns as checkboxes.so i have to create multiple checkboxes.but these checkbox values are to be stored in a mysql table and then later retrieved when form reloads.and depending on previous state when form was submitted, the newly created checkboxes have to be checked in the same manner.so how do i store multiple checkbox values in my table and also how do i retrieve them? please help. So completely new here.
I've created a database that has 4 fields full_name, company, email and serial_no with 2 sample records.
I would like to create a form with those fields, so the data I enter into the form when I press submit it goes into the database. Config File: <?php $mysqli = new mysqli('localhost', 'username', 'pass', 'database_name'); if($mysqli->connect_error) { echo $mysqli->connect_error; } ?>
Index.php <html lang="en"> <head> <meta charset="UTF-8"> <title>Add Record Form</title> </head> <body> <form action="insert.php" method="post"> <p> <label for="Fullname">Fullname:</label> <input type="text" name="full_name" id="Fullname"> </p> <p> <label for="Company">Company:</label> <input type="text" name="Company" id="Company"> </p> <p> <label for="emailAddress">Email Address:</label> <input type="text" name="email" id="emailAddress"> </p> <p> <label for="Serial">Serial:</label> <input type="text" name="Serial" id="Serial"> </p> <input type="submit" value="Submit"> </form> </body> </html>
Insert.php <?php /* Attempt MySQL server connection. Assuming you are running MySQL server with default setting (user 'root' with no password) */ $link = mysqli_connect("localhost", "username", "pass", "database_name"); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } // Escape user inputs for security $full_name = mysqli_real_escape_string($link, $_REQUEST['full_name']); $company = mysqli_real_escape_string($link, $_REQUEST['company']); $email = mysqli_real_escape_string($link, $_REQUEST['email']); $serial_no = mysqli_real_escape_string($link, $_REQUEST['serial_no']); // Attempt insert query execution $sql = "INSERT INTO licjwe(full_name, company, email, serial_no) VALUES ('$full_name', '$company', '$email', '$serial_no')"; if(mysqli_query($link, $sql)){ echo "Records added successfully."; } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } // Close connection mysqli_close($link); ?>
This is the error I am getting: ERROR: Could not able to execute INSERT INTO database_name(full_name, company, email, serial_no) VALUES ('test', '', 'email@home.com', ''). Table 'table_name' doesn't exist Not sure what I am doing.
Basically I want to have the form so I can enter the data, once its been entered, it lets me know its been successfully updated, then loads the page again.
Please help. Where have I gone wrong?
Hi I have a form that I want people to fill out and then click the button and it sends me an email. My problem is that it doesn't send me any emails, I have looked around and I don't seem to find any thing. This is my form in application_form.php Code: [Select] <form action="application_form" method="POST"> <table border="0" cellpadding="5" cellspacing="0"> <tr> <td>Full name</td> <td><input type="text" size="30" maxlength="80" name="name" /></td> </tr> <tr> <td>Email address</td> <td><input type="text" size="30" maxlength="80" name="email" /></td> </tr> <tr> <td>Message</td> <td><textarea name="message" cols="29" rows="5"></textarea></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="Submit Message" /></td> </tr> </table> </form> and this is the php on the same application_form.php Code: [Select] <?php if (isset($_POST['submit'])) { // Collect variables $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; // Send email $body = "The following feedback has been submitted:\n\n"; $body .= "Name: $name\n"; $body .= "Email: $email\n"; $body .= "Message: $message"; mail ("cerberus478@gmail.com","Feedback Received",$body,"From: cerberus478@gmail.com"); // Output confirmation echo "<p>Your message has been received.</p>"; } ?> 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 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! 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? |