Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Tuesday 16 February 2016

image upload with compress image and add text into image in using php

Hello Here Example Image compress and add text into image

<?php
function compress_image($source_url, $destination_url, $quality) {
  $info = getimagesize($source_url);
if ($info['mime'] == 'image/jpeg') $image = imagecreatefromjpeg($source_url);
elseif ($info['mime'] == 'image/gif') $image = imagecreatefromgif($source_url);
elseif ($info['mime'] == 'image/png') $image = imagecreatefrompng($source_url);
 // Set Path to Font File
$color = imagecolorallocate($image, 255, 255, 255);

//x-coordinate of the upper left corner.
$xPos = 600;
//y-coordinate of the upper left corner.
$yPos = 200;

//Writting the picture
imagestring($image,5,$xPos,$yPos,"Add Your Text Here",$color);
imagejpeg($image, $destination_url, $quality);



return  $destination_url;
}
if(isset($_POST['submit'])){
$tempPath = $_FILES['upload']['tmp_name'];
$mypath = "compress";
if(!is_dir($mypath)){
mkdir($mypath);
}
 $filename = $_FILES['upload']['name'];
 $destination = $mypath."/".$filename;

$destination  =   compress_image($tempPath,$destination,90);
}
?>

<form method="post" enctype="multipart/form-data">

<input type="file" name="upload"/>
<input type="submit" name="submit" value="upload"/>

</form>

Saturday 30 January 2016

Insert Csv File Data in Mysql using Php with Validation

Insert Csv File Data in Mysql using Php with Validation  Full Example

Sample Csv File Test.csv

<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://jqueryvalidation.org/files/dist/jquery.validate.min.js"></script>
<script src="http://jqueryvalidation.org/files/dist/additional-methods.min.js"></script>

<script type="application/javascript">
$(document).ready(function(e) {
    $('#pincodeList').validate({
        rules: {
            Csv: {
                required: true,
extension: "xls|csv"
              
            }

        },

    messages: {
        Csv: {
            extension: 'Please upload a csv file!'
        }
}

    });
});
</script>

<?php
include('connect.php');


if($_POST['submit']){
$csv_file = $_FILES['Csv']['name'];
$tmpFilePath =$_FILES['Csv']['tmp_name'];
$newFilePath="pincodeUpload/";
$mypath = "pincodeUpload/".$csv_file;
move_uploaded_file($tmpFilePath, $mypath);
if ( ! is_dir($newFilePath)) {

mkdir($newFilePath);

$csv_file =$mypath;

if (($handle = fopen($csv_file, "r")) !== FALSE) {

   fgetcsv($handle);  
   while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
         $num = count($data);
        for ($c=0; $c < $num; $c++) {
           $col[$c] = $data[$c];
        }

    $col1 = $col[0];

  
// SQL Query to insert data into DataBase
$query = "INSERT INTO pincode(Pincode) VALUES('$col1')";
$s     = mysql_query($query);
 }
    fclose($handle);
}

}

?>

<form id="pincodeList" name="pincodeList" method="post" enctype="multipart/form-data">
               <div class="row">
               <div class="co-md-3 col-sm-6">
<input  type="file" name="Csv" >
                </div>
                <div class="co-md-3 col-sm-6">
<input class="btn btn-success" type="submit" name="submit" value="Upload Csv"/>
                </div>
                </div>
</form>

Wednesday 20 January 2016

Upload Multiple-image Using Webservice in PHP



Hello
Upload Multiple-image Using Webservice in PHP

