Jump to content

wigglesby

Members
  • Posts

    42
  • Joined

  • Last visited

    Never

Everything posted by wigglesby

  1. It seems to display all the html when HTML email is disabled. How could I change the code I provided to send html or plain text?
  2. function sendEmail($to, $subject, $body, $errorText="") { $sendSuccess = 0; $body = str_replace("\n","<br/>",$body); $footer = "<div style='clear:both;'></div>" ."<p style='display:block;text-align:left;border-top:solid 1px #cccccc; padding-top:10px; margin-top:25px;'>" ."Visit: <a href='".WEBSITE_ADDRESS."'>".WEBSITE_ADDRESS."</a><br/>" .WEBSITE_POSTAL_ADDRESS.'<br/>' .WEBSITE_CONTACT_NUMBERS.'<br/>' ."Terms and Conditions: <a href='".WEBSITE_ADDRESS."/terms.php'>Terms and Conditions</a><br/>" ."Contact: <a href='mailto:".EMAIL_FROM_WEBSITE."'>".EMAIL_FROM_WEBSITE."</a><br/>" ."Company Registration: xxx VAT Number: xxx<br/>" ."</p>"; if(EMAIL_SENDING_STATUS == 1)//Check if we are sending emails from the site { //$emailHeaders = "To: The Receiver <".$to.">\n" . $emailHeaders = "From: ".EMAIL_FROM_WEBSITE."\r\n". "Content-type: text/html\r\n"; $header = "" ."<head>" ."<style type=\"text/css\">" ."body {\n" ." font: 11px/1.5em \"Lucida Grande\",\"Nimbus Sans Medium\",Arial,sans-serif;\n" ." color:#333333;\n" ." }\n" ." .maindiv\n" ." {\n" ." width:550px;\n" ." padding:5px;\n" ." padding-top:0px;\n" ." border:solid 1px #333333;\n" ." margin-bottom:25px;\n" ." }\n" ." .mailbody\n" ." {\n" ." padding-bottom:5px;\n" ." margin-bottom:10px;\n" ." }\n" ." .bodyImg\n" ." {\n" ." border:solid 1px #cccccc;\n" ." padding:3px;\n" ." }\n" ." td\n" ." {\n" ." vertical-align:top;\n" ." }\n" ."</style>" ."</head>"; $logoHead = ""; //"<p style='display:block;text-align:right;border-bottom:solid 1px #cccccc;margin-bottom:25px;'><img title='www.example.co.uk' alt='xx logo' src='http://www.example.co.uk../images/look_feel/logo.png' /></p>"; //If not an error send to site contact if($errorText == "") { if(!@mail($to, $subject, "<html>".$header."<body><div class='maindiv'>".$logoHead."<div class='mailbody'>".$body."</div>".$footer."</div></body></html>", $emailHeaders)) $sendSuccess++; }else //else send to webmaster { if(!@mail(EMAIL_WEBMASTER , WEBSITE_NAME." ".$subject ,"<html>".$header."<body><div class='maindiv'>" .$logoHead ."<div class='mailbody'>" ."============".WEBSITE_NAME." ERROR =============<br/>" .date("l jS \of F Y h:i:s A")."<br/>" .$this->curPageURL()."<br/>" ."-----------------------------------------------------------------------------------<br/>" .$body."<br/>" .$errorText ."</div>" .$footer ."</div></body></html>" , $emailHeaders)); $sendSuccess++; } } else { $emailString = "<p>TO: ".$to."</p>" ."<p>SUBJECT: ".$subject."</p>" ."<p>BODY: ".$body."</p>" .$footer .($errorText != '' ? "<p>ERROR: ".$errorText."</p>" : ''); echo $emailString; } return ($sendSuccess == 0 ? true : false); } Some users seem to only get the email in terms of the code displaying and not rendering the HTML properly.
  3. Hi all I'm trying to send email via PHP and some of the emails are returning as: > >> Content-type: text/html >> >> Message-Id: <xxx.xxx@280443-web1.xxx.co.uk> >> Date: Mon, 19 Apr 2010 10:05:15 +0100 (BST) >> Return-Path: apache@280443-web1.xxx.co.uk >> X-OriginalArrivalTime: 19 Apr 2010 09:05:16.0672 (UTC) FILETIME= >> [6DB2F800:01CADF9F] >> It doesn't seem to send the email properly. Can anyone shed any light on why it would be doing this?
  4. Hi All I'd really like it so that If someone types www.mydomain.com then they are redirected to www.mydomain.co.uk Is this possible with a .htaccess file? Thanks
  5. I haven't called a PHP function in my JS. updateReceivedCartons() is another JS function: <script type="text/javascript" /> jQuery.noConflict(); function updateReceivedCartons(){ var cartons = jQuery('input#txtitemscarton<? echo $recId ?>').val(); var remaining = jQuery('input#txtitemsremaining<? echo $recId ?>').val(); var received = jQuery('input#txtitemsreceived<? echo $recId ?>').val(); var gTotal = cartons - remaining; var html = '<input type="text" onblur="updateRemainingCartons()" id="txtitemsreceived<? echo $recId ?>" name="txtitemsreceived<? echo $recId?>" class="teenyinput numbers" value="'+gTotal+'" />'; if (gTotal < 0) { alert("The number you entered is too large."); } else { jQuery("#txtitemsreceived<? echo $recId ?>").after(html).remove(); } } </script> <script type="text/javascript" /> jQuery.noConflict(); function updateRemainingCartons(){ var cartons3 = jQuery('input#txtitemscarton<? echo $recId ?>').val(); var remaining3 = jQuery('input#txtitemsremaining<? echo $recId ?>').val(); var received3 = jQuery('input#txtitemsreceived<? echo $recId ?>').val(); var gTotal2 = cartons3 - received3; var html = '<input type="text" onblur="updateReceivedCartons()" id="txtitemsremaining<? echo $recId ?>" name="txtitemsremaining<? echo $recId?>" class="teenyinput numbers" value="'+gTotal2+'" />'; if (gTotal2 < 0) { alert("The number you entered is too large."); } else { jQuery("#txtitemsremaining<? echo $recId ?>").after(html).remove(); } } </script> Thanks
  6. Hi I have written some code, that calculates the value of one input box minus another input box and then puts the sum into another input box. This works fine if there is only 1 row (the page uses php to loop through the db), with only 3 boxes. If there is another table row (i.e. another 3), the code doesn't seem to update but the row below does. <script type="text/javascript" /> jQuery.noConflict(); jQuery(document).ready(function() { var cartons2 = jQuery('input#txtitemscarton<? echo $recId ?>').val(); var received2 = jQuery('input#txtitemsreceived<? echo $recId ?>').val(); var remaining2 = jQuery('input#txtitemsremiaining<? echo $recId ?>').val(); var gRemaining = cartons2 - received2; var gReceived = received2; var html2 = '<input type="text" onblur="updateReceivedCartons()" id="txtitemsremaining<? echo $recId ?>" name="txtitemsremaining<? echo $recId?>" class="teenyinput numbers" value="'+gRemaining+'" />'; jQuery("#txtitemsremaining<? echo $recId ?>").after(html2).remove(); var html3 = '<input type="text" onblur="updateRemainingCartons()" id="txtitemsreceived<? echo $recId ?>" name="txtitemsreceived<? echo $recId?>" class="teenyinput numbers" value="'+gReceived+'" />'; jQuery("#txtitemsreceived<? echo $recId ?>").after(html3).remove(); }); </script> Above is my code: The 3 input fields have the following ids: carton number = txtitemscarton + the id of the row from the db received number = txtitemsreceived + the id of the row from the db remaining number = txtitemsremaining + the id of the row from the db So on load, it should detect the value of txtitemscarton... - txtitemsreceived and then insert the result into txtitemsremaining, but it if there are 2 or more rows, then it only replaces 1 txtitemsreceived input box. I have attached a screenshot of what I mean. Any ideas how I can change this code? Thanks [attachment deleted by admin]
  7. Hi I have following code: <script type="text/javascript" /> function updateReceivedCartons(){ var cartons = parseFloat(document.getElementById('cartons').value); var remaining = parseFloat(document.getElementById('txtitemsremaining<? echo $recId ?>').value); var received = parseFloat(document.getElementById('txtitemsreceived<? echo $recId ?>').value); var gTotal = cartons - received - remaining; if (gTotal < 0) { alert("The number you entered is too large."); } else { $("#txtitemsreceived<? echo $recId ?>").after("<td class='numbers'><input type='text' disabled='disabled' id='txtitemsreceived<? echo $recId ?>' name='txtitemsreceived<? echo $recId?>' class='teenyinput numbers' value='XXXXXX' /></td>").remove(); } } </script> cartons = 3 received =1 remaining = 1 Now when I set remaining as 1, I then want to pass in the gTotal variables value where XXXXXX is. But I'm not sure how to. So If the above values are set, XXXXXX should be 1 (3 - 1 - 1 = 1). Im just not sure how to the the value of the variable and then pass it into value="XXXXXX" Any ideas?
  8. Hi I have 2 input fields: <input type='text' name='txtitemsremaining".$recId."' id='txtitemsremaining".$recId."' class='teenyinput numbers' value='' /> <input type='text' disabled='disabled' id='txtitemsreceived".$recId."' name='txtitemsreceived".$recId."' class='teenyinput numbers' value='".$poItem->items_received."' /> The form Is in 3 parts: Remaining (input field) Received (input field) Total (outputs the total from the db) What I want to do is: If the total is 6 and received is 0, then remaining needs to say '6'. If I then type in 3 into remaining, I need it to update the received value to 3. If then saved, the page should then display remaining as 3, received as 3 and total as 6. If i then type 0 into remaining, then received should say 6. I just dont know how to do this with javascript and ajax. Thanks
  9. Oh yeah Cheers everyone!
  10. Ok, so it works for some but not others: if (get_magic_quotes_gpc()) { $good_practice = stripslashes($_POST['good_practice']); $investment_return = stripslashes($_POST['investment_return']); } else { $good_practice = $_POST['good_practice']; $investment_return = $_POST['investment_return']; } $good_practice = mysql_real_escape_string($_POST['good_practice']); $investment_return = mysql_real_escape_string($_POST['investment_return']); On output it will still output the following: it\'s Any idea why? Thanks
  11. Ok: echo get_magic_quotes_gpc(); Returned 1, so I guess magic quotes is turned on.... $json_out = nl2br($mtj->get_json()); This seemed to work as well. Cheers guys
  12. Ok, I'm using: $content = mysql_real_escape_string($_POST['content']); To insert the text. Do I need to add stripslashes before the real_escape_string function? $content = stripslasges(mysql_real_escape_string($_POST['content'])); The code: $json_out = stripslashes(nl2br($mtj->get_json())); didn't work Thanks
  13. Hi I have some data in my db, which is inserted into a form. As some of the text is in " it's " with single quote, it inserts with a \' into the db. This is all fine, the problem is I'm wanting to use nl2br, which finds all the \r\n and outputs a break. But this still outputs the it\'s string. I have the following: $json_out = nl2br(stripslashes($mtj->get_json())); But using stripslashes removes the \ form the it\'s but then outputs the rn minus theri slashes. Anyway I can round this? Thanks
  14. That is quite possible. The insert of the data uses mysql_real_escape_string. Could this be a reason why, when inserting a string, such as "example-code" then outputs "\\\example-code\\\" ? Thanks
  15. Can anyone help me with this? It's causing a problem parsing the JSON as it cannot parse the JSON due to the \\ chars UPDATE: I've added stripslashes to the way the json is generated. Fingers crossed no more errors on parsing.
  16. I'm using a class: <?php class mysql_to_json { var $json; var $cbfunc; var $json_array; //constructor function mysql_to_json($query = '', $cbfunc = '') { //set cbfunc $this->set_cbfunc($cbfunc); //check they don't just want a new class if($query != '') { //set query $this->set_query($query); } } //produces json output function get_json() { //generate json $this->json = $this->cbfunc . '(' . json_encode($this->json_array) . ')'; //return json return $this->json; } //produces json from query function get_json_from_query($query, $cbfunc = '') { //set cbfunc $this->set_cbfunc($cbfunc); //set query $this->set_query($query); //return json data return $this->get_json(); } //set query function set_query($query) { //execute query $exec_query = mysql_query($query); //reset json array $this->json_array = array(); //loop through rows while($row = mysql_fetch_assoc($exec_query)) { //add row array_push($this->json_array, $row); } //enable method chaining return $this; } } //set cbfunc function set_cbfunc($cbfunc) { //set cbfunc $this->cbfunc = $cbfunc; //enable method chaining return $this; } } I'm including this in another file then just creating an object and using methods from the class: //create a new instance of mysql_to_json $mtj = new mysql_to_json($query); //show the json output $json_out = rtrim(str_replace('\r\n', '',$mtj->get_json())); //create a new blank instance of mysql_to_json $mtj = new mysql_to_json(); //show the json output through method chain $fh = fopen('objects.json', 'w') or die("can't open file"); fwrite($fh, $json_out); fclose($fh); Objects.json is populated, but everything with a "(double quote) or ' (single quote) becomes \\\"example\\\" or shouldn\\'t. Thanks
  17. Hi all I'm trying to generate JSON, by pulling data from my database and outputting it to a file to be used later. I've managed to get all that working, the only problem is that If there is anything like "example-text" (double quotes) the JSON output is \\\"example-text\\\". I want to removed the slashes as it seems to be affecting the output of the actual paragraph of text. Everything after the slashes is not displayed (I'm pulling the JSON into flash) Thanks
  18. I managed to get it to work using the following: jQuery(document).ready(function(){ var numShown = 5; // Initial rows shown & index var numMore = 5; // Increment var numRows = jQuery('#list li').size(); // Total # rows alert(numRows); // Hide rows and add clickable div jQuery('#list') .find('li:gt(' + (numShown - 1) + ')').hide().end() .after('<div id="more">Show <span>' + numMore + '</span> More</div>'); jQuery('#more').click(function(){ numShown = numShown + numMore; // no more show more if done if ( numShown >= numRows ) jQuery('#more').remove(); // change rows remaining if less than increment if ( numRows - numShown < numMore ) jQuery('#more span').html(numRows - numShown); jQuery('#list').find('li:lt('+numShown+')').show(); }) })
  19. That works great!! Is there anyway that if there are no more <li> to show, that the moreLink <a href> can be hidden? Also my other concern is that, it will say 'next 5'. What If there are 8 <li>'s? The link will say 'next 5' but only show 3 more.... Thanks
  20. Ok, I changed the code from a <ul><li> to using a table, like the code I gave. I can load the next 5 now, but the list has about 50 rows and after the first click, the 'Show more' link disappears.
  21. Hi thank for the example. Unfortunately that doesnt work. It just lists out all my <li> tags, rather than hiding the first 5. I am pulling the <li> from a db in PHP, so I'm using a foreach(). So I cannot manually give the 6th -nth <li> attribute of style="display: none". The example code I found worked well, just when clicking on the 'Show more' link, nothing happened.... Any more help would be much appreciated
  22. Sorry, I updated my code to include using <li> var numShown = 5; // Initial rows shown & index var numMore = 5; // Increment var numRows = jQuery('#test').find('li').length; // Total # rows jQuery(document).ready(function(){ // Hide rows and add clickable div jQuery('#test') .find('li:gt(' + (numShown - 1) + ')').hide().end() .after('<div id="more">Show <span>' + numMore + '</span> More</div>'); jQuery('#more').click(function(){ numShown = numShown + numMore; if ( numShown >= numRows ) jQuery('#more').remove(); if ( numRows - numShown < numMore ) $('#more span').html(numRows - numShown); jQuery('info').find('tr:lt('+numShown+')').show(); }) }) Well in firebug, it says the 6th -> nth <li> are style="display: none" but when i view the HTML source, there is no style attribute. My code when viewing the source is: <div id="test"> <h2>Articles Tagged by: arms</h2> <ul id="list"> <li><a href="/work/fitbritz_events_new/web/frontend_dev.php/test/test1">test1</a></li> <li><a href="/work/fitbritz_events_new/web/frontend_dev.php/test/test2">test2</a></li> <li><a href="/work/fitbritz_events_new/web/frontend_dev.php/test/test3">test3</a></li> <li><a href="/work/fitbritz_events_new/web/frontend_dev.php/test/test4">test4</a></li> <li><a href="/work/fitbritz_events_new/web/frontend_dev.php/test/test5">test5</a></li> <li><a href="/work/fitbritz_events_new/web/frontend_dev.php/test/test6">test6</a></li> <li><a href="/work/fitbritz_events_new/web/frontend_dev.php/test/test7">test7</a></li> <li><a href="/work/fitbritz_events_new/web/frontend_dev.php/test/test8">test8</a></li> <li><a href="/work/fitbritz_events_new/web/frontend_dev.php/test/test9">test9</a></li> </ul> </div>
  23. I found an example using the following: var numShown = 5; // Initial rows shown & index var numMore = 5; // Increment var numRows = $('table').find('tr').length; // Total # rows $(document).ready(function(){ // Hide rows and add clickable div $('table') .find('tr:gt(' + (numShown - 1) + ')').hide().end() .after('<div id="more">Show <span>' + numMore + '</span> More</div>'); $('#more').click(function(){ numShown = numShown + numMore; // no more show more if done if ( numShown >= numRows ) $('#more').remove(); // change rows remaining if less than increment if ( numRows - numShown < numMore ) $('#more span').html(numRows - numShown); $('table').find('tr:lt('+numShown+')').show(); }) }) But when clicking on the div 'Show More' the div disappears and no other results are displayed. They remain as style="display:none" in the HTML. Thanks
  24. Hi I have a script that lists a lot of links within an-ordered list. As the list will be different lengths for different pages (user profiles) I want to display the first 5 links, then have a button that when clicked, will then show the next 5 (including the first 5 - so a total of 10 links) Is this possible?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.