PHP - Emailing Files, Using Temporary Name Instead Of Storing Before Hand.
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"; } ?> Similar TutorialsHi Guys I trying to download files and I have this error message, hopelly you guys can help me please
Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 14 Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 15 Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 16 Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 17 Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 18 This is the code I use to force the download <?php include('core/inc/init.inc.php'); if(isset($_GET['file_id'])) { $file_id=(int)$_GET['file_id']; $file=mysql_query("SELECT file_name, file_expiry FROM files WHERE file_id=$file_id"); if(mysql_num_rows($file)!=1){ echo'Invalid file Id'; }else{ $row=mysql_fetch_assoc($file); if ($row['file_expiry']<time()){ echo'This file has expired'; }else{ $path="core/files/{$row['$file_name']}"; header('Content-Type:application/octet-stream'); header('Content-Description:File Transfer'); header('Content-Transfer-Encoding:binary'); header("Content-Disposition:attachment;filename=\"{$row['file_name']}\""); header('Content-Length:'.filesize($path)); readfile($path); } } } ?>Thank you for your help..... 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 want to store a series of data which are called in a main php file. Do you suggest to store them in xml as file1.xml: <title>TITLE</title> <content>CONTENT</content> or file1.php: $title="TITLE"; $content="CONTENT"; AND is it better to create separate file for each article or storing all data in one single file? Hi, I am having a wierd problem and I dont know what is causing it - PHP/MySql.? Server - Apache on Fedora Php - 5.3.2 MySql - 5.1.47 In the same server config I have implemented storing files into blob fields any type of file by using mysql as well as mysqli. The one implemented by mysql is working just fine. But the one using mysqli is not working for anything other than text files. For image files the following error is coming - Error interpreting JPEG image file (Not a JPEG file: starts with 0x0a 0xff) For word/pdf etc the files are getting corrupted in such a way that the concerned application is not recognising it as a valid document. /*MySQL using mysql_connect Storing*/ $name=trim($_POST['fname']); $desc=trim($_POST['description']); $file=$_FILES['formfile']['name']; $filetype=$_FILES['formfile']['type']; $filename=$_FILES['formfile']['tmp_name']; $fileerror=$_FILES['formfile']['error']; $filesize=$_FILES['formfile']['size']; $fp = fopen($filename, 'r'); $content = fread($fp, filesize($filename)); fclose($fp); if (!get_magic_quotes_gpc()) { $content = addslashes($content); $name=addslashes($name); } $query="insert into forms_master (name, description, data, filename, filesize, filetype, entrydate) values ("; $query.="'$name', '$desc', '$content', '$file', '$filesize', '$filetype', now())"; /*Retreiving*/ $id=$_GET[sha1('id')]; $form=mysql_fetch_array(mysql_query("select filename, filesize, filetype, data from forms_master where sha1(id)='$id'", $link)); header("Content-length: ".$form['filesize']); header("Content-type: ".$form['filetype']); header("Content-Disposition: attachment; filename=".$form['filename']); print $form['data']; Works absolutely fine /*MySQL using mysqli_connect Storing */ $file=$_FILES['fname']; $name=$file['name']; $tmp_name=$file['tmp_name']; $size=$file['size']; $type=$file['type']; $fp = fopen($tmp_name, 'r'); $content = fread($fp, filesize($tmp_name)); fclose($fp); $content = mysqli_real_escape_string($link, $content); $name=mysqli_real_escape_string($link, $name); $query="insert into document_master (name, size, filetype, data) values ('$name', '$size', '$type', '$content')"; //Retreiving $id=$_GET[sha1('id')]; $file=mysqli_fetch_array(mysqli_query($link, "select name, size, filetype, data from document_master where sha1(id)='$id'")); header("Content-type: ".$file['filetype']); header("Content-length: ".strlen($file['size'])); header("Content-Disposition: attachment; filename=".$file['name']); print $file['data']; Note. I uploaded an image file through phpMyAdmin. Then tried to retreive it via the mysqli code above. The same error came. Any help will be greatly appreciated. My users table on my forum is what gets checked everytime a user refreshes to authentic them.
When killing a monster, I want users to be able to grab items and it will insert them into their inventory. I have this part done already. But I want them to have a plethora of loot available that drops from a mob, and once they click the specific item it will then be inserted into their inventory (server database).
I'm storing the Temporary Item Data in a PHP session variable. Once they kill a monster, the Tempory Item Data variable get's filled with the specific loot and then the user will have the option to choose what items they want to go into their inventory.
My problem is, if they open the game in a new browser they will get a new session id. Since I'm authenticating them through my users table, can I just make a new column called session_id and just use php's session_id() before every session start so no matter which browser they're on they will have the same session right?
You might think, well why dont you just store the temporary item data in a mysql field or rows instead? I want to try to minimize mysql usage as much as possible, as players will be CLICKING a lot to kill mobs, it is most likely very mysql demanding as well and I want to be intuitive about it. I just want to use temporary session data for the loot. Then once the user clicks an item they want, it is EXTRACTED from their tempory item data variable, then I will use MYSQL to insert those items into their inventory.
Is this a fair and intuitive way to do temporary data for item loot? For example, in action RPG's like Path of Exile you kill a group of mobs and you see a shit ton of loot on the floor. (I imagine that loot is just temporary waiting for someone to pick it up right?) Once you do pick it up, mysql is then called to save it right? That's the same logic I have with my web based game. Is using a session variable to store that temporay loot.
Is this an intuitive way to do this, or are there other ways?
Edited by Monkuar, 24 November 2014 - 01:24 AM. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=345265.0 After the file gets uploaded, I intend the file to become renamed, and then moved to its destination folder. Though to move the file, I need the newly renamed file name and also its location, which is the temporary folder, and the latter describes my question. This is the script as follows: Code: [Select] $avatar_tmp = $_FILES['avatar_upload']['tmp_name']; // Rename the file into a more usable file name $new_file_name = $user_name . '_' . rand(111111, 999999) . '.jpg'; rename($avatar_tmp, $new_file_name); // Move the uploaded file on the disk to its folder // The directory of the temporary folder is needed in front of the new_file_name variable move_uploaded_file ($new_file_name, $target); The directory of the temporary folder is needed in front of the new_file_name variable and my question is, is there any function, to get the directory of the temporary folder for the uploaded file? So I can insert it in front of the new_file_name variable and move it out of the folder to its destination folder? Can anyone tell me, how the temporary file names (name of the file which is created in the 'tmp' dir ) generated by PHP when the files are uploaded ? Are there any algorithms used ? I'm using a popular PHP script for my web site, which uses main_1.htm for the header and footer, and inner_index.htm for the main part of the home page. Also, of course it has index.php. How can I set up a duplicates of these files to work on and test changes to the home page, before I actually deploy the changes on to my live site's home page? Thanks Ok here is what i got so far and now I am stuck. The user enters a number of how many squares (rectangles is note accurate) they wish to calculate. If its between 1 and 100 it continues, if its any other number it tells you to put in a number between 1 and 100. That was easy for me to do. If the number is between 1 and 100 it creates and input for length, width and height of each rectangle. creating the variables as it goes, i.e. "length$i" when $i is the while counter and increases to the ammount of rectangles you wished to view. Again, not that hard for me. So I am at the point where is I put in 50 I get length1 - through length30, width1 - width50, and height1 - height50. THis works great. However I now what to store those variables and calculate the area of each one via a while look which again creates an area$i variable which can be added (it would create area1 - area50 which I then wish to add together) Here is what I have so far. <?php session_start(); if (isset($_REQUEST['numpack'])) { if ($_REQUEST['numpack'] <= 0 || $_REQUEST['numpack'] > 100 ) { $error = "Please enter a number between 1 and 100"; echo $error; ?> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <table width="0" border="0" cellspacing="5" cellpadding="5"> <tr> <td colspan="2">How many Squares</td> </tr> <tr> <td> <input name="numpack" type="text" size="4" maxlength="3"></td> <td><input type="submit" name="button" id="button" value="Submit"></td> </tr> </table> </form> <?php } else { ?> <form name="form2" method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <?php $i=1; while($i<=ceil($_REQUEST['numpack'])) { ?> <table width="325" border="0" cellspacing="5" cellpadding="5" style="float: left;" class="aluminium"> <tr> <td align="center" rowspan="2"><span class="transparent" style="color: #FFF; font-weight: bold;"><?=$i; ?>.</span></td> <td align="center">L</td> <td align="center">x</td> <td align="center">W</td> <td align="center">x</td> <td align="center">H</td> </tr> <tr> <td align="center"><input name="length<?=$i; ?>" type="text" size="4" maxlength="3"></td> <td align="center">x</td> <td align="center"><input name="width<?=$i; ?>" type="text" size="4" maxlength="3"></td> <td align="center">x</td> <td align="center"><input name="height<?=$i; ?>" type="text" size="4" maxlength="3"></td> </tr> </table> <?php $i++; } ?> </form> <?php } } If (!isset($_REQUEST['numpack'])) { ?> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <table width="0" border="0" cellspacing="5" cellpadding="5"> <tr> <td colspan="2">How many Squares</td> </tr> <tr> <td> <input name="numpack" type="text" size="4" maxlength="3"></td> <td><input type="submit" name="button" id="button" value="Submit"></td> </tr> </table> </form> <?php } ?> Now I was reading up on session data and think this might be the best way to go, but again how do I do this? and two I want to make sure that if there are 2 people accessing it at the same time, it does not change the variables on them... (i.e. user one puts in 50 values, and user two puts in 50 different values I do not want cross contamination) Any ideas on how to proceed? I have this interesting problem, I think I know how to do it.
In a java class I took there was a lab on swapping the values of variables and if there were two variables, you needed a third temporary value holder.
So this project I'm working on has a row output, currently the individual values are outputted as a concatenated string but ideally they would be independent rows with accompanying buttons.
One of those buttons is a ^ symbol, when you press this, ideally the row is moved up in ID putting the previous ID in front or ahead.
The problem is that the ID's / rows are not necessarily in sequential order.
So, when I recall a set of rows that have random sequential values for example, 2, 5, 27, 41, 43
and those are outputted by themselves, now becoming 0,1,2,3,4 respectively or 1,2,3,4,5
So when I try to move 43 to position 2, that's 4 positions away or 4 clicks of the ^ button.
Now how do you deal with that 4 difference and the difference of 41... ? thereby, when the initial set of rows are recalled again, the order is now, 43, 5, 27, 41, 2 Of course the ID I think remains the same but the data is switched... ? yeah I have to draw some pictures, but this isn't a current problem to fix, later on down the road after I update the interface.
here is a drawing to explain, I'm more of a visual person
wp_20150112_05_27_16_pro.jpg 59.67KB
0 downloads
Any ideas would be appreciated, otherwise I will post my solution when I come to it. Or I don't figure it out and find one.
thanks
Bear with me, as I'm still quite new at PHP. I'm trying to figure out the best way to build a search function for a database that will eventually be quite large. The path of the search I'm building is to go from a straight-forward javascript and html search page, to a paginated search result. Then the user can narrow down those query results based on a new search of their results. In trying to get the pagination to work across several pages(unsuccessfuly, I might add), I've been learning about sessions and temporary tables. But, because the database will be very large, I'm wondering if they are the wrong way. Sessions have a time limit, and temporary tables delete once the connection is closed. Is it possible/feasible to build a permanent table that puts in the search variables, with a unique id and use this to manage the searches, pagination and all that? Then, at some point in the process, I can put code to delete the corresponding row (or even make it a saveable search). Maybe somebody sees where I'm going with this and can describe it better than me? I'm just thinking off the cuff at the moment. Maybe there's some terminology that will help me find a tutorial. Any bit helps. thanks! Hello folks, well what I mean by temporary variables are variables like error messages or success messages that appear after a form has been submitted. I want to be able to kill these variables when the page is refreshed and return the page to its defualt state. For example, I'm making this simple page which is basically a form that ask users for some information, then upon submit, stores the in a database and prints a success message. If the form is filled out incorrectly or some form fields are left blank, then error messages are printed. What I really want is for these messages to disappear when the page is refreshed. My current model uses a second page to handle the form, and then upon succes or upon encountering an error, redirects to the form page, passing the error or success variables via the url to the form page where they are printed out. What can I do differently to achieve what I want (ie kill variables upon page refresh)? Below are the form page, and the page that handles the form respectively. Code: [Select] <form method="post" action="send_email.php"> <div id="contact_form"> <div align="left" class="green18">Contact Us</div> <br/> <br/> <label>Your Name:</label> <input class="texta" name ="name" size="20" maxlength="49"/> <br/> <br/> <div class ="error" style="position:relative;bottom:40px;left:128px" > <?php //Retrieve the encoded errors string from send_email.php page $errors_string=$_GET['errors_string']; //Explode the decoded errors string back to an array. $errors = explode(",", $errors_string); echo $errors[0];?> </div> <label>Your Company Name:</label> <input class="texta" name ="company" size="30" maxlength="66"/> <br/> <br/> <div class ="error" style="position:relative;bottom:40px;left:128px" > <?php //Retrieve the encoded errors string from send_email.php page $errors_string=$_GET['errors_string']; //Explode the decoded errors string back to an array. $errors = explode(",", $errors_string); echo $errors[1];?> </div> <label>Subject(Optional):</label> <input class="texta" name ="subject" size="20" maxlength="49"/> <br/> <br/> <label>Email:</label> <input class="texta" name ="email" size="20" maxlength="49"/> <br/> <br/> <div class ="error" style="position:relative;bottom:40px;left:128px" > <?php //Retrieve the encoded errors string from send_email.php page $errors_string=$_GET['errors_string']; //Explode the decoded errors string back to an array. $errors = explode(",", $errors_string); echo $errors[2];?> </div> <label>Message:</label> <textarea style="float:left" class="" name ="message" cols="40" rows="3"> </textarea> <br/> <br/> <div class ="error" style="position:relative;bottom:-19px;left:-260px" > <?php //Retrieve the encoded errors string from send_email.php page $errors_string=$_GET['errors_string']; //Explode the decoded errors string back to an array. $errors = explode(",", $errors_string); echo $errors[3];?> </div> <button class="button" type ="submit" name ="submit">Submit</button> <br/> <div id ="sent" > <?php //Retrieve the user id from send_email.php page $sent=$_GET['sent']; $send_msg = urldecode($sent); echo $send_msg; ?> </div> <!--closes sent--> </div> </form> Code: [Select] <?php //address error handling ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); if (isset($_POST['submit'])) { $errors = array(); // Connect to the database. require('config/config.php'); //Check for errors. //Check to make sure they entered their name and it's of the right format. if (eregi ("^([[:alpha:]]|-|')+$", $_POST['name'])) { $a = TRUE; } else { $a = FALSE; $errors[0] = '*Please enter a valid name.'; } //Check to make sure they entered their company name. if (!empty ( $_POST['company'])) { $b = TRUE; } else { $b = FALSE; $errors[1] = '*Please enter company name.'; } //Check to make sure email is valid. if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) { $c = TRUE; }else { $c = FALSE; $errors[2] = '*Please enter a valid email address.'; } //Check to make sure they entered their message. if (!empty ( $_POST['message'])) { $d = TRUE; } else { $d = FALSE; $errors[3] = '*Please enter your message.'; } //If no errors if (empty($errors)) { //Create variables for all the post values. $name = $_POST['name']; $company = $_POST['company']; $email = $_POST['email']; $message = $_POST['message']; $ip = $_SERVER[REMOTE_ADDR]; $date = (date("Y/m/d:G:i:s")); $timestamp = ( mktime(date(H), date(i), date(s), date(m) , date(d) , date(Y))); //Formulate the insert query. $query = "INSERT INTO emails ( email_id, name, company, email, message, ip, date,timestamp) VALUES ( 0, '$name','$company','email', '$message', '$ip' , '$date', '$timestamp' )"; $result = mysql_query($query) or die("Data could not be inserted into table because: " .mysql_error()); if (mysql_affected_rows() == 1) { // Display success message $sent_msg = "Your email has been sent. We will get back to you shortly."; $sent = urlencode($sent_msg); // Display contact page header("Location: contact_page.php?sent=$sent"); exit(); }else{die("There was a problem: " . mysql_error());} //Display error messages. } else {// if errors array is not empty //Confer the errors array into a string $errors_string = implode(",", $errors); //Encode the imploded string. $error_message = urlencode($errors_string); // Display page header("Location: contact_page.php?errors_string=$errors_string"); exit(); }//End of if there are errors. }//End of if submit. ?> Also, another problem I just noticed is that, the errors[3] variable isn't getting passed back to the form page. I don't know if it's because the url can only pass so much info to a second page. The page in question can be located he http://creativewizz.com/contact_page.php 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>"); } ?> 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 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 ; ?> |