<?php



 
  if(isset($_POST['submit'])){
 
 
for($i=0; $i<count($_FILES['upload']['name']); $i++) {

/** valiation  only 1 Mb File Upload **/
if($_FILES['upload']['size'][$i] > 1048576){
$notice_image = '<div class="alert alert-info fade in">
    <a title="close" aria-label="close" data-dismiss="alert" class="close" href="#">×</a>
    <strong>Info!</strong> Image Size Must Be Less Than 1 Mb. Your Image is "'.$_FILES['upload']['name'][$i].'"
</div>';

}else{

$tmpFilePath =$_FILES['upload']['tmp_name'][$i];


//Make sure we have a filepath
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "ProductImg/";

if ( ! is_dir($newFilePath)) {

mkdir($newFilePath);


$picture =uniqid()."_".$_FILES['upload']['name'][$i];
$mypath = "ProductImg/".$picture;
//Upload the file into the temp dir
// if(move_uploaded_file($tmpFilePath, $mypath)) {
if(!file_exists($mypath)){
//move_uploaded_file($tmpFilePath, $mypath);
/** remove Comment when not use webservice*/

 
 
if(!empty($picture))
  {

 
$data = base64_decode($_FILES['upload']['name'][$i]);
$file = fopen($mypath, "w");
fwrite($file,$data);
fclose($file);
  }


}

}


}
}

}
?>

<form method="post" enctype="multipart/form-data">
<?php echo $notice_image; ?>
<input type="file" name="upload[]" multiple="multiple" >
<input type="submit" name="submit" value="save">

</form>

Monday 18 January 2016

Get longitude and latitude using address with php

Get longitude and latitude using address with php 

here The Example For that.

function Get_LatLng_From_Google_Maps($address) {
    $address = urlencode($address);

    $url = "http://maps.googleapis.com/maps/api/geocode/json?address=$address&sensor=false";

    // Make the HTTP request
    $data = @file_get_contents($url);
    // Parse the json response
    $jsondata = json_decode($data,true);

    // If the json data is invalid, return empty array
    if (!check_status($jsondata))   return array();

    $LatLng = array(
        'lat' => $jsondata["results"][0]["geometry"]["location"]["lat"],
        'lng' => $jsondata["results"][0]["geometry"]["location"]["lng"],
    );

    return $LatLng;
}

/*
* Check if the json data from Google Geo is valid
*/

function check_status($jsondata) {
    if ($jsondata["status"] == "OK") return true;
    return false;
}

/*
*  Print an array
*/

function d($a) {
    echo "<pre>";
    print_r($a);
    echo "</pre>";
}
$address="bhavnagar,gujrat,india";
$arry_lat_lag = Get_LatLng_From_Google_Maps($address);

Monday 28 December 2015

Get near by Location using latitude and longitude from php and mysql in google map Kilometer

Get near by Location using latitude and longitude from php and mysql in google map Kilometer

To search by miles  instead of kilometers, replace 6371 with .3959

<?php


$username="root";
$password="";
$database="googlemap";



// Get parameters from URL
$center_lat = 23.036730;
$center_lng = 72.516373;
$radius = 6;


$connection=mysql_connect ("localhost", $username, $password);
if (!$connection) {
  die("Not connected : " . mysql_error());
}

// Set the active mySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
  die ("Can\'t use db : " . mysql_error());
}

// Search the rows in the mstuser table
$query = sprintf("SELECT usermail, res_name, lat, lng, ( 6371  * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance FROM mstuser HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20",


  mysql_real_escape_string($center_lat),
  mysql_real_escape_string($center_lng),
  mysql_real_escape_string($center_lat),
  mysql_real_escape_string($radius));

  /*$query = sprintf("SELECT address, name, lat, lng, ( 3959 * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20",


  mysql_real_escape_string($center_lat),
  mysql_real_escape_string($center_lng),
  mysql_real_escape_string($center_lat),
  mysql_real_escape_string($radius));*/
$result = mysql_query($query);

$result = mysql_query($query);
if (!$result) {
  die("Invalid query: " . mysql_error());
}

header("Content-type: application/json");
$i=0;
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){


  $data[$i]['usermail'] = $row['usermail'];
  $data[$i]['res_name'] = $row['res_name'];
  $data[$i]['lng'] = $row['lng'];
  $data[$i]['lat'] = $row['lat'];
  $data[$i]['distance'] = $row['distance'];

  $i++;

}

