Skip to main content

Posts

Showing posts from April, 2021

How to Create "Google Login" in Codeigniter?

Google Login Integration in Codeigniter Paste in Controller $uuser_id = ''; include_once(FCPATH.'googlelogin-library/vendor/autoload.php'); $google_client = new Google_Client(); $google_client->setClientId('975330128814-il47gqr1l99uleblged7altinhpm99g3.apps.googleusercontent.com'); //Define your ClientID $google_client->setClientSecret('c-6xwtqoC4DRXV_blQ9QB6Lu'); //Define your Client Secret Key $google_client->setRedirectUri(base_url().'login'); //Define your Redirect Uri $google_client->addScope('email'); $google_client->addScope('profile');   //echo '<pre>';  // print_r($google_client); //echo $_GET["code"];   if(isset($_GET["code"]))   {    $token = $google_client->fetchAccessTokenWithAuthCode($_GET["code"]);    if(!isset($token["error"]))    { $google_client->setAccessToken($t

How to fix font-awesome icons from error (has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.).

Fix font-awesome icons from error (has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.). Paste in htaccess file      <IfModule mod_headers.c>   <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css)$">     Header set Access-Control-Allow-Origin "*"   </FilesMatch> </IfModule>

How to create forgot password page with ajax in Codeigniter?

Create forgot password page with ajax in Codeigniter Forgot Password Paste in view file <!DOCTYPE html> <html lang="en"> <head>   <meta charset="utf-8">   <meta name="viewport" content="width=device-width, initial-scale=1">   <title>AdminLTE 3 | Forgot Password</title>   <!-- Google Font: Source Sans Pro -->   <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">   <!-- Font Awesome -->   <link rel="stylesheet" href="<?php echo base_url().'assets/new-template/'; ?>plugins/fontawesome-free/css/all.min.css">   <!-- icheck bootstrap -->   <link rel="stylesheet" href="<?php echo base_url().'assets/new-template/'; ?>plugins/icheck-bootstrap/icheck-bootstrap.min.css">   <!-- Theme style -->   <link rel="st

How to get next and preview post links in PHP (CodeIgniter).

 Get next and preview post links in PHP (CodeIgniter). Paste in Controller :- $id = 56;     // Current Post id  $blog_pages = $this->Post_Model->all_posts(); $idArray = array(); foreach($blog_pages as $m=>$o) {   $idArray[]= $o->id; } // Find the index of the current item $current_index = array_search($id, $idArray); // Find the index of the next/prev items $next = $current_index + 1; $prev = $current_index - 1;   // and now finally sent the data to view if(!empty($idArray[$prev])){ if(in_array($idArray[$prev],$idArray)){ $data['prev'] = $this->Post_Model->getpostbyid($idArray[$prev]); } } if(!empty($idArray[$next])){ if(in_array($idArray[$next],$idArray)){ $data['next'] = $this->Post_Model->getpostbyid($idArray[$next]);  } } Paste in Model:- public function all_posts() {             $query = $this->db->get('posts');      

How to calculate time(Seconds, Minutes, Hours, days , Years) from current date or days in PHP?

Calculate time(Seconds, Minutes, Hours, days , Years) from current date or days in PHP.   <!DOCTYPE html> <html> <body> <?php function calculate_time($old_date){ $current_time = date('Y-m-d H:i:s'); $date1 = new DateTime($old_date); $date2 = $date1->diff(new DateTime($current_time)); //print_r($date2); //echo $date2->days.'Total days'."\n"; $years = $date2->y; $months = $date2->m; $days = $date2->d; $hours = $date2->h; $min = $date2->i; $sec = $date2->s; if(!empty($years) && $years>0){ if($years == 1){ $cal_time = $years.' Year'; } else{ $cal_time = $years.' Years'; } } elseif(!empty($months) && $months>0){ if($months == 1){ $cal_time = $months.' month'; } else{ $cal_time = $months.' months'; } } elseif(!empty($days) && $days>0){ if($days == 1){ $cal_time = $days.' day'; } else{ $cal_time = $days.' days'