Friday 30 September 2016

How to use php varible in javascript.

<?php
$varible = "get any string or fetch any data from database";

   ?>
       <script type="text/javascript">
   var show= "<?php echo strip_tags($varible); ?>";
  alert(show);
  </script>

How to use javascript Function in php

<a href="javascript:readmore(id)"> Read More </a>

<script type="text/javascript">
function readmore(id)
{
 if(confirm('Sure To Remove This Chat ?'))
     {
        window.location.href='?readmore='+id;
      }
}
</script>

Tuesday 13 September 2016

how to share any post on facebook in php

<?php
$data = "pppppppppppppppppppppppppppp";

?>
<html>
     

<head>
    <title>Facebook Share Button - External Website</title>
   
<style type="text/css">

body { 
background:#f5f5f5;
font: 14px/150% 'century gothic',helvetica,arial;
}

#container {
margin:5px auto;
padding:25px;
width:400px;
border:1px solid #999;
border-radius:8px; -moz-border-radius:8px; -webkit-border-radius:8px;
background:#fff;
}
</style>


</head>

<body>

<div id="container">

<p>Manjeet kashyap</p>

<div id="fb-root"></div>


<script>
 window.fbAsyncInit = function() {
FB.init({

 appId  : '964579503687504',
 status : true, // check login status
 cookie : true, // enable cookies to allow the server to access the session
 xfbml  : true  // parse XFBML
});
 };

 (function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
 }());
</script>


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>

<img id = "share_button" src = "http://app.tabpress.com/fbui_share/share_button.png">

<script type="text/javascript">
$(document).ready(function(){
$('#share_button').click(function(e){

e.preventDefault();
var m = "<?php echo $data; ?>";
FB.ui(
{

method: 'feed',
name: 'HyperArts Blog',
link: 'http://hyperarts.com/blog',
picture: 'http://www.hyperarts.com/_img/TabPress-LOGO-Home.png',
caption: 'I love HyperArts tutorials',
description: m,
message: ''
});
});
});
</script>


</div>

</body>
</html>

Friday 9 September 2016

how to check email valid on server in php.

$email = "john@gmail.com";

if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
  echo("$email is a valid email address");
} else {
  echo("$email is not a valid email address");
}

Tuesday 6 September 2016

how to call page content in template file in wordpress.

<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>