echo json_encode($data);
?>

Sunday 6 December 2015

Split String with comma Loop in Mysql store Proceture Example

Hello

Here Very Usefull for Split String with comma Loop in Mysql store Proceture Example

Split String with comma Loop in Mysql store proceture
this fully example how to use

Loop In Mysql

and split string in mysql

begin
  
   
   
    SET @InitCounter := 1;
      SET @Param := "11,22,33,44,";
    
 
  
  
      
    myLoop: loop 
   
 SET @NextCounter := LOCATE(',',@Param);

 SET @SUBSTR := SUBSTRING(@Param,@InitCounter,@NextCounter);

 SET @Param := REPLACE(@Param,@SUBSTR,'');

 SET @SUBSTR:= REPLACE(@SUBSTR,',','');

 SET @ParamLength := LENGTH (@Param);


 SELECT @SUBSTR;




                      
        if  
       
             @ParamLength = 0
        then
            leave myLoop;             
        end if;
       
    end loop myLoop;                   
   
END

Monday 16 November 2015

how to remove index and unique constraint in mysql

Hello

here Example of remove how to remove index and unique constraint in mysql

first check table how many constraint  in table after you can remove.

here the query for show index in table

SHOW INDEX FROM Your-table-Name

after remove all index name display in column

here the query

ALTER TABLE Your-table-Name DROP INDEX Your-field-unique-constraint -name;

Please check this 

Login With Facebook Using javascript SDK Example

Hello

Here Example of Facebook Login With Javascript SDK
the login flow step-by-step and explain each step clearly - this will help you if you are trying to integrate Facebook Login into an existing login system, or just to integrate it with any server-side code you're running. But before we do that, it's worth showing how little code is required to implement login in a web application using the JavaScript SDK.

Create Login.php File

Code For Login.php

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
function facebook_login (){
    if(typeof(FB) == "undefined") {
        alert("Facebook SDK not yet loaded please wait.")
      }
    FB.getLoginStatus(function(response) {
      if (response.status === 'connected') {
        console.log('Logged in.');
        basicAPIRequest();

      }
      else {
       FB.login(function(response) {
 
      if (response.status === 'connected') {
        console.log('Logged in.');
        basicAPIRequest();
  }
 
}, {scope: 'email,user_birthday,user_location,public_profile,publish_actions'});

      }
    });    
}

  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'your-app-id',
      xfbml      : true,
   status     : true, // check login status
      version    : 'v2.0'
    });

