Skip to main content

Posts

Cakephp 3x- Add Email verification on registration

How to add email verification on registration Cakephp 3.x In this tutorial we will add email verification on user register so whenever a new user registered in our site then he will receive an email with confirmation link and after confirmation link click , his account will activate. this tutorial is also for that users that want to learn how to setup email configration in cakephp 3.x. for basic knowledge you can check this post Send mail using mail class in cakephp 3 SO FOLLOW THESE SIMPLE STEPS TO VERIFY USER EMAIL ON REGISTRATION First we need to add one table with three columns id email and status . you can run below query to create a table CREATE TABLE `cake`.`users` ( `id` INT NOT NULL AUTO_INCREMENT , `email` VARCHAR(50) NOT NULL , `otp` VARCHAR(50) NOT NULL , `status` INT NOT NULL DEFAULT '0' , PRIMARY KEY (`id`)) ENGINE = InnoDB; Your database table should look like In this tutorial we will use gmail for smtp so first we need to configure EmailTra...

Cakephp 3x Add TinyMCE text editor in 2 Steps

Cakephp 3.x Add text editor in 2 Steps In this tutorial we will use TinyMCE because its easy to implement TinyMCE text editor Step 1 So First Add this js to your header or default layout or your preferred location where you call other js files <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>   <script> tinymce.init({ selector:'.edittextarea', height: 500,  plugins: [     'advlist autolink lists link print preview anchor',     'visualblocks code fullscreen',     'insertdatetime table contextmenu paste code'   ], }); </script>   Step 2 Now Add edittextarea class to textarea where you want to change textarea to text editor Here is the example of how to create text editor textarea in Cakephp 3.x  <?= $this->Form->input('description', array('type' => 'textarea','class' => 'edittextarea form-control','value'=>$description,...

Cakephp-3x-On debug Mode for controller or action

Cakephp 3.x On debug Mode for a specific controller or action To on debug mode for only one controller or action you should follow below steps:- First call configure into your controller at the top(check its already called then don't call it again) use Cake\Core\Configure; Then in your controller action paste this line or if you want it to on for all actions of a controller then paste this line into beforeFilter or initialize Configure::write('debug', 2);    Now run your controller action and your debug mode will be on for specific controller and action. On Debug mode only for specific IP Address If you want to on debug only for you or any specific IP Address then first get your ip address you can get ip address in cakephp using this code. use Cake\Network\Request; echo $this->request->clientIp(); OR with php $_SERVER['REMOTE_ADDR']; then you can use below code         $clientIpAddress = $this->request-...

PHP check a string contains specific value or string

How to check if a string having specific characters or string In PHP we can check with strpos() . strpos() is the simplest way to get string having search texts or not. Examples :- For examle here is a php string and we want to know that it contains "php" word or not. $a = 'Hello string do u have php word?'; The below line of code echo true if php word exist in string. if (strpos($a, 'php') !== false) { echo 'true'; } OR if (strpos($string, $word) === FALSE) { ... not found ... } Answer 2 We can also use preg_match() to determine that Example if (preg_match('/php/',$a)) {   echo 'true'; }

Install Cakephp with Composer on Linux

How to Install Cakephp with Composer on Linux System Here is the complete tutorial for how to install cakephp letest version with composer on linux system. If you dont have install composer then first you should install composer To install composer run the following commands one by one- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');" OR you can install composer with curl by using this command curl -sS https://getcomposer.org/installer | php these commands will download the latest composer.phar in the current directory...

Cakephp 3.x cake bake on linux system

How to Cakephp 3.x cake bake on linux system Cakephp gives an awesome feature that is bake. by using bake you can create controller models and views without coding . you just need to type some commands and cake will create files for you. So here is the simple steps for cake bake in cakephp 3.x on linux system 1.First Open your terminal window 2. install php5 on your system by using this command and press enter       sudo apt-get install php5-mysql 3. Now download letest cakephp 3.x zip file from cakephp github and unzip into your local server (ex. /op/lampp/htdocs/newcake/here all files) 4. Now in terminal change directory by this command and press enter       cd /opt/lampp/htdocs/newcake/ 5. Then run following command   bin/cake bake When you hit enter then you will see output like this  Welcome to CakePHP v3.3.4 Console --------------------------------------------------------------- App : src Path: ...

Simply Create PDF with PHP mysql FPDF (2 steps)

Simply Create PDF with fpdf Sometimes we need to generate pdf based on mysql database so here is the example of How to create PDF with PHP mysql using FPDF in 2 Steps. Step1 First Download fpdf from Here Step 2 Create an index.php file and paste this code <?php include('../config.php'); require('webroot/fpdf/fpdf.php'); $aClassDb = new ClassDb(); class Getdata { public function all($getPostdata) { $getData = ""; try { $getApartment = $getPostdata['apartid']; $getYear = $getPostdata['invoiceyear']; $startdate = mktime(0,0,0,1,1, $getYear); $enddate = mktime(0,0,0,12,31, $getYear); $query = $aClassDb->getAllData("invoice", "AND appartment='$getApartment' AND date_invoice BETWEEN $startdate AND $enddate"); $getData = $query; /* PDO $db = new PDO('mysql:host=localhost;dbname=test;', 'root'...