Posts

Setup of Google reCAPTCHA

Image
What is CAPTCHA? The term CAPTCHA (for Completely Automated Public Turing Test To Tell Computers and Humans Apart) was coined in 2000 by Luis von Ahn, Manuel Blum, Nicholas Hopper and John Langford of Carnegie Mellon University. A CAPTCHA is protects websites against bots by generating and grading tests that humans can pass but current computer programs cannot. Google create program and name it reCAPTCHA . Follow this steps for setup reCAPTCHA For setup first create keys for auth. reCAPTCHA Genrate keys Click here Now in page where use captcha  add script before </head> tag close. <script src='https://www.google.com/recaptcha/api.js'></script> Add this div tag when display capcha <div class="g-recaptcha" data-sitekey="**yoursitekey**"></div> add this code when you action for captcha. (php scipt) if( !empty($_POST['g-recaptcha-response'])){             $secret = '**Yoursecr

CRUD operation with ajax functions

Image
Hear we show a basic CRUD operation with database with ajax function. Points : Connection with database  HTML form page Ajax function  JavaScript Insert data Update data Delete data View data First create one PHP file call connect.php  in this file contain a connection of database and this file call in other file for connecting with database. <?php $con=mysqli_connect("server name","username","password","databasename") or die(''.mysql_error()); ?> Now we create second file that include HTML of form and javascript. Create file name index.php <html>     <head>         <meta charset="UTF-8">         <title>test form</title>         <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>     </head>     <body>         <form onsubmit="return false&q

How to set self page in form action?

In PHP some developer use same page for code and some use separate page for code of PHP script.so who use same page to script, they set page path in form tag as action.for that not set every time path of page use common code to put path of page. htmlspecialchars($_SERVER["PHP_SELF"]);  This code put in action attribute of form tag. this get current page path directly. For ex. <form name="test"  action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post" >                    //Your code </from>

Let's make a webservice in php

It's easy to create web service in php. First create one php file in your website folder like " firstwebservice.php ". and open this file in any text editor. Now copy this code and past in file. <?php //add header for json header("Content-Type:application/json"); //if you send url paramers if(!empty($_REQUEST))     {         //url parameter "param"         if(isset($_REQUEST["param"]))         {             try             {                 $param=$_REQUEST['param'];                                  $response['status'] = 200;                 $response['param'] = $param;                                //return output as json format                 echo json_encode($response);             }             catch(Exception $ex)             {                 $error = array(                     "status"=> 500,                     "message"=>".$ex->getMessage()."               

PHP Syntax

 PHP Syntax Default file extension for php code is " .php ". .php file can have HTML tags, JavaScripts, PHP scripts.  A PHP script can be placed anywhere in the page. <?php code hear ?>  for print or display normaly userd "echo". Example <html>        <head>       </head>       <body>              <?php echo 'hello php!' ; ?>       </body>  </html>

What is PHP?

What is PHP? PHP is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. PHP is an HTML-embedded scripting language . Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly. PHP stands for PHP: Hypertext Preprocessor . This confuses many people because the first word of the acronym is the acronym. This type of acronym is called a recursive acronym.  PHP as it's known today is actually the successor to a product named PHP/FI. Created in 1994 by Rasmus Lerdorf, the very first incarnation of PHP was a simple set of Common Gateway Interface (CGI) binaries written in the C programming language. Originally used for tracking visits to his online resume, he named the suite of scripts "Personal Home Page Tools," more frequently ref