FB.Event.subscribe('auth.login', function () {
         basicAPIRequest()
      });

  };

 
  

  
  
   (function(d, s, id){
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(s); js.id = id;
     js.src = "//connect.facebook.net/en_US/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));


function basicAPIRequest() {
    FB.api('/me',
        {fields: "id,about,age_range,picture,bio,birthday,context,email,first_name,gender,hometown,link,location,middle_name,name,timezone,website,work"},
        function(response) {
         console.log('API response', response);
         /*  $("#fb-profile-picture").append('<img src="' + response.picture.data.url + '"> ');
          $("#name").append(response.name);
          $("#user-id").append(response.id);
          $("#work").append(response.gender);
          $("#birthday").append(response.birthday);
          $("#education").append(response.hometown);
  $("#email").append(response.email);*/
 

 
  $.ajax({
  url: "facebook_login_query.php",
  data: {
  email:response.email,
  birthday : response.birthday,
  gender : response.gender
  },
  success: function( response ) {
alert(response);
window.location.href = "http://localhost/home.php";
return false;
 
  }
 

});
 
        }
    );
  }



</script>
<!--<div  class="fb-login-button" data-scope="email,user_birthday,user_hometown,user_location,user_website,user_work_history,user_about_me
" data-max-rows="1" data-size="medium" data-show-faces="false" data-auto-logout-link="true"  >
</div>
</div> -->


<button id='load' onClick="facebook_login();">Load data</button>
</html>

Create facebook_login_query.php

<?php
include('connect.php');
session_start();


 echo $uname = $_GET['email'];


if(!is_null){
echo $newbirthday = $_GET['birthday'];
echo $birthday = date("Y-m-d", strtotime($newbirthday));

}else{
$birthday= '';
}
echo $gender = strtolower($_GET['gender']);



   $select="select * from mstuser where username='$uname' and facebook_login='1' and  isActive = '1' AND isDelete = '0'";
$result=mysql_query($select);

  $total_result = mysql_num_rows($result);
if($total_result == 1){

$row = mysql_fetch_assoc($result);
  $_SESSION['vid']=$row['id'];
$_SESSION['username'] = $row['username'];
  $roleid = $row['roleid'];
$count=mysql_num_rows($result);


}else{
echo "insert into mstuser set username='$uname',facebook_login='1',isActive = '1',isDelete = '0' ";
  $insert_mstuser = mysql_query("insert into mstuser set username='$uname',facebook_login='1',isActive = '1',isDelete = '0' ");



  $select="select * from mstuser where username='$uname' and facebook_login='1' and  isActive = '1' AND isDelete = '0'";
$result=mysql_query($select);
$row = mysql_fetch_assoc($result);
  $_SESSION['vid']=$row['id'];
  $roleid = $row['roleid'];
$_SESSION['username'] = $row['username'];
$count=mysql_num_rows($result);



}
?>

Create Home.php

echo "Welcome user";

Tuesday 3 November 2015

Get Country State and City using JavaScript ajax and php

Hello

Here Example Of set your country,state,city using javascript ajax and php

Country State City Dropdown Using Ajax. ... In the onChage event of the country drop down we have called showhint() function of the javascript and also get current state of city using show_city();

Full Code

--
-- Table structure for table `city`
--

CREATE TABLE `city` (
  `id` int(11) NOT NULL auto_increment,
  `cid` int(11) NOT NULL,
  `sid` int(11) NOT NULL,
  `city_name` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

--
-- Dumping data for table `city`
--

INSERT INTO `city` (`id`, `cid`, `sid`, `city_name`) VALUES
(1, 1, 1, 'ahmedabad'),
(2, 1, 1, 'rajkot'),
(3, 2, 3, 'afarica city 1'),
(4, 2, 4, 'afarica city 2');

-- --------------------------------------------------------

--
-- Table structure for table `country`
--

CREATE TABLE `country` (
  `id` int(11) NOT NULL auto_increment,
  `countryname` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `country`
--

INSERT INTO `country` (`id`, `countryname`) VALUES
(1, 'india'),
(2, 'africa');

-- --------------------------------------------------------

--
-- Table structure for table `state`
--

CREATE TABLE `state` (
  `id` int(11) NOT NULL auto_increment,
  `cid` int(11) NOT NULL,
  `s_name` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

--
-- Dumping data for table `state`
--

INSERT INTO `state` (`id`, `cid`, `s_name`) VALUES
(1, 1, 'gujrat'),
(2, 1, 'bihar'),
(3, 2, 'afarica state1'),
(4, 2, 'afarica state 2');

all_date.php file

<script>
function showHint(str) {

    if (str.length == 0) {
        document.getElementById("txtHint").innerHTML = "";
        return;
    } else {
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {


                document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET", "getstate.php?q=" + str, true);
        xmlhttp.send();
    }

}

function showCity(str) {


    if (str.length == 0) {
        document.getElementById("txtCity").innerHTML = "";
        return;
    } else {
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {


                document.getElementById("txtCity").innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET", "getcity.php?q=" + str, true);
        xmlhttp.send();
    }

}

</script>

<?php

mysql_connect("localhost","root","");

mysql_select_db('test_country');

$get_country = mysql_query("select * from country");



?>
<label> country</label>

<select name="country" onchange="showHint(this.value)" >
<option value="0" >select country</option>
<?php
while($row_country = mysql_fetch_assoc($get_country)){ ?>


<option value="<?php echo $row_country['id']; ?>"/>
<?php echo $row_country['countryname'];  ?>
</option>


<?php
}
?>
</select>
<select name="state" id="txtHint" onchange="showCity(this.value)" >
</select>

<select name="city" id="txtCity">
</select>
</br>

getstate.php file

<option value="0" >select state</option>
<?php
mysql_connect("localhost","root","");

mysql_select_db('test_country');

$q=$_GET['q'];

echo $select_state= mysql_query("select * from state where cid=".$q);

while($result_state= mysql_fetch_array($select_state)){ ?>

<option value="<?php echo $result_state['id']; ?>"><?php echo $result_state['s_name']; ?></option>

<?php }
?>

getcity.php file

<option value="0" >select City</option>
<?php
mysql_connect("localhost","root","");

mysql_select_db('test_country');

$q=$_GET['q'];

echo $select_state= mysql_query("select * from city where sid=".$q);

while($result_state= mysql_fetch_array($select_state)){ ?>

<option value="<?php echo $result_state['id']; ?>"><?php echo $result_state['city_name']; ?></option>

<?php }
?>

Monday 2 November 2015

How to Get Difference Between Two date in php

Hello,

Here Example of get difference between two dates in year,month and days.

You can use strtotime() to convert two dates to unix time and then calculate the number of seconds between them. From this it's rather easy to calculate different time periods.

<?php

$date1 = "2014-03-24";
$date2 = "2015-06-26";

$diff = abs(strtotime($date2) - strtotime($date1));

$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));




echo "Get Your Year diffrernce:-".$years."year";
echo "<br/>";
echo "Get Your Year diffrernce:-".$months."months";
echo "<br/>";
echo "Get Your Year diffrernce:-".$days."days";

Monday 28 September 2015

include , require and require_once , include_once in php

 include , require and require_once , include_once in php 


include, require and require_once,include_once are used to include a file into the PHP code

for example of include and require

<h1>Welcome to My blog!</h1>
<?php include 'header.php';
?>

it can added file in php code.

in require example

<h1>Welcome to My blog!</h1>
<?php require 'header.php';
?>

difference between  include and require

 when a file is included with the include statement and PHP cannot find it, the script will continue to execute

and

the echo statement will not be executed because the script execution dies after the require statement returned a fatal error

include_once 

It can be used include a PHP file another one, it can used to add files once. If it is found that the file has already been included, calling script is going to ignore further inclusions.

Syntax



include_once('name of the called file with path');

example 

<?php include_once('xyz.php'); 

?>

same as require_once used.

<?php require_once('example.php')  ?>

include_once and require_once same different with include and require.




Difference between Echo And Print In Php

Hello,

Here I can Give both of use echo and print in php. I give example and use.

Echo and Print are almost same. they are both output on screen. they are used with and without
parentheses.

Difference Echo And Print



  1. print return value and echo not return value.
  2. echo faster than print.
  3.  echo without parentheses can take multiple parameters, which get concatenated but print give error.

How Can Use.



$data = "hello".
$data1 ="jaydip";

echo "<h2>My echo information</h2>";
echo "namste !<br>";

echo $data."".$data1;


echo without parentheses can take multiple parameters 
echo "jj","123",1,3;

same like in Print:

$data = "hello".
$data1 ="jaydip";

print "<h2>My echo information</h2>";
print "namste !<br>";

print $data."".$data1;

you can use as print in 
$test=1;
($test==2) ? print "true" : print "false";


Friday 28 August 2015

Use Ternary Operator in Php

Hello

I am Here Create Some Example How to use Ternary operator in php.

Ternary Operator use as simple if and else condition

$bool_val = 5;

echo ($bool_val <= 5) ? 'true' : 'false';.

it result is true.

if $bool_val = 6. then out put will be different. it false.

before ? it's like if condition  and : else condition.

For Check this

<?php
$age = 18;
    $agestr = ($age < 18) ? 'child' : 'adult';

it same like this

<?php
      if ($age < 16) {
        $agestr = 'child';
    } else {
        $agestr = 'adult';
    }
 

?>

here

another example


        $valid = false;
    $lang = 'french';
    $x = $valid ? ($lang === 'french' ? 'oui' : 'yes') : ($lang === 'french' ? 'non' : 'no');
 
    echo $x;

like this

if($valid){
   
    if($lang === 'french')
    {
        $x='oui';
    }else{
        $x = 'yes';
    }
} else{
   
      if($lang === 'french')
    {
        $x='non';
    }else{
        $x = 'no';
    }
   
}
echo $x;




Tuesday 9 June 2015

Implode And Explode Function In Php

Hello All,

Here I Want give example of how to use implode and explode in php.

Use of Implode 


=> The implode() function returns a string from the elements of an array. separator parameter of implode() is optional.

I give example for it.


$array = array("hello","all","be","happy","always");

$result =  implode($array);

echo $result;

it result will be => helloallbehappyalways.

if you can separate array using space then you can write this way

 $result =  implode(" ",$array);

this result will me => hello all be happy always

you can any of parameter to separate array;

like i give emaple for it


echo $result =  implode("$",$array)."<br/>";
echo $result =  implode("+",$array)."<br/>";
echo $result =  implode("-",$array)."<br/>";
echo  $result =  implode("*",$array)."<br/>";

this result will me =>

hello$all$be$happy$always
hello+all+be+happy+always
hello-all-be-happy-always
hello*all*be*happy*always

I think yon can understand what implode work it can make string of array using separate
by it parameter.you can use different parameter that can separate it. 

Use of Explode

=> this function use of breaks a string into an array.separator parameter cannot be empty string.

i will give example for it.

$string = "Lorem Ipsum is simply dummy text of the printing and typesetting industry";
$result = explode(" ",$string);
print_r($result);

this result will be=>
Array ( [0] => Lorem [1] => Ipsum [2] => is [3] => simply [4] => dummy [5] => text [6] => of [7] => the [8] => printing [9] => and [10] => typesetting [11] => industry )

if you want to separate to this different word.

if you to get separate word then check below code

echo "<br/>";
 $count = count($result);
 
 for($i=1;$i<=$count;$i++){
    
    $line =  each($result);
    print_r($line);
    echo "<br/>";
    echo $line['value']."<br/>";
 }

this out put will be
=>
Lorem
Array ( [1] => Ipsum [value] => Ipsum [0] => 1 [key] => 1 )
Ipsum
Array ( [1] => is [value] => is [0] => 2 [key] => 2 )
is
Array ( [1] => simply [value] => simply [0] => 3 [key] => 3 )
simply
Array ( [1] => dummy [value] => dummy [0] => 4 [key] => 4 )
dummy
Array ( [1] => text [value] => text [0] => 5 [key] => 5 )
text
Array ( [1] => of [value] => of [0] => 6 [key] => 6 )
of
Array ( [1] => the [value] => the [0] => 7 [key] => 7 )
the
Array ( [1] => printing [value] => printing [0] => 8 [key] => 8 )
printing
Array ( [1] => and [value] => and [0] => 9 [key] => 9 )
and
Array ( [1] => typesetting [value] => typesetting [0] => 10 [key] => 10 )
typesetting
Array ( [1] => industry [value] => industry [0] => 11 [key] => 11 )
industry

if you want to get only word echo $line['value]; use it and print_r($line); comment it.

you can also limit parameter to return a number of array elements

check this example

$string = "Lorem,Ipsum,is,simply,dummy,text,of,the,printing,and,typesetting,industry";

if you want to only 1 key then code this

print_r(explode(',',$string,0));

this result will =>
Array ( [0] => Lorem,Ipsum,is,simply,dummy,text,of,the,printing,and,typesetting,industry )

if you want 2 key then

print_r(explode(',',$string,2));

this result will=>
Array ( [0] => Lorem [1] => Ipsum,is,simply,dummy,text,of,the,printing,and,typesetting,industry )

if you want all key then you can use this code

print_r(explode(',',$string,-1));


this result will be =>

Array ( [0] => Lorem [1] => Ipsum [2] => is [3] => simply [4] => dummy [5] => text [6] => of [7] => the [8] => printing [9] => and [10] => typesetting )

this use of explode and implode. explode use for string to array and implode use for array to string.

 



 

Email Already Exit Using Jquery And Php

Hello All,

I am Simple Learn How to check email already exit. I am create code and check if

email already exit then you cannot submit  and also also validation of email.

I am give the code for that you can check it and use it.

you have to create to file

1)email.php
2)check.php

in your email.php wriite this code

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
 
   $("#myform").submit(function(){
 
       if(!emailok)
       {
        alert('check your email');
        return false;
       }
   
    });
$('#email').blur(function(){
   alert($('#email').val());
    $.ajax({
        type:"post",
        data:"email="+$('#email').val(),
        url:"check.php",
        beforeSend:function(){
            $("#email_info").html("checking email...");
        },
        success:function(data){
         
            if(data == "invalid"){
                $("#email_info").html("check your Email");
           
       
            emailok = false;
            }else if(data !="0"){
                  $("#email_info").html("email already exit");
             
            }else{
            emailok = true;
            $("#email_info").html("email ok");
            }
         
         
        }
     
     
     
    });
 
    });
});
</script>
<form id="myform" method="post">
<input type="text" id="email" name="email"/>
<input type="submit" />
</form>
<div id="email_info"></div>


second file is check.php

add this code

<?php
 $dbhost = 'localhost';
   $dbuser = 'root';
   $dbpass = '';
   $conn = mysql_connect($dbhost, $dbuser, $dbpass);
   if(! $conn )
   {
     die('Could not connect: ' . mysql_error());
   }

 
   mysql_select_db('blog',$conn);
 
   $email = $_POST['email'];
 
   if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
 
   $sql =  mysql_query('select email from email where email="'.$email.'"' );
 
   $result = mysql_fetch_array($sql);
 
 
 
    echo $num = mysql_num_rows($sql);
 }else{
 
    echo "invalid";
 }
 
 
 
 
 
 
   mysql_close($conn);
?>

table code

--
-- Table structure for table `email`
--

CREATE TABLE IF NOT EXISTS `email` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(200) NOT NULL,
  `password` varchar(200) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `email`
--

INSERT INTO `email` (`id`, `email`, `password`) VALUES
(1, 'test@gmail.com', 'test'),
(2, 'teset@gmail.com', 'test');

Monday 11 May 2015

Change xampp or Wamp apache port number

Hello All,

Chnage xampp or wamp apache port number 


I am Just here Tell you How to change xampp or wamp apache port number.
Chnage xampp or wamp apache port number


In Wamp and xampp apache port in 80. 80 is it's defualt port in wamp and xampp.

so some time issue with in skyppe,sql server because then also use port 80.

if we want to use xamp and wamp port 80 then we can stop service sql sql.

and in skypee you can stop to use 80 port then follow below step

1) first goto skypee 
2) tools -> options
3)in options -> advance tab -> connection
4) Then un check the check box of use port 80 and 443 for addtions incoming connections

