Posts

Showing posts with the label PHP

Google captcha validation with server side

Image
Create Captcha Credential here HTML:         < form   id = "registration"   name = "registration"   action = "#"   method = "POST" >          < input   type = "text"   name = "name"   placeholder = "Name"   />          < input   type = "email"   name = "email"   placeholder = "Email"   />          < input   type = "number"   name = "number"   placeholder = "Mobile Number"   />          < input   type = "password"   name = "password"   placeholder = "Password"   />          < div   class = "form-group" >              < div  ...

Send email using phpMailer

Image
Download PHPMailer Library PHP Content      <?php      if  ( $_SERVER [ 'REQUEST_METHOD' ] ==  'POST' ) {          require   'phpmailer/PHPMailerAutoload.php' ;          $name  =  $_POST [ 'namecontact' ];           $email  =  $_POST [ 'emailcontact' ];          $number  =  $_POST [ 'numbercontact' ];          $msg  =  $_POST [ 'messagecontact' ];          $mail  =  new   PHPMailer ();          $mail -> IsSMTP ();          $mail -> SMTPOptions  =  array (       ...

Redirect website multiple domain to single domain using htaccess

Image
Code: copy below code and create .htaccess file and past it.              RewriteEngine  on                RewriteCond   %{HTTP_HOST}   ^http://domainname.com  [OR]              RewriteCond   %{HTTP_HOST}   ^https://www.domainname.com  [OR]              RewriteCond   %{HTTP_HOST}   ^http://www.domainname.com  [OR]              RewriteCond   %{HTTP_HOST}   ^www.domainname.com              RewriteRule   ^(.*)$   https://domainname.com/$1  [R=permanent,L]             ...

Redirect http to https using htaccess

Image
Code: write below code in .htaccess file.          RewriteEngine  On             RewriteCond   %{HTTPS}   off              RewriteRule   ^(.*)$   https://%{HTTP_HOST}%{REQUEST_URI}  [L,R=301]   

Pretty url using htaccess

Image
Before URL: https://domainname.com/project.php?state=Delhi After URL: https://domainname.com/project/Delhi          RewriteEngine  on          RewriteBase  /          RewriteCond   %{THE_REQUEST}   /project\.php\?state=([^\s&]+)  [NC]           RewriteRule   ^   project/%1?  [R=302,L]           RewriteCond   %{REQUEST_FILENAME}   !-d          RewriteCond   %{REQUEST_FILENAME}   !-f          RewriteCond   %{THE_REQUEST}   /project\?([^\s&]+)  [NC]           RewriteRule   ^   project/%1?  [R=302,L]       ...

Hide php extension from url via htaccess

Image
Before URL:  https://domainname.com/about-us.php After URL:  https://domainname.com/about-us      RewriteEngine  On          RewriteCond   %{REQUEST_FILENAME}   !-d           RewriteCond   %{REQUEST_FILENAME}   !-f           RewriteCond   %{REQUEST_FILENAME}.php   -f           RewriteRule   ^(.*)$   $1.php  [L]     This will not remove the PHP extension automatically from the URL. You need to remove yourself you'll not get any error.  

Scan directory in php

Image
$handle  =  'E:\xampp\htdocs\path' ; function   listFolderFiles ( $dir ){      $ffs  =  scandir ( $dir );         foreach ( $ffs  as  $ff ){          if ( $ff  !=  '.'  &&  $ff  !=  '..' ){                           echo   $dir . '/' . $ff ;              echo   "<br />" ;              if ( is_dir ( $dir . '/' . $ff ))                       listFolderFiles ( $dir . '/' . $ff );           ...

Protect PDF using php

Image
Protect PDF using PHP. Download the library used: Protect PDF in PHP <?php function pdfEncrypt ($origFile, $password, $destFile){     //include the FPDI protection http://www.setasign.de/products/pdf-php-solutions/fpdi-protection-128/  require_once('fpdi/FPDI_Protection.php'); $pdf =& new FPDI_Protection(); // set the format of the destinaton file, in our case 6×9 inch // $pdf->FPDF('P', 'in', array('6','9')); $pdf->FPDF("P"); //calculate the number of pages from the original document $pagecount = $pdf->setSourceFile($origFile); // copy all pages from the old unprotected pdf in the new one for ($loop = 1; $loop <= $pagecount; $loop++) {       $tplidx = $pdf->importPage($loop);     $size = $pdf->getTemplateSize($tplidx);     $pdf->w; // Width of Current Page     $pdf->h; // Height of Current Page     $pdf->AddPage();     $pdf-...