Skip to main content

Posts

Using Node.js and Websockets in Cakephp 3.x

  Using Node.js and Websockets in Cakephp 3.x Node.js is a platform built on Chrome’s JavaScript runtime to make building applications in JavaScript that run on the server .Node.js is the latest technology that used for create realtime applications and with cakephp we can use to send updated data to each connected clients. The main advantage of node.js is that you don't need to refresh a webpage or create ajax requestto update users data. Websockets And Node.js is the great combination to update data from server side to client side. so here is the tutorial for how to use node.js and websockets in cakephp 3.x. 1. First we need to install node.js on server. you can follow this tutorial to How to Install Node.js .  2. Then you need to install Socket.io on your server.to install socket.io on your server you nedd to run this command. sudo apt-get npm install socket.io 3. After installation of Socket.io we are ready to use node.js and websockets with cakephp ....

clear ajax requests from browser console

How to clear ajax requests from browser console  Yes we can clear ajax requests from mozilla firefox console tab .to clear ajax requests from console we use javascript function function clearconsole() {   console.log(window.console);   if(window.console || window.console.firebug) {    console.clear();   } } when you call this function after your ajax request then all ajax request from console will be hide . call this function after ajax success , done or fail . Example             $.ajax({                         type:"POST",                          url: form.attr('action'),             ...

How to do PHP unserialize jQuery serialized form data

How to do PHP unserialize jQuery serialized form data   The Jquery serialize method just takes the form elements and puts them in string form. example - "firstvariable=value&secondvariable=othervalue"; if you are not using associative array then you can access this variable by $_GET and $_POST method. Example =  $variable1 = $_GET[' firstvariable '];  but if your data in an array then you need to unserialize jquery serialized data in php. you can unserialize jquery seralized data by usin this methods. you can unserialize jquery serialize data into php by using parse_str. //GET METHOD $params = array (); parse_str ( $_GET , $params );   //POST METHOD $params = array (); parse_str ( $_POST , $params );   if your data serialize data in a variable then you need to use-    $params = array(); parse_str($_POST['formdata'], $params);     you can also use this function to unserialize your data   functi...

Tutorial-formatting floating point numbers in javascript

How to formatting floating point numbers in javascript In jQuery or javascript when we add or multiple or any mathematical opertaion perform on floating point numbers it gives wrong output . For Example if we add 0.1+0.2 using javascript it gives  0.30000000000000004 instead of 0.3 . so here is the solution of perform mathematical operations on floating point numbers with javascript. We are using 2 js function for this 1. parseFloat   2. toPrecision javascript snippet to solve js floating point numbers wrong output problem. <script> function cal() {  var a=0.1;  var b=0.2;  var c=parseFloat((a+b).toPrecision(10)); //Calculate like this  alert("parseFloat((0.1 + 0.2).toPrecision(10)) = "+c); } </script>

Get your gmail emails using php

How to get your gmail emails using php here is the short n simple script to get your gmail inbox messages and you can store them into your database . $imapPath = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';  $username = 'your-mail@gmail.com'; $password = 'your-password'; // try to connect $inbox = imap_open($imapPath,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error()); $emails = imap_search($inbox,'UNSEEN'); $output = ''; foreach($emails as $mail) {         $headerInfo = imap_headerinfo($inbox,$mail);         $output .= $headerInfo->subject.'<br/>';     $output .= $headerInfo->toaddress.'<br/>';     $output .= $headerInfo->date.'<br/>';     $output .= $headerInfo->fromaddress.'<br/>';     $output .= $headerInfo->reply_toaddress.'<br/>';         $emailSt...

Solved-mail not send gmail smtp phpmailer

Solved-mail not send with phpmailer if you face problem to send mail from your localhost or live server you can use this code to solve your problem. function SendMail( $ToEmail,$subjectval, $MessageHTML, $MessageTEXT ) {      // require_once ( 'class.phpmailer.php' ); // Add the path as appropriate      include_once "webroot/phpmailer/PHPMailerAutoload.php";       $Mail = new PHPMailer();       $Mail->IsSMTP(); // Use SMTP       $Mail->Host        = "smtp.gmail.com"; // Sets SMTP server       $Mail->SMTPDebug   = 0; // 2 to enable SMTP debug information       $Mail->SMTPAuth    = TRUE; // enable SMTP authentication       $Mail->SMTPSecure  = "tls"; //Secure conection       $Mail->Port    ...

Send mail from localhost using phpmailer

 How to Send mail from localhost using phpmailer   To send mail from your localhost or live server you can use phpmailer class. phpmailer class sends mail using smtp from both local and live server .using phpmailer you can also send html. so these are the steps to send a mail from localhost using phpmailer. Step 1 First download phpmailer class from here . and after download unzip and extract it into your root directory ex(htdocs/yourprojectfolder/phpmailer/). Step 2 then create a form in your html to send mail    <form action="" method="post" onsubmit="return sendnewsletter()">                                                       <div class="form-body">      ...