Change Wamp apache port number 

Step1 ) Open file "httpd.conf" with notepad++ or any editor you can use like (dream viewer,PHP designer) in  D:\wamp\bin\apache\Apache2.4.4\conf\original

Here I am Install in D Drive then my path is that. when you install wamp 
check there. "youWamp Install Drive"\wamp\bin\apache\Apache2.4.4\conf\original

Step2) After Fine use ctrl+f and find "80", the are 2 places which you need to change.

step 3) Change port 80 to be ther number, such as 88(as you wish)

step 4) After changes, restart the wamp

now listen 80 to listen 88

and servername localhost 80 to localhost:88

but make sure that new port change in httpd.conf can not use any another program.


Change Xampp apache port number 

Step1 ) Open file "httpd.conf" with notepad++ or any editor you can use like (dream viewer,PHP designer) in  E:\xampp\apache\conf

Here I am Install in E Drive then my path is that. when you install wamp 
check there. "your Xampp Install Drive"\xampp\apache\conf

Step2) After Fine use ctrl+f and find "80", the are 2 places which you need to change.

step 3) Change port 80 to be ther number, such as 88(as you wish)

step 4) After changes, restart the xampp

now listen 80 to listen 88

and servername localhost 80 to localhost:88

but make sure that new port change in httpd.conf can not use any another program.

