PHP - Display Of Variables In Body
i am having issues getting the variables to show up on localhost server within the body element. is it something in the codes or something in the php.ini settings? here is some sample code
Code: [Select] <h1>Skyward Aviation</h1> <h2>Contact Information</h2> <form action="ContactUpdate.php" method="get"> <table frame="border" rules="cols"> <colgroup width="50%" /> <colgroup width="50%" /> <tr> <td align="right" valign="top"> <p>First Name <input type="text" name="first_name" value="<?= $First ?>" size="36" /></p> <p>Last Name <input type="text" name="last_name" value="<?= $Last ?>" size="36" /></p> <p>Phone <input type="text" name="phone" value="<?= $Phone ?>" size="36" /></p> </td> <td align="right" valign="top"> <p>Address <input type="text" name="address" value="<?= $Address ?>" size="40" /></p> <p>City <input type="text" name="city" value="<?= $City ?>" size="10" /> State <input type="text" name="state" value="<?= $State ?>" size="2" maxlength="2" /> Zip <input type="text" name="zip" value="<?= $Zip ?>" size="10" maxlength="10" /></p> </td> </tr> </table> <p><input type="hidden" name="PHPSESSID" value='<?php echo session_id() ?>' /> <p><input type="submit" value="Submit" /></p> </form> In the page is shows <?= $First ?> in the area First Name textbox. Similar TutorialsThis code was given to me by mjdamato to help display a student and the course that student has take and within that the modules in the course and the sessions in course including module mark and grade and student's session marks and grades. I am very weak on php code as I have only done it once and that was following a php workbook 2 years ago. I am more of a database specialist. Below is the code given to me and you can also download the code from the attachment: Code: [Select] <?php function outputModule($moduleID, $moduleName, $sessionData) { if(!count($sessionData)) { return false; } $markTotal = 0; $markGrade = 0; $weightSession = 0; $grade = ""; $sessionsHTML = ""; foreach($sessionData as $session) { $sessionsHTML .= "<p><strong>Session:</strong> {$session['SessionId']} <br><strong>Session Mark:</strong> {$session['Mark']}</strong> <br><strong>Session Weight Contribution</strong> {$session['SessionWeight']}%</p>\n"; $markTotal += round($session['Mark'] / 100 * $session['SessionWeight']); $weightSession += ($session['SessionWeight']); $markGrade = round($markTotal / $weightSession * 100); if ($markGrade >= 70){ $grade = "A";} else if ($markGrade >= 60 && $markGrade <= 69){ $grade = "B";} else if ($markGrade >= 50 && $markGrade <= 59){ $grade = "C";} else if ($markGrade >= 40 && $markGrade <= 49){ $grade = "D";} else if ($markGrade >= 30 && $markGrade <= 39){ $grade = "E";} else if ($markGrade >= 0 && $markGrade <= 29){ $grade = "F";} } $moduleHTML = "<p><br><strong>Module:</strong> {$moduleID} - {$moduleName} <br><strong>Module Mark:</strong> {$markTotal} <br><strong>Mark Percentage:</strong> {$markGrade} <br><strong>Grade:</strong> {$grade} </p>\n"; return $moduleHTML . $sessionsHTML; } $output = ""; $studentId = false; $courseId = false; $moduleId = false; while ($row = mysql_fetch_array($result)) { if($studentId != $row['StudentUsername']) { //Student has changed $studentId = $row['StudentUsername']; $output .= "<p><strong>Student:</strong> {$row['StudentForename']} {$row['StudentSurname']} ({$row['StudentUsername']})\n"; } if($courseId != $row['CourseId']) { //Course has changed $courseId = $row['CourseId']; $output .= "<br><strong>Course:</strong> {$row['CourseId']} - {$row['CourseName']} <strong>Course Mark</strong> <strong>Grade</strong> <br><strong>Year:</strong> {$row['Year']}</p>\n"; } if($moduleId != $row['ModuleId']) { //Module has changed if(isset($sessionsAry)) //Don't run function for first record { //Get output for last module and sessions $output .= outputModule($moduleId, $moduleName, $sessionsAry); } //Reset sessions data array and Set values for new module $sessionsAry = array(); $moduleId = $row['ModuleId']; $moduleName = $row['ModuleName']; } //Add session data to array for current module $sessionsAry[] = array('SessionId'=>$row['SessionId'], 'Mark'=>$row['Mark'], 'SessionWeight'=>$row['SessionWeight']); } //Get output for last module $output .= outputModule($moduleId, $moduleName, $sessionsAry); //Display the output echo $output; } } ?> Below the what this code outputs: Student: Mayur Patel (u0867587) Course: INFO101 - Bsc Information Communication Technology Course Mark Year: 3 Module: CHI2550 - Modern Database Applications Module Mark: 41 Mark Percentage: 68 Grade: B Session: AAB Session Mark: 72 Session Weight Contribution 20% Session: AAE Session Mark: 67 Session Weight Contribution 40% Module: CHI2513 - Systems Strategy Module Mark: 31 Mark Percentage: 62 Grade: B Session: AAD Session Mark: 61 Session Weight Contribution 50% If you look above it shows that there is nothing in the Course Mark: section, what Course Mark is suppose to do is total up all the module mark percentages and then divide it by the number of modules. So the calculation will be adding up all the Code: [Select] $markGrade and dividing it by count Code: [Select] $ModuleID. In examle above it will be 68 (mark percentage for 1st module) + 62 (mark percentage for 2nd module) / 2 (number of modules in the course). So the Course Mark should equal 65. The problem is that all of the calculations are in the foreach loop but where the course details and where the course marks are going to be placed are in the while loop. So the problem is that if the total Course Mark (lets say we call in $totalCourse) is displayed in the while loop it will provide an undifined index as the calculation will be placed with the other calculations in the foreach loop which is outside the while loop, if I do the calculation with in the while loop, it will only choose the 1st module mark percentage and divdie it by the first module only, this is obviously incorrect as it sohuld try and do this for all modules hence why my calculations are in the foreach loop which does this. So how will change the code so that the course details can go from the while loop and be placed in the foreach loop so then I can include the calculation in the foreach loop. Thank You and hopefully you understand it, just read it very carefully to understand it, it is very simple what I want to achieve but I do not know how to do it. [attachment deleted by admin]
For debug purposes, I want to see all (each and every possible) variables from a website visitor, e.g. I know how to save the info in a database, I might even have the info emailed to myself, I just can't remember the "one-liner" I used to use to capture this info. Thank you in advance!
hello i have built a webpage using tables. i might have done something wrong (except using tables) and now the results are rendered chaotically on the webpage. also here is the attached file. after the 4th article it's all messy i have a solution but that means to insert a php tag inside another php tag, but won't work thankyou does anyone know how to decode this XML variable value into string values? I also need to know the oposite way: creating variable values into xml. I've tried several code examples but they did filter the requested data. Code: [Select] $xml='<?xml version="1.0" encoding="utf-8"?> <elements> <text identifier="ed9cdd4c-ae8b-4ecb-bca7-e12a5153bc02"> <value/> </text> <textarea identifier="a77f06fc-1561-453c-a429-8dd05cdc29f5"> <value><![CDATA[<p style="text-align: justify;">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>]]></value> </textarea> <textarea identifier="1a85a7a6-2aba-4480-925b-6b97d311ee6c"> <value><![CDATA[<p style="text-align: justify;">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>]]></value> </textarea> <image identifier="ffcc1c50-8dbd-4115-b463-b43bdcd44a57"> <file><![CDATA[images/stories/red/cars/autobedrijf.png]]></file> <title/> <link/> <target/> <rel/> <lightbox_image/> <width><![CDATA[250]]></width> <height><![CDATA[187]]></height> </image> <text identifier="4339a108-f907-4661-9aab-d6f3f00e736e"> <value><![CDATA[Kramer 5]]></value> </text> <text identifier="ea0666d7-51e3-4e52-8617-25e3ad61f8b8"> <value><![CDATA[6000 RS]]></value> </text> <text identifier="90a18889-884b-4d53-a302-4e6e4595efa0"> <value><![CDATA[Eindhoven]]></value> </text> <text identifier="410d72e0-29b3-4a92-b7d7-f01e828b1586"> <value><![CDATA[APK Pick up and return]]></value> </text> <text identifier="45b86f23-e656-4a81-bb8f-84e5ea76f71f"> <value><![CDATA[15% korting op grote beurt]]></value> </text> <text identifier="3dbbe1c6-15d6-4375-9f2f-f0e7287e29f3"> <value><![CDATA[Gratis opslag zomerbanden]]></value> </text> <text identifier="2e878db0-605d-4d58-9806-8e75bced67a4"> <value><![CDATA[Gratis abonnement of grote beurt]]></value> </text> <text identifier="94e3e08f-e008-487b-9cbd-25d108a9705e"> <value/> </text> <text identifier="73e74b73-f509-4de7-91cf-e919d14bdb0b"> <value/> </text> <text identifier="b870164b-fe78-45b0-b840-8ebceb9b9cb6"> <value><![CDATA[040 123 45 67]]></value> </text> <text identifier="8a91aab2-7862-4a04-bd28-07f1ff4acce5"> <value/> </text> <email identifier="3f15b5e4-0dea-4114-a870-1106b85248de"> <value/> <text/> <subject/> <body/> </email> <link identifier="0b3d983e-b2fa-4728-afa0-a0b640fa34dc"> <value/> <text/> <target/> <custom_title/> <rel/> </link> <relateditems identifier="7056f1d2-5253-40b6-8efd-d289b10a8c69"/> <rating identifier="cf6dd846-5774-47aa-8ca7-c1623c06e130"> <votes><![CDATA[1]]></votes> <value><![CDATA[1.0000]]></value> </rating> <googlemaps identifier="160bd40a-3e0e-48de-b6cd-56cdcc9db892"> <location><![CDATA[50.895711,5.955427]]></location> </googlemaps> </elements>'; Hi. I have some code which needs to return a single variable from the function and stored as a variable within this page, so it can be echoed later on in the page. I couldn't get it to return as a variable, so i used "return compact();" to return the variable and "extract (myFunction());" to extract it to variables. However, when I turned on php's display errors and error reporting function, I got an error message saying "Warning: extract() [function.extract]: First argument should be an array in /my/web/site/index.php on line 6" (which is where my extract function is). This works fine with passing more than one variables through, is there another way pass one variable from a function to be stored as a variable on the page which called the function? Here is the function: Code: [Select] <?php //This is a list of numeric error codes against their text. this will return the error code as the variable $issue function checkLoginIssue() { //If there is an error code if (isset($_GET["issue"])) { //cycle through the list until the code is reached, return the text and break the switch switch ($_GET["issue"]) { case "1": $issue = '<p class="warning">Please log in to view this page</p>'; break; case "2": $issue = '<p class="warning">Wrong Username or Password</p>'; break; case "3": $issue = '<p class="warning">No user found with those details</p>'; break; } //return the variable in an array with a single value return compact('issue'); } } ?> And here is the code which calls the function: Code: [Select] <?php extract(checkLoginIssue()); ?> Hi, I've written a conditional statement to give my body tag a unique ID, depending on three conditions. (body id="red" etc..) The statement does indeed work when tested, but dreamweaver is highlighting the conditional in yellow - So I'm wondering if there is an alternate (and perhaps cleaner) way of writing the following.. It's for a joomla site btw.. (I've spread the code out a little here, so it's easier for you guys to see what I'm doing) Code: [Select] <body <?php if($this->countModules('headerlow')) : ?> id="up" <?php endif; ?> <?php if (JRequest::getVar('Itemid')==104) { ?> id="red" <? } else {?> id="low" <? } ?> > Hello all, I have a script I have been working on that retrieves my email from my mail server using some of the imap_functions. Everything works fine except for the emails that were sent from my blackberry. I have done some research and it seem to be something to do with the encoding that the blackberry uses. I have found a little bit of code that I was hoping would solve the issue. My goal is to get the body content from email that was produced with my blackberry and put bits of this body into a database. Then I want to do a report from that database once a week. I have developed a script that will retrieve all other message except from my blackberry. Does anyone know how blackberry encodes their body content? jmr3460 I want to read an imap message with all the headers, and body, what would be the best way to do that? Hey guys I have the following code and am trying to get the body of the webpage, however it is not currently working and the array at the end is empty. Any help appreciated!!!!! Code: <?php $word = $_GET['word']; function get_web_page( $url,$curl_data ) { $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects CURLOPT_POST => 1, // i am sending post data CURLOPT_POSTFIELDS => $curl_data, // this are my post vars CURLOPT_SSL_VERIFYHOST => 0, // don't verify ssl CURLOPT_SSL_VERIFYPEER => false, // CURLOPT_VERBOSE => 1 // ); $ch = curl_init($url); curl_setopt_array($ch,$options); $content = curl_exec($ch); $err = curl_errno($ch); $errmsg = curl_error($ch) ; $header = curl_getinfo($ch); curl_close($ch); // $header['errno'] = $err; // $header['errmsg'] = $errmsg; //$header['content'] = $content; return $content; } $curl_data = "?tranword=".$word; $url = "http://www.wordreference.com/es/translation.asp?tranword=".$word; $response = get_web_page($url,$curl_data); preg_match('~<body>(.*)</body>~', $response, $output); print_r($output); ?> Thanks lots, Jake I've been trying to implement the ID the Body Based on URL wordpress snippet. First issue seems to be a syntax error function curr_virtdir($echo=true){ $url = explode('/',$_SERVER['REQUEST_URI']); $dir = $url[1] ? $url[1] : 'home'; // defaults to this if in the root $dir = htmlentities(trim(strip_tags($dir))); // prevent injection into the DOM through this function if ($echo) echo $dir; return echo $dir; // ie. curr_virtdir(false) } function get_curr_virtdir(){ curr_virtdir(false); } I Get a syntax error on this line below return echo $dir; // ie. curr_virtdir(false) If i remove this line completly the script seems to work for in the following situation <body <?php id="<?php curr_virtdir(); ?>"> although I am trying to use the same functions as a conditional for my hardcoded navigation but it doesnt seem to work - any ideas? <li><a href="http://www.url.com/" class="<?php if ( get_curr_virtdir() == "home" ){echo "navhomecurrent";} else {echo "navhome";}?>">Home<span></span></a></li> <li><a href="http://www.url.com/solutions/solutions/" class="<?php if ( get_curr_virtdir() == "solutions" ){echo 'navsolutionscurrent';} else {echo 'navsolutions';}?>">Solutions<span></span></a></li> <li><a href="http://www.url.com/about-us/about-us/" class="<?php if ( get_curr_virtdir() == "about-us" ){echo "navaboutuscurrent";} else {echo "navaboutus";}?>">About us<span></span></a></li> This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=351491.0 Hello,
I've made a function that contains the html header (<head>). When I call that function in a other file, with the header file included, it puts the header function in the body. So all the meta tags are in the body, instead of the head.
Would it be possible to load this all in the head?
The head function does contain the html and head tags. However, without them, it still doesn't want to go to the head.
Hi there guys, can any1 help me out to sort this thing. I'm using a simple php email script to send emails from online form (registration). Since i'm using unicode (cyrilic) font, i'm recieving an unreadable email from my php script. Here's the script (mailer.php): Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset="UTF-8" /> <title>Mecavnik</title> </head> <body> <!-- Reminder: Add the link for the 'next page' (at the bottom) --> <!-- Reminder: Change 'YourEmail' to Your real email --> <?php $ip = $_POST['ip']; $hp1 = $_POST['hp1']; $hp2 = $_POST['hp2']; $hp3 = $_POST['hp3']; $hp4 = $_POST['hp4']; $hp5 = $_POST['hp5']; $IP = $_POST['IP']; $hp6 = $_POST['hp6']; $hp7 = $_POST['hp7']; $hp8 = $_POST['hp8']; $hp9 = $_POST['hp9']; $hp10 = $_POST['hp10']; $hp11 = $_POST['hp11']; if (eregi('http:', $notes)) { die ("Ne ne! ! "); } if(!$hp8 == "" && (!strstr($hp8,"@") || !strstr($hp8,"."))) { echo "<h2>Error</h2>\n"; $badinput = "<h2>Error</h2>\n"; echo $badinput; die ("Error."); } if(empty($hp1) || empty($hp2) || empty($hp3) || empty($hp4) || empty($hp5) || empty($hp6) || empty($hp7) || empty($hp8 )) { echo "<h2>123</h2>\n"; die ("Error."); } $datum = date("l, F j, Y, g:i a") ; $subject = "Custom subject"; $message = "Firma: $hp1 \n Ime: $hp2 \n Prezime: $hp3 \n Email: $hp8 \n Telefon: $hp4 \n Konfekcijski broj: $hp5 \n Spavanje: $hp6 \n Prevoz: $hp7 \n "; $from = "From: $hp8 \n"; mail("evlj@something.bla", $subject, $message, $from); ?> <?php header( 'Location: http://blabla/123/123.html' ) ; ?> </p> </body> </html> Email that i have previously recieved: Code: [Select] Firma: Тестирам Ime: Упишите Ваше име Prezime: Упишите Ваше презиме Thanks in advance I have a page which contains php scripts for the values that will be send through email. my problem is when i send it, it doesn't read the php script. The body only read plain html text. how can I output my php script values through html Hi,
I currently have some html stored in a variable as below:
<!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> Hello world </body> </html>This requires a "<div class='container'>" to be inserted directly after the opening body tag. My original thinking was to use str_replace on the <body> to be <body><div class="container"> however note that occasionally my body will require an ID or Class. I therefore need a way to make it appear after the body tag, even if it has an ID or Class on it :-\ . I assume this may be reg-ex, but am not sure if there is a simple way around this? Would anyone be able to clarify and point me in the right direction. Much appreciated. MoFish Hi, I wanted to know is there any class or functions which will parse the mail body and find all the features like how many sentences, how many stop words, how many paragraphs, how many punctuation chars, etc. I haven't find anything good in my searching so far. I have parsed the whole body of email and separated the headers and body in variables. Now I want to perform these operations in only in the body. Thank you in advance. I have this code. Why aren't the php scripts working when executing the body onload or onunload functions? Code: [Select] <head> <script language="javascript"> <?php function hello() { $fp = fopen("counter.txt", "r"); $count = fread($fp, 1024); fclose($fp); $count = $count + 1; echo "<p>Number of users online now:" . $count . "</p>"; $fp = fopen("counter.txt", "w"); fwrite($fp, $count); fclose($fp); alert("Welcome to My Page"); } ?> <?php function goodbye() { $fp = fopen("counter.txt", "r"); $count = fread($fp, 1024); fclose($fp); $count = $count - 1; $fp = fopen("counter.txt", "w"); fwrite($fp, $count); fclose($fp); alert("Goodbye!"); } ?> </script> </head> <body onload="hello()" onUnLoad="goodbye()"> </div> </body> </html> Magento PHP mail function : <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); $itemData = array(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); $sku = $list->getsku(); $name = $list->getName(); $price = $list->getPrice(); $Qty = $list->getQtyOrdered(); $extra = $order->getIncrementId(); $message = " <tr> <td>$incrementid</td> <td>$sku</td> <td>$name</td> <td>$price</td> <td>$Qty</td> </tr>"; $itemData[$list->getId()] = $message; } $finalMessage = "<table border='1'> <tr> <th>Id</th> <th>Sku</th> <th>Product name</th> <th>Price</th> <th>Qty Ordered</th> </tr>"; if (!empty($itemData)) { foreach ($itemData as $data) { $finalMessage .= $data; } $finalMessage .= "</table>"; $this->sendMail($finalMessage); } } public function sendMail($message) { $body ="$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('abc'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); $emailTemplate->setToEmail('aveevacool@gmail.com'); $emailTemplate->send(); } } ?> Now my output like :
Edited January 7, 2020 by aveeva My external css file works on everything except for body, however, it works when I include the css on the page itself:
body{ margin-top: 0px; padding-top: 0px; margin-bottom: 0px; padding-bottom: 0px; background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNS4xIFdpbmRvd3MiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OERFQkEzRUJDNUM5MTFFMUE3NzBCMTZBMEExNEQ5NUQiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OERFQkEzRUNDNUM5MTFFMUE3NzBCMTZBMEExNEQ5NUQiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo4REVCQTNFOUM1QzkxMUUxQTc3MEIxNkEwQTE0RDk1RCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo4REVCQTNFQUM1QzkxMUUxQTc3MEIxNkEwQTE0RDk1RCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PiSp0pIAAAAySURBVHjaYmBgYOAHYmYGCADR/CDiDxDzQAW5gPgLlM3ACsQKUBqhBYjZkY3CMBMgwACvHQKnyUp+6gAAAABJRU5ErkJggg=="); background-color:#b20a22; -webkit-transition: all 300ms ease-in-out; -moz-transition: all 300ms ease-in-out; -ms-transition: all 300ms ease-in-out; -o-transition: all 300ms ease-in-out; transition: all 300ms ease-in-out; }What could be wrong? Hi I am sure this is very simple but it's got me beat! I have a page that sends emails to people with their account details. I can get it to work fine with straight plain text but would like it in HTML and I can't get the username and password details into the body of the email. I'm sure it's just a formatting issue but I've tried many things and it fails!! Any suggestions very welcome. The code is below. Many thanks in advance. <?php // MAIL TO AP require_once '../phpmailer/class.phpmailer.php'; $mail = new PHPMailer(); if(isset($_GET['idcode'])){ $idcodepassed = $_GET['idcode']; }else{ $idcodepassed = 111111; // set this to your default value if no URL value is present } mysql_select_db($database_process, $process); $result = mysql_query("SELECT applicantid, idcode, type, company, email, CONCAT('pdf_document_',idcode) AS linkname, length, username, password, DATE_FORMAT(applicationdate,'%D %M %Y') AS formattedDate, parties FROM applicant WHERE idcode = '$idcodepassed' LIMIT 1 "); while($row = mysql_fetch_array($result)) { $appid = $row['applicantid']; $idcode = $row['idcode']; $type = $row['type']; $company = $row['company']; $email = $row['email']; $term = $row['length']; $username = $row['username']; $password = $row['password']; $appdate = $row['formattedDate']; $parties = $row['parties']; } // $body = file_get_contents('EmailTextAP.php'); // $body = eregi_replace("[\]",'',$body); $body = '<html><p>This email TO AP is confirmation of your appointment of Clear Appointments as your agent for service of process under the agreement between $parties. Our appointment starts on $appdate and you have appointed us for $term years from this date. We have attached our letter of confirmation to this email for your records.</p> <p>You can log into your account on our website (<a href=\"http://www.clearappointments.co.uk\">www.clearappointments.co.uk</a>) at any time to review your documents and change your contact details. Your user name is:??? and your password is ???.</p> <p>We appreciate your custom and hope that you will use us again.</p> <p>Kind regards</p> <p>Clear Appointments Team<br /> '; $mail->SetFrom('confirmation@clearappointments.co.uk', 'Clear Appointments'); $mail->AddReplyTo('confirmation@clearappointments.co.uk', 'Clear Appointments'); // set the subject of the email $mail->Subject = "Process Agent Letter of Confirmation Attached"; @MYSQL_CONNECT("localhost","lawwork1_graham","733576"); @mysql_select_db("lawwork1_process"); $query = "SELECT company, email FROM applicant WHERE idcode='$idcodepassed'"; $result = @MYSQL_QUERY($query); // sets name and location of attachment $directory = '../docs/'; $docname = 'Confirmation_Letter_'. $idcodepassed . '.pdf'; $invname = 'Invoice_' . $idcodepassed . '.pdf'; $send=$directory.$docname; $sendinvoice=$directory.$invname; while ($row = mysql_fetch_array ($result)) { $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $mail->AddAddress($row["email"]); // $mail->AddAddress($row["instemail"]); // attachment // $mail->AddAttachment($send); // $mail->AddAttachment($sendinvoice); $mail->AddAttachment($send); // attachment // $mail->AddAttachment($sendinvoice); // attachment if(!$mail->Send()) { echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '<br>'; } else { echo ""; // echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "@", $row["email"]) . ')<br>'; } // Clear all addresses and attachments for next loop $mail->ClearAddresses(); $mail->ClearAttachments(); } ?> |