Skip to main content

Posts

Showing posts from January, 2016

Simple Form Validation for All Fields Required with Jquery

Simple Form Validation for All Fields Required Function 1 function trythis() {         var incomplete = $('.required').filter(function() {                              return $(this).val() === '';                          });         if(incomplete.length) {             alert('All fields are required');             //to prevent submission of the form             return false;         }      } Function 2 function validateForm() {   v...

Create Image Captcha in PHP

Create Image Captcha in PHP <?php session_start(); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); function _generateRandom($length=6) {     $_rand_src = array(         array(48,57) //digits         , array(97,122) //lowercase chars //        , array(65,90) //uppercase chars     );     srand ((double) microtime() * 1000000);     $random_string = "";     for($i=0;$i<$length;$i++){         $i1=rand(0,sizeof($_rand_src)-1);         $random_string .= chr(rand($_rand_src[$i1][0],$_rand_src[$i1][1]));     }     return $...

Create Login Check file in php

<?php require_once('function.php'); if(!isset($_SESSION['admin']['id'])){ $url = admin_url."index.php"; Redirect($url); } TYPE 2 <?php     include("includes/admin-config.php");         $logqry = "select * from admin where username='".$_REQUEST['uname']."' and password='".$_REQUEST['pwd']."'";     if($logrec = $db->query($logqry,database::GET_ROW))     {         $id=$logrec["id"];                 //echo $id;         $_SESSION['admin_id']=$logrec["id"];         $_SESSION['admin_name']=$logrec["username"];                 if($link1!="")         {             //print "<META http-equiv='refresh' content='0;UR...

Create function file in php

<?php class Data {               /************************   Insert Query   **************************************/   function insert_item($tablename,$data) {         $data_sql='';                 $msg='';         foreach($data as $field => $value)         {         $data_sql .= $field."='".$value."',";         }                 $data_sql=rtrim($data_sql,",");                 $sql="insert $tablename SET  $data_sql";                      ...

how to convert speech to text with gogle api

<?php   // Convert Words (text) to Speech (MP3) // ------------------------------------   // Google Translate API cannot handle strings > 100 characters    $words = substr ( $_GET [ 'words' ] , 0 , 100 ) ;   // Replace the non-alphanumeric characters // The spaces in the sentence are replaced with the Plus symbol    $words = urlencode ( $_GET [ 'words' ] ) ;   // Name of the MP3 file generated using the MD5 hash    $file    = md5 ( $words ) ;    // Save the MP3 file in this folder with the .mp3 extension    $file = "audio/" . $file . ".mp3" ;   // If the MP3 file exists, do not create a new request    if ( ! file_exists ( $file ) ) {      $mp3 = file_get_contents (          'http://translate.google.com/translate_tts?q=' . $words ;      file_put_...

How to retrieve Facebook Likes, share , comment Counts

function facebook_count($url){     // Query in FQL     $fql  = "SELECT share_count, like_count, comment_count ";     $fql .= " FROM link_stat WHERE url = '$url'";     $fqlURL = "https://api.facebook.com/method/fql.query?format=json&query=" . urlencode($fql);     // Facebook Response is in JSON     $response = file_get_contents($fqlURL);     return json_decode($response); } $fb = facebook_count('https://www.facebook.com/BahutHoGyiPadhai'); // facebook share count echo $fb[0]->share_count;  echo "like"; // facebook like count echo $fb[0]->like_count ; echo "comment"; // facebook comment count echo $fb[0]->comment_count;  ?>

How to fetch product fom flipkart

<?php $content = file_get_contents("http://stackoverflow.com/questions/18049289/how-to-fetch-data-text-from-an-external-website-with-php-if-possible"); //print_r($content); ? http://www.flipkart.com/samsung-galaxy-on5/p/itmedhx3uy3qsfks?pid=MOBECCA5FHQD43KA&al=OVGKKfDmwQTN6O85o2%2BD0MldugMWZuE7Qdj0IGOOVquS3ymugNFh%2BcWgDvEB%2BoXknGEqmG%2Fg55Q%3D&ref=L%3A4113169617862935247&srno=b_1 $url = "http://www.flipkart.com/samsung-galaxy-on5/p/itmedhx3uy3qsfks?pid=MOBECCA5FHQD43KA&al=OVGKKfDmwQTN6O85o2%2BD0MldugMWZuE7Qdj0IGOOVquS3ymugNFh%2BcWgDvEB%2BoXknGEqmG%2Fg55Q%3D&ref=L%3A4113169617862935247&srno=b_1&affid=amitlabnol"; $response = getPriceFromFlipkart($url); //echo json_encode($response);  ?>  <div class="product">      <a href=""     <b><?php echo $response['title']; ?></b><br />     <img src="<?php echo $response['image']; ?>" name="product_im...

PHP Array Functions

PHP Array Constants Sr.No Constant & Description 1 CASE_LOWER Used with array_change_key_case() to convert array keys to lower case 2 CASE_UPPER Used with array_change_key_case() to convert array keys to upper case 3 SORT_ASC Used with array_multisort() to sort in ascending order 4 SORT_DESC Used with array_multisort() to sort in descending order 5 SORT_REGULAR Used to compare items normally 6 SORT_NUMERIC Used to compare items numerically 7 SORT_STRING Used to compare items as strings 8 SORT_LOCALE_STRING Used to compare items as strings, based on the current locale 9 COUNT_NORMAL 10 COUNT_RECURSIVE 11 EXTR_OVERWRITE 12 EXTR_SKIP 13 EXTR_PREFIX_SAME 14 EXTR_PREFIX_ALL 15 EXTR_PREFIX_INVALID 16 EXTR_PREFIX_IF_EXISTS 17 EXTR_IF_EXISTS 18 EXTR_REFS List of Functions PHP − indicates the earliest version of PHP that supports the functio...