Change xampp or Wamp apache port number

In localhost access this type locahost:88/blogger 

Give Me Comment is blog usefull or not 

Thanks






Monday 4 May 2015

Errors file upload in PHP

Hello

Here Very small errors are found in file upload.

You can find the code for file uploading from the internet  but you can make some mistake.

I Will oberserve you. mostlly mistake in file upload.

1) in form html enctype="multipart/form-data"


<form action="" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="fileToUpload" id="fileToUpload"/>
    <input type="submit" value="Upload Image" name="submit"/>
</form>

when you use input type file then you must write enctype="multipart/form-data"
it's recuired otherwise it can not upload file or get issue or error in file upload code.

2) just check file_uploads = On in your php.ini file.

Wednesday 25 March 2015

Design anchor tag in visited link, select link, unvisited link and active link and link open in new tab


hello

you want to open in new tab then use target="_blank" propertity in anchor tab
example

http://myphpinformation.blogspot.in

anchor tag css

/* unvisited link */
a:link {
color: green;
}

/* visited link */
a:visited {
color: #776655;
}

/* mouse over link */
a:hover {
color: red;
}

/* selected link */
a:active {
color: yellow;
}
anchor tag css add in style see it.

if you want to change text-decoration in anchot tag.

text-decoration propertity by default in text-decoration: underline; if you want to remove
unader line text-decoration: none; is your css.

