PHP - Sending Php Results To The End User Through Email
I want to do something like this,
I had a html query submission form linked to php.
I want to send the output generated after php execution to the user through mail id provided in the form, in a manner such that when user click submit button, he well be redirected to thank you page and php keeps on running in the background and as soon as the output is generated, it will be send to the end user through email. As my query takes time to execute, so I don't want the end user to keep waiting till the program gets finish.
Here is my code:
<?php
$seq = $_POST['seq']; if (isset($_POST['seq'])) { $b = fopen("sequence.txt", "w"); fwrite($b, $seq); fclose($b); system("perl /opt/lampp/htdocs/matepred/blast/bin/scriptforblastcompleterun.pl sequence.txt nr > out"); system("perl /opt/lampp/htdocs/matepred/blast/bin/format.pl > output"); system("perl /opt/lampp/htdocs/matepred/blast/bin/testing.pl output"); echo "<div align='center'><font color='blue'><b>RESULT</font></div>"; $i=1; $files = array(); foreach (glob("file_*.out")as $file) { $files[] = $file; $b = fopen("/opt/lampp/htdocs/matepred/blast/bin/$file", "r"); $s=fgets($b); fclose($b); echo "<table border=10. align=center><tr bgcolor=lightgreen><th>SerialNo</th><th>Value</th><th>Decision</th><th></tr>"; echo '<td>'. $i++. '</td>'; echo "<td>$s</td>"; if($s>=0) { echo "<td>Yes</td>"; } else { echo"<td>No</td>"; } echo "</table>"; } } ?> html table part marked in red here is the output which I want to send back to the user. Can anybody help me in linking my php output to the mail. Thanks in advance. Similar Tutorialshi all, im working on a email send to de user who register on the website! now i get the email but its not email/html view and it gets in to the unwanted folder, also as i siad trust this emailadress! what do i wrong in the code?? the whole php file see //#### XXX ### where i need help! Code: [Select] <?php Session_start(); if(file_exists("support/functions_alg.php")) // user,pass and database file { include("support/functions_alg.php"); // database functions file } if($_REQUEST) { $email=$_REQUEST['email']; $pass=md5( $_REQUEST['pass'] ); $secc=md5( $_REQUEST['sec_code'] ); function check_code($secc) { if($secc == $_REQUEST['mdcode']) { return true; } else { return false; } } function check_email_address($email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } if(check_email_address($email)) { if(check_code($secc)) { //$res=register($email,$pass,$name,$address,$huisnr,$zipcode,$plaats,$dob_year,$dob_month,$dob_date,$tel); $res=true; if($res==true) { // ##### XXX ##### //mail function /* subject */ $subject = "Activeer uw Profiel"; /* To send HTML mail, you can set the Content-type header. */ $headers = "MIME-Version: 1.0 \r\n"; $headers .= "Content-type: text/html; charset=utf-8 \r\n"; /* additional headers */ $headers .= "From: " . $mailme . " \r\n"; /* and now mail it */ $text = ' <html> <head> <title>Nieuw profiel</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> Activeer uw profiel op:<br><br> <a href="http://'.$_SERVER['SERVER_NAME'].'/?reg_result&activatie=true">Activeer</a>br><br> Veel plezier op onze website! </body> </html>'; $res = mail($email,$subject,$text,$headers); echo("<script>document.location.href='index.php?topic=reg_result&".$res."'</script>"); //header('location: "'.$_SERVER['HTTP_REFERER'].'?topic=reg_result&true"'); //###### XXXX ####### } else { echo "<table border=1 class=outer_tbl align=center width=50% style='border-collapse:collapse;'>"; echo "<tr><td align=center>"; echo "Fout tijdens registratie<br><a href='javascript:history.back();'>Klik hier</a> om opnieuw te proberen"; echo "</tr></td></table>"; } } else { echo("<script>document.location.href='".$_SERVER['HTTP_REFERER']."&error=code'</script>"); //header('location: "'.$_SERVER['HTTP_REFERER'].'&error=code"'); } } else { echo("<script>document.location.href='".$_SERVER['HTTP_REFERER']."&error=email'</script>"); //header('location: "'.$_SERVER['HTTP_REFERER'].'&error=email"'); } } ?> the recived email looks like : Content-type: text/html; charset=utf-8 From: info@pc-hulp-online.nl Return-Path: anonymous@server70.hosting2go.nl X-OriginalArrivalTime: 30 Apr 2012 10:47:41.0985 (UTC) FILETIME=[AB19D110:01CD26BE] <html> <head> <title>Nieuw profiel</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> Activeer uw profiel op:<br><br> <a href="http://nieuw.pc-hulp-online.nl/?reg_result&activatie=true">Activeer</a>br><br> Veel plezier op onze website! </body> </html> please help me!! thnx, Hi, I want to create a forgotten password page, where the user enters in their email address, the script queries the database for that email address, creates a unique ID, stores that unique ID in the database, then emails the unique ID and the User ID off to the user in an HTML link e.g. http://somesite.com/reset-password.php?userId=2&uniqueId=132832189312978312. The reset page would then match the unique ID to the one in the database and let them enter in a new password into the form. Ok so I can do most of that so far except from the emailing to the user. I'm running an Ubuntu Server 10 at the moment as my test server which is on my local network. Do I need to set up a mail server on that for php mailing to work, or can I use some external SMTP for sending? I've had a play round with the PHP mail() function but it won't send anything at the moment. I'll also need some code for when the site is running in the hosted live environment as it will likely use their mail servers. What's the best way to go about doing this? Many thanks! From our website we are connecting to GMAIL to send our emails through SMTP. For some reason it is not sending the emails to the CC or BCC email address event though GMAIL shows it was included in the email. Am I missing something in the below code? Code: [Select] $currentTime = time(); $emailTo = "redbrad0@domain.com"; $emailCC = "brad@domain.com"; $emailBCC = "events@domain.com"; $emailSubject = "TEST Email at (" . $currentTime . ")"; $emailBody = "This is the body of the email"; $headers = array(); if (!empty($emailTo)) $headers['TO'] = $emailTo; if (!empty($emailCC)) $headers['CC'] = $emailCC; if (!empty($emailBCC)) $headers['BCC'] = $emailBCC; if (!empty($emailSubject)) $headers['Subject'] = $emailSubject; $headers['From'] = "events@domain.com"; $mime = new Mail_mime("\n"); $mime->setTXTBody($emailBody); $body = $mime->get(); $headers = $mime->headers($headers); $mail = Mail::factory('smtp', array ('host' => 'ssl://smtp.gmail.com', 'auth' => true, 'port' => 465, 'username' => 'events@domain.com', 'password' => 'thepasswordhere')); try { $result = $mail->send($emailTo, $headers, $emailBody); } catch (TixException $ex) { echo "<font color=red>Error:" . $ex->getCode() . "</font><br>"; } echo "Emailed at (" . $currentTime . ")<br>"; die; Everything about the email is sending except the message text does anyone know what the issue could be? here is the block of code that sends the email Thanks in advance Code: [Select] $image = "http://www.visualrealityink.com/dev/clients/arzan/snell_form/images/email.png"; echo "got to process form"; $target_path = "upload/"; $path = $target_path = $target_path . basename( $_FILES['file']['name']); $boundary = '-----=' . md5( uniqid ( rand() ) ); $message .= "Content-Type: application/msword; name=\"my attachment\"\n"; $message .= "Content-Transfer-Encoding: base64\n"; $message .= "Content-Disposition: attachment; filename=\"$path\"\n\n"; echo $path; $fp = fopen($path, 'r'); do //we loop until there is no data left { $data = fread($fp, 8192); if (strlen($data) == 0) break; $content .= $data; } while (true); $content_encode = chunk_split(base64_encode($content)); $message .= $content_encode . "\n"; $message .= "--" . $boundary . "\n"; $message .= $image . "<br />" . $_POST['name'] . "submitted a resume on our website. Please review the applications and contact the candidate if their resume is a fit for any open opportunities with the company. <br><br> Thank you. <br><br> SEI Team"; $headers = "From: \"Me\"<me@example.com>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\""; mail('george@visualrealityink.com', 'Email with attachment from PHP', $headers, $message); Hi the user fill details and then the email his sent to me the only problem is that the emails keeps going to my spam, can someone help me out please I looked already php website and email format looks the same. This is the link to my form. http://www.people.eurico.co.uk/ here my form script Code: [Select] <?php // Set email variables $email_to = 'xxxxx@xxxxxxx.co.uk'; $email_subject = 'Call back form'; // Set required fields $required_fields = array('fullname','email','telephone','comment'); // set error messages $error_messages = array( 'fullname' => 'Please enter a Name to proceed.', 'email' => 'Please enter a valid Email.', 'telephone' => 'Please telephone.', 'comment' => 'Please enter your Message to continue.' ); // Set form status $form_complete = FALSE; // configure validation array $validation = array(); // check form submittal if(!empty($_POST)) { // Sanitise POST array foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value)); // Loop into required fields and make sure they match our needs foreach($required_fields as $field) { // the field has been submitted? if(!array_key_exists($field, $_POST)) array_push($validation, $field); // check there is information in the field? if($_POST[$field] == '') array_push($validation, $field); // validate the email address supplied if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field); } // basic validation result if(count($validation) == 0) { // Prepare our content string $email_content = 'peoplesmartlearning.co.uk: ' . "\n\n"; // simple email content foreach($_POST as $key => $value) { if($key != 'submit') $email_content .= $key . ': ' . $value . "\n"; } // if validation passed ok then send the email mail($email_to, $email_subject, $email_content); // Update form switch $form_complete = TRUE; } } function validate_email_address($email = FALSE) { return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE; } function remove_email_injection($field = FALSE) { return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field)); } ?> The HTML Code: [Select] <div class="call_us_form"> <p class="title">WE'LL CALL YOU BACK</p> <?php if($form_complete === FALSE): ?> <form class="contact_form" id="fm-form" method="post" action="index.php" > <fieldset> <div class="fm-req"> <label for="fm-firstname">Name</label> <input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" /> <?php if(in_array('fullname', $validation)): ?><script type="text/javascript">alert("Please enter a Name"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-firstname">Email</label> <input type="text" id="email" class="detail" name="email" value=" <?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /> <?php if(in_array('email', $validation)): ?><script type="text/javascript">alert("Please enter a valid Email Address"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-firstname">Number</label> <input type="text" id="telephone" class="detail" name="telephone" value="<?php echo isset($_POST['telephone'])? $_POST['telephone'] : ''; ?>" /> <?php if(in_array('telephone', $validation)): ?><script type="text/javascript">alert("Please enter telephone number"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-lastname">Message</label> <textarea cols="40" rows="5" id="comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea> <?php if(in_array('comment', $validation)): ?><script type="text/javascript">alert("Please enter your message"); history.back();</script><?php endif; ?> </div> <input class="submit_button" type="submit" value="Call us" /> </fieldset> </form> <?php else: ?> <p>Thank you for your Message!</p> <p>We will get back to you as soon as we can</p> <script type="text/javascript"> setTimeout ('ourRedirect()', 5000) function ourRedirect () { location.href='index.php' } </script> <?php endif; ?> Code: [Select] $sql="SELECT * FROM $tbl_name3 WHERE review_show='n'"; $result=mysql_query($sql); $num_results=mysql_num_rows($result); if($num_results > 1){ $message="You have ".$num_results." reviews unapproved."; mail('example@example.com','GHP Reviews', $message, 'From: example@example.com'); } $sql2="SELECT * FROM $tbl_name4 WHERE rma_issued='n'"; $result2=mysql_query($sql2); $num_results2=mysql_num_rows($result2); if($num_results2 > 1){ $message="You have ".$num_results2." RMA Numbers Requested."; mail('example@example.com','GHP RMA Number Requests', $message, 'From: example@example.com'); } The reviews email is being sent, however, the RMA email is not. EDIT: Nevermind, $num_results and $num_results2 should have been > 0 not > 1. Actually, what i want to do is to use the email to fetch the $email,$password and $randomnumber from database after Hello there, I have run into a problem. I have a search box, which searches through my database and gets results hopefully. But I need to be able to print the list. There is the problem. If I just print the page, it does not print the results. Here is the search.php with the php and the current print javascript. -Search By Address or Postcode-<br> <form name="search" method="post" action="search.php" id="searchform"> Query: <input type="text" name="name"> <input type="submit" name="submit" value="Search"></form> <br><br> -Search By REFID-<br> <form name="search2" method="post" action="search.php" id="searchform2"> Query: <input type="text" name="name2"> <input type="submit" name="submit2" value="Search"></form> <br><br> <?php if(isset($_POST['submit'])){ if($_POST['name'] > NULL){ $name=$_POST['name']; $sql="SELECT * FROM propertyaddress WHERE `address 1` LIKE '%" . $name . "%' OR `postcode` LIKE '%" . $name ."%'"; //-run the query against the mysql query function $result=mysql_query($sql); //-create while loop and loop through result set ?> <SCRIPT LANGUAGE="JavaScript"> if (window.print) { document.write('<form>' + '<br><input type=button name=print value="Print Results" ' + 'onClick="javascript:window.print()"></form>'); }</script> <script language="javascript" type="text/javascript"> <?php while($row=mysql_fetch_array($result)){ echo "<ul>\n"; echo '<a href="display.php?id='.$row['id'].'">'.$row['address 1'].', '.$row['address 2'].' at '.$row['postcode'].'</a><br>'; echo "</ul>"; } } else{ echo "<p>Please enter a search query</p>"; } } I'm at a lost. I'm not sure what to do, I don't think the code as anything to do with printing, but I put it there just in case. I thought about writing it to a temp html page in a popup, but I don't really no how to do that really well. I appreciate any help or suggestions you give. Hi Guys I am creating a site which allows the registration of new users. I already have my user registration page up and running which is lnked to my database. I would now like to add a function which will send a 'welcome to...' email to the email address provided on the registration form provided by the new user. Could anybody please point me in the right direction i.e where to start? I am using dreamweaver and Cpanel. Thanksin advance Hi, I want to send an email to my registered users so that when they click on the URL given in the message hey should come back to my site as confirmetion of their registration. I am able to send the mail but the mail body is not coming as expected. Here's my code Code: [Select] <?php public function email($id){ //get users info $this->userInfo = $this->model->listUser($id); $this->sendEmail($this->userInfo); } public function sendEmail($data){ $to =$data['email']; $this->msg ="<img src=\"ideas.kpjit.com/public/images/header-img.jpg\" /> <h1>KPJ Idea</h1> <p>Make a difference</p> <p>This is a Confirmation Mail.Please confirm your registration by clicking here <a href=\"http://ideas.kpjit.com\register\confirm\ <?php echo $this->data['id'];?></p>\" "; $subject = "Registration confirmation"; $message = $this->msg; $from ="narjisfatima@yahoo.com"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From:narjisfatima@yahoo.com' . "\r\n"; if(mail($to,$subject,$headers)){ $this->render2("register/message"); exit; } } Also I am unable to insert my site banner in the mail. How can I do It. I need some help over here. I want to send an email to my friends by checking the database and extract the id. After extracting the id from the database, i want to include a URL with the id. E.g. www.abc.php?35 (35 is the id) www.abc.php?40 (40 is the id) May I know how to send an email with multiple url? Is it using a for loop in the php email function? Your help is greatly appreciated. this is a forgot password page and this email script will not send Code: [Select] <?php $emailcut = substr($email, 0, 4); // Takes first four characters from the user email address $randNum = rand(); $tempPass = "$emailcut$randNum"; $hashTempPass = md5($tempPass); @mysql_query("UPDATE myMembers SET password='$hashTempPass' where email='$email'") or die("cannot set your new password"); include('Mail.php'); include('Mail/mime.php'); // Constructing the email $sender = "Social network"; // Your email address $recipient = "$email"; // The Recipients name and email address $subject = "Reset Your Password"; // Subject for the email $text = 'This is a text message.'; // Text version of the email $html = "<html><body><div align=center><br>----------------------------- New Login Password --------------------------------<br><br><br> Your New Password for our site is: <font color=\"#006600\"><u>$tempPass</u></font><br><br /> </div></body></html>"; // HTML version of the email $crlf = "\n"; $headers = array( 'From' => $sender, 'Return-Path' => $sender, 'Subject' => $subject ); // Creating the Mime message $mime = new Mail_mime($crlf); // Setting the body of the email $mime->setTXTBody($text); $mime->setHTMLBody($html); // Add an attachment // Set body and headers ready for base mail class $body = $mime->get(); $headers = $mime->headers($headers); // SMTP authentication params $smtp_params["host"] = "smtp.gmail.com"; $smtp_params["port"] = "587"; $smtp_params["auth"] = true; $smtp_params["username"] = "activate.social@gmail.com"; $smtp_params["password"] = "pass"; // Sending the email using smtp $mail =& Mail::factory("smtp", $smtp_params); $result = $mail->send($recipient, $headers, $body); if (PEAR::isError($mail)) { $outputForUser = '<font color="#FF0000">Password Not Sent.<br /><br /> Please Contact Us...</font>'; } else { $outputForUser = "<font color=\"#006600\"><strong>Your New Login password has been emailed to you.</strong></font>"; } } } else { $outputForUser = 'Enter your email address into the field below.'; } ?> Can someone help me understand why an email isn't being sent after clicking submit? Code: [Select] <?php error_reporting(E_ALL); ?> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php extract ($_POST); if(!isset($submit)) { ?> <form action=" " method="post" name="test"> Name: <input name="name " type="text" id="name " size="8" /><br /> phone <input name="phone" type="text" size="13" /><br /> email <input name="email" type="text" size="9" maxlength="30" /><br /> <input name="submit" type="submit" value="submit" /> </form> <?php $Recipient = "$email"; $MsgSubject = "message subject"; $MsgHeader = "From Auntie Vic's Treatery <auntievics@gmail.com>\r\n"; $MsgBody = "message body."; mail($Recipient, $MsgSubject, $MsgBody, $MsgHeader); } else { echo " thank you for your order. It is being processed. Thank you for your business."; } ?> </body> </html> I am creating a forgotten password button, it works but it just doesn't send me an email containing the reset link.
Here's the code for the email part:
<?php require("../config.php"); if($_GET['code']) { $get_username = $_GET['username']; $get_code = $_GET['code']; $query = mysql_query("SELECT * FROM users WHERE username='$get_username'"); while($row = mysql_fetch_assoc($query)) { $db_code = $row['passreset']; $db_username = $row['username']; } if($get_username == $db_username && $get_code == $db_code) { echo " <form action='pass_reset_complete.php?code=$get_code' method='POST'> Enter a new password<br><input type='password' name='newpass'><br> Re-enter your password<br><input type='password' name='newpass1'><p> <input type='hidden' name='username' value='$db_username'> <input type='submit' value='Update Password!'> </form> "; } } if(!$_GET['code']) { echo " <form action='forgot_pass.php' method='POST'> Enter your username<br><input type='text' name='username'><p> Enter your email<br><input type='text' name='email'><p> <input type='submit' value='Submit' name='submit'> </form> "; if(isset($_POST['submit'])) { $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query("SELECT * FROM users WHERE username='$username'"); $numrow = mysql_num_rows($query); if($numrow!=0) { while($row = mysql_fetch_assoc($query)) { $db_email = $row['email']; } if($email == $db_email) { $code = rand(10000,1000000); $to = $db_email; $subject = "Password Reset"; $body = " This is an automated email. Please DO NOT reply to this email. Click the link below or paste it into your browser http:/www.***REMOVED***.com/second/forgot_pass.php?code=$code&username=$username "; mysql_query("UPDATE users SET passreset='$code' WHERE username='$username'"); mail($to,$subject,$body); echo "Check Your Email"; } else { echo "Email is incorrect"; } } else { echo "That username doesnt exist"; } } } ?> Hello Guys I just want to ask if I will send email using php syntax do I need to configure the php ini settings? Any ideas how to configure it? Your usual cooperation is highly appreaciated. God Bless.. Hi
I have below code :
<?php $_SERVER['SERVER_NAME']; $to = "info@domain.com"; $subject = "Test mail"; $body = $_SERVER['SERVER_NAME']; $from = "user@example.com"; $headers = "From:" . $from; mail($to, $subject, $body, $headers) ?>the email is sent correctly but without any body text . I use $_SERVER['SERVER_NAME']; but nothing show as body . I want to use this code load each day becuse I want to know which domain is used my script. but now the code not work. this is my email.php file <?php $senderName =$_POST['userName']; $senderEmail =$_POST['userEmail.']; $senderMessage =$_POST['userMessage.']; //security $senderName=stripslashes($userName); $senderEmail=stripslashes($userEmail); $senderMsg=stripslashes($userMessage); $to = 'myName@mydomain.com'; $from = 'myName@mydomain.com'; $subject = 'Testing CONTACT PAGE'; $message = 'Message From your site: Their Name: $senderName Their Email: $senderEmail Their Message is below: $senderMsg'; // Build $headers Variable $headers = 'From: Company <mysite@mydomain.com.com>' . "\r\n"; $to = '$to'; // Send the email mail($to, $subject, $message, $headers); $my_msg='thanks your message has been sent.'; print $my_msg; ?> The error I'm getting is this: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\PHP_Test\email.php on line 5 all I want to be able to do is verify my form works and that I can receive emails from users of mysite any help would be greatly appreciated. Also what should the send_mail in the PHP.INI file be set to? thansk Hey guys, Coding something for a survey as no solution exists for our needs. I have not finished the code as I still need to do error checks + making it spam proof. Anyway I am not reciving the email even though it says that I have been sent it. Any suggestions are appreciated, please ask if you need additional info to be able to help, and thank you in advanced. Code: [Select] <?php error_reporting(0); if(isset($_POST['submit'])){ //Check that all fields that are mandatory are filled in and that the $Email variable is real $Title = $_POST['Title']; $FirstName = $_POST['FirstName']; $LastName = $_POST['LastName']; $Email= $_POST['Email']; $Country= $_POST['Country']; $State= $_POST['State']; $List= $_POST['List']; $Nav= $_POST['Nav']; $IssuesYes= $_POST['IssuesCheck']; $IssuesList= $_POST['IssuesList']; $Satisfaction= $_POST['Satisfaction']; $Improvement= $_POST['Improvement']; $ValueSatisfaction= $_POST['Value']; $Recommendation= $_POST['Recommend']; $Knowledge= $_POST['Knowledge']; $Comments= $_POST['Comments']; $Gender= $_POST['Gender']; $Age= $_POST['Age']; $Source= $_POST['Source']; $ContactNumber= $_POST['Contact']; $Newsletter= $_POST['Newsletter']; $errors = array(); //Check that the fields above are not empty: $to = "email@email.com";//Obviously not real one that I am sending to. $subject = "Survey Form Submission"; $from = $to; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "$name submitted the survey form:\n". "This is what they responded with to each question: <br>". "Their Name: $Title $FirstName $LastName <br>"."Email: $Email <br>"."Country: $Country <br>"."State: $State<br>"."Bought: $List<br>"."Website Navigation: $Nav<br>"."Issues: $IssuesYes " ." $IssuesList"."Satisfaction: $Satisfaction<br>"."Improvement: $Improvement<br>"."Value Satisfaction: $ValueSatisfaction<br>"."Reccomend: $Recommendation<br>"."Knowledge: $Knowledge<br>"."Comments: $Comments <br>"."Gender: $Gender<br>"."Age: $Age <br>"."Source for Finding Us: $Source <br>"."Contact: $ContactNumber<br>"."Subscribe to Newsletter?: $Newsletter<br>"; $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; if( mail($to, $subject, $body,$headers)){ echo "Email Send!"; }else{ echo "Somethings wrong :\ "; } // header('Location: http://www.********/thank-you-for-survey'); } ?> Hey guys,
So, I have some complicated code, kind of. I'm using a Java server to generate a PDF. The actual user interacts with a HTML/PHP page and they click a submit and everything is good so far.
I generate a PDF to my /tmp directory (I'm using Linux) and it's a perfectly fine PDF. I can open it and read it and it's perfectly as it should be.
But when I try to send it to the user's browser as a download, the PDF I get doesn't open.
The error I get is "File type HTML document (text/html) is not supported" and that I'm unable to open the document.
My biggest question is, why? Is it something to do with the permissions of my directories and files? I've had a lot of errors be caused because of permissions so it wouldn't surprise me.
My output to the user page is :
Successfully connected to Java server. Hi all First, thanks for any help you can offer! What I'm trying to do is have a form, when submitted, create an attachment (the attachment appends the form values if it is already created) AND send the form values to myself as well as the person filling in the form (so to the email address in the 'email' field). I have several php files that do everything except I cant get it to email to the address in the email field and I cant see where I'm going wrong. I am NOT very php literate and these files were created for me although I understand how they work mostly. Thanks! FridgeForm.html code: Code: [Select] <form onclick="return checkFields();" method="post" action="formsubmit.php" id="skopefridge" name="skopefridge" enctype="multipart/form-data"> <p align="right" class="style1 style2"><img src="skope_logo.png" width="235" height="38" border="0">JOB SHEET</p> <table BORDER=0 RULES=NONE FRAME=BOX cellspacing="2" cellpadding="7"> <tr> <td colspan="2"><strong>Request ID</strong> <input name="requestid" type="text" class="fieldwidth" id="firstname" maxlength="50" readonly style="background-color:#CCC"> </label> <strong>Operator Name</strong> <input name="operator" type="text" id="operator" size="20" maxlength="80"></td> <td colspan="3"><strong>Date & Time: </strong> <script type="text/javascript" src="time.js"></script></td> </tr> <tr> <td colspan="5"><strong>CALLERS DETAILS</strong></td> </tr> <tr> <td>Name</td> <td><input name="name" type="text" size="50" tabindex=1></td> <td>Night Phone</td> <td colspan="2"><input name="nightph" type="text" size="50" tabindex=5></td> </tr> <tr> <td>Street</td> <td><input name="street" type="text" size="50" tabindex=2></td> <td>Day Phone </td> <td colspan="2"><input name="dayph" type="text" size="50" tabindex=6></td> </tr> <tr> <td>Suburb</td> <td><input name="suburb" type="text" size="50" tabindex=3></td> <td>Mobile</td> <td colspan="2"><input name="mobile" type="text" size="50" tabindex=7></td> </tr> <tr> <td>City</td> <td><select name="selectcity" size="1" tabindex=4> <option value="Alexandra">Alexandra</option> <option value="Ashburton">Ashburton</option> <option value="Auckland">Auckland</option> <option value="Blenheim">Blenheim</option> <option value="Canterbury">Canterbury</option> <option value="Cromwell">Cromwell</option> <option value="Dannevirke">Dannevirke</option> <option value="Dargaville">Dargaville</option> <option value="Dunedin">Dunedin</option> <option value="Fiordland">Fiordland</option> <option value="Gisborne">Gisborne</option> <option value="Gore c/o Invercargill">Gore c/o Invercargill</option> <option value="Greymouth">Greymouth</option> <option value="Hamilton">Hamilton</option> <option value="Hastings">Hastings</option> <option value="Invercargill">Invercargill</option> <option value="Kerikeri">Kerikeri</option> <option value="Masterton">Masterton</option> <option value="Napier">Napier</option> <option value="Nelson">Nelson</option> <option value="New Plymouth">New Plymouth</option> <option value="Oamaru">Oamaru</option> <option value="Palmerston North">Palmerston North</option> <option value="Queenstown">Queenstown</option> <option value="Ranfurly">Ranfurly</option> <option value="Rotorua">Rotorua</option> <option value="Taupo">Taupo</option> <option value="Tauranga/ mt maunganui">Tauranga/ mt maunganui</option> <option value="Timaru">Timaru</option> <option value="Wanaka">Wanaka</option> <option value="Wanganui">Wanganui</option> <option value="Wellington">Wellington</option> <option value="Westport">Westport</option> <option value="Whakatane">Whakatane</option> <option value="Whangerei">Whangerei</option> <option value="test">test</option> <option value="test2">test2</option> </select></td> <td>Company</td> <td colspan="2"><input name="company" type="text" size="50" id="company" tabindex=8></td> </tr> <tr> <td colspan="5"><strong>PRODUCT DETAILS</strong></td> </tr> <tr> <td>Model</td> <td><input name="model" type="text" size="50" tabindex=9></td> <td>Purchased From </td> <td colspan="2"><input name="purchfrom" type="text" size="50" tabindex=11></td> </tr> <tr> <td>Serial No</td> <td><input name="serial" type="text" size="50" tabindex=10></td> <td>Date Purchased </td> <td colspan="2"><input name="datepurch" type="text" size="50" tabindex=12></td> </tr> <tr> <td> </td> <td> </td> <td>Proof Of Purchase? </td> <td colspan="2"><input name="proofpurch" type="text" size="50" tabindex=13></td> </tr> <tr> <td>Room Heater Installed In </td> <td colspan="4"><input name="installed" type="text" size="50" tabindex=14></td> </tr> <tr> <td>Heater Problem </td> <td colspan="4"><input name="problem" type="text" size="50" tabindex=15></td> </tr> <tr> <td colspan="5" align="center"><span class="style4">FOR ANY PROBLEMS/ENQUIRIES PLEASE CONTACT SKOPE INDUSTRIES PH:0800 947 5673</span> </td> </tr> <tr> <td colspan="5" align="center"><hr> <strong>Contact Belinda at Skope Services if the complete heater needs to be replaced. | Replaced parts are to be kept for 3 months. <br> <font color="#FF0000">This form is automatically emailed to the contractor associated with the city you choose above. The contractors details are below (for the chosen city) if you need to contact them)</font></strong> </td> </tr> </table> <table border="0" cellspacing="4" cellpadding="4"> <tr> <td>Contractor</td> <td style="display:none;">City</td> <td>Address</td> <td>Phone</td> <td>Fax</td> <td>Email</td> </tr> <tr> <td><input type="text" name="contractor" id="contractor" readonly style="background-color:#CCC"></td> <td style="display:none;"><input type="text" name="city" id="city" readonly style="background-color:#CCC"></td> <td><input type="text" name="address" id="address" readonly style="background-color:#CCC"></td> <td><input type="text" name="phone" id="phone" readonly style="background-color:#CCC"></td> <td><input type="text" name="fax" id="fax" readonly style="background-color:#CCC"></td> <td><input type="text" name="email" id="email" readonly style="background-color:#CCC"></td> </tr> </table> <p> <input type="submit" name="Submit" value="Submit" style="width:1000px; height:30px; "> </p> </form> formsubmit.php: <?php include ('../tools/maketable.php'); include ('../tools/processing.php'); $config = "skopeGlobal.php"; /****************************************************************/ /*FORM SUBMITTED DATA */ /****************************************************************/ // These are the fields that are posted from the form to be changed to suit the form // Make sure that there is one variable per form field or you may miss data $requestid = $_REQUEST["requestid"]; $operator = $_REQUEST["operator"]; $name = $_REQUEST["name"]; $street = $_REQUEST["street"]; $suburb = $_REQUEST["suburb"]; $selectcity = $_REQUEST["selectcity"]; $nightph = $_REQUEST["nightph"]; $dayph = $_REQUEST["dayph"]; $mobile = $_REQUEST["mobile"]; $company = $_REQUEST["company"]; $model = $_REQUEST["model"]; $serial = $_REQUEST["serial"]; $purchfrom = $_REQUEST["purchfrom"]; $datepurch = $_REQUEST["datepurch"]; $proofpurch = $_REQUEST["proofpurch"]; $installed = $_REQUEST["installed"]; $problem = $_REQUEST["problem"]; $email = $_REQUEST["email"]; $callerInfo = "Request ID=".$requestid."; Operator=".$operator."; Name=".$name."; Street=".$street."; Suburb=".$suburb."; City=".$selectcity."; Night Phone=".$nightph."; Day Phone=".$dayph."; Mobile Phone=".$mobile."; Company Name=".$company."; Model=".$model."; Serial No=".$serial."; Purchased From=".$purchfrom."; Date Purchased=".$datepurch."; Proof of Purchase=".$proofpurch."; Room Installed In=".$installed."; Product Problem=".$problem."; Emailed To=".$email; $display .= makeTable("Call Details",$callerInfo,1); processData($config,$display,$callerInfo); ?> skopeGlobal.php: <?php $title = "Skope Fridge Form"; //TODO: The title should be changed to a significant title $stylesheet = "http://www.thecallcentre.co.nz/css/submittedstyling.css"; // TODO: This Has to be changed to a stylesheet for the site // this must be a url or email will not style correctly $logo = "http://www.thecallcentre.co.nz/other/tcclogo.jpg"; $fileName="Skope-FridgeFormResults.xls"; $emailTo= $_REQUEST["email"]; $emailFrom="info@thecallcentre.co.nz"; $redirect="Thankyou.html"; ?> There are also other processing files but I'm not sure if you need to see their code or not. |