a:link {
color: green;
text-decoration: none;
}

if you want line in over the link then you can set as
below
a:link {
color: green;
text-decoration: overline;

}

if you want to create link line-through then change

a:link {
color: green;
text-decoration: line-through;

}

you can also change anchor tag background color;

a:link {
background-color: red;
color: #ffcc77;
text-decoration: none;
}

you can also change it font family
a:link {
background-color: red;
color: #ffcc77;
text-decoration: none;
font-family: Verdana;
}



How to get base url and go back facility in php

How to get base url and go back facility in php


Here for very normal code for that 

just get base url then you can try this code

<?php echo "http://" . $_SERVER['SERVER_NAME'] . 
$_SERVER['REQUEST_URI']; ?>

try i think it's working for you and you want create go back

<a href="#" onclick="window.history.back();">Go Back

this two for php very usefull check it suggest me.

Change connection root name, username, password and db name dynamically in PHP

Change connection root name, username, password and deb name dynamically in PHP



Hello,

I am just creating dynamically change your dbname, servername, username and password.

You can create just one file you can change your DB.

Create database blog and create a connection table in PHP my admin

Here it's code and its data

Table structure for table `connction`

CREATE TABLE IF NOT EXISTS `connction` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `localhost` varchar(200) NOT NULL,
  `username` varchar(200) NOT NULL,
  `password` varchar(200) DEFAULT NULL,
  `db_name` varchar(200) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

Dumping data for table `connction`

INSERT INTO `connction` (`id`, `localhost`, `username`, `password`, `db_name`) VALUES
(1, 'localhost', 'root', '', 'blog');