Tech blog

PHP tutorials,a way to getting some thing new in web

Followers

Powered by Blogger.

Search This Blog

Thursday 12 May 2016

How to create modal dialog using bootstrap

No comments :
We are now a days using css3 and html5,but responsive website is very necessary for all users who are surfing all sites online

Developer have to create such designs for all devices,you can create it using bootstrap css and bootstrap js.

Please check below code for sample modal popup.




<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>Friend modal</h2>
  <!-- Trigger the modal with a button -->
  <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
 
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Hello!!!</h4>
        </div>
        <div class="modal-body">
          <p>Hello friends,this is sample modal</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
   
    </div>
  </div>

</div>

</body>
</html>

Tuesday 7 April 2015

Box Animation Effect using CSS

No comments :
Hi friends,Today i am posting here a topic which is not part of programming.I have created one simple animation effect using HTML5 and CSS3.Many of you have tried it by your own.You may find it useful because this code is so simple.

CSS

h1:hover{

    /* Rotate div */
    -ms-transform: rotate(360deg); /* IE 9 */
    -webkit-transform: rotate(360deg); /* Chrome, Safari, Opera */
    transform: rotate(360deg);
-webkit-animation:spin1 4s linear infinite;
    -moz-animation:spin1 4s linear infinite;
    animation:spin1 4s linear infinite;

}
h1{
   /* Rotate div */
    width: 50%;
    height: 20%;
    background-color: yellow;
    -ms-transform: rotateY(180deg); /* IE 9 */
    -webkit-transform: rotateY(180deg); /* Chrome, Safari, Opera */
    transform: rotateY(180deg);
-webkit-animation:spin 4s linear infinite;
    -moz-animation:spin 4s linear infinite;
    animation:spin 4s linear infinite;
}
img:hover {
        -moz-transform: scaleX(-1);
        -o-transform: scaleX(-1);
        -webkit-transform: scaleX(-1);
        transform: scaleX(-1);
        filter: FlipH;
        -ms-filter: "FlipH";

}
img
{
-webkit-animation:spin 4s linear infinite;
-moz-animation:spin 4s linear infinite;
animation:spin 4s linear infinite;
}
img:hover
{
-webkit-animation:spin1 4s linear infinite;
-moz-animation:spin1 4s linear infinite;
animation:spin1 4s linear infinite;
}
@-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
@-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
@keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }

@-moz-keyframes spin1 { 100% { -moz-transform: rotate(360deg);font-size: 10px;} }
@-webkit-keyframes spin1 { 100% { -webkit-transform: rotate(360deg); font-size: 10px; } }
@keyframes spin1 { 100% { -webkit-transform: rotate(360deg); font-size: 10px; } }

HTML

Lets see how whole code will do.

<html>
<head>
<title>Text Effect</title>
<style>
h1:hover{

    /* Rotate div */
    -ms-transform: rotate(360deg); /* IE 9 */
    -webkit-transform: rotate(360deg); /* Chrome, Safari, Opera */
    transform: rotate(360deg);
-webkit-animation:spin1 4s linear infinite;
    -moz-animation:spin1 4s linear infinite;
    animation:spin1 4s linear infinite;

}
h1{
   /* Rotate div */
    width: 50%;
    height: 20%;
    background-color: yellow;
    -ms-transform: rotateY(180deg); /* IE 9 */
    -webkit-transform: rotateY(180deg); /* Chrome, Safari, Opera */
    transform: rotateY(180deg);
-webkit-animation:spin 4s linear infinite;
    -moz-animation:spin 4s linear infinite;
    animation:spin 4s linear infinite;
}
img:hover {
        -moz-transform: scaleX(-1);
        -o-transform: scaleX(-1);
        -webkit-transform: scaleX(-1);
        transform: scaleX(-1);
        filter: FlipH;
        -ms-filter: "FlipH";

}
img
{
-webkit-animation:spin 4s linear infinite;
-moz-animation:spin 4s linear infinite;
animation:spin 4s linear infinite;
}
img:hover
{
-webkit-animation:spin1 4s linear infinite;
-moz-animation:spin1 4s linear infinite;
animation:spin1 4s linear infinite;
}
@-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
@-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
@keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }

@-moz-keyframes spin1 { 100% { -moz-transform: rotate(360deg);font-size: 10px;} }
@-webkit-keyframes spin1 { 100% { -webkit-transform: rotate(360deg); font-size: 10px; } }
@keyframes spin1 { 100% { -webkit-transform: rotate(360deg); font-size: 10px; } }
</style>
</head>
<body>
<h1>This is<br/>Image Animation of Box</h1><br/><br/>
<img src="e:\2.jpg" alt="flipped" border="0"/>

</body>
store file with whatevername.html and run in browser.change image path with your image path in img tag.


Friday 3 April 2015

Sticky Header using HTML5 and CSS3

No comments :
Hi friends,Today i am posting here a topic which is not part of programming.I have created one simple sticky header using HTML5 and CSS3.Many of you have tried it by your own.You may find it useful because this code is so simple.




CSS

body{
    margin:0px;
    background:#000;
}
.header-cont {
  position: fixed;
  width: 100%;
  text-align: center;
  font-size: 72px;
  height: 204px;
  background: #335C7D;
  color: #fff;
  font-family: 'PT Sans', sans-serif;
}
.header {
    height:50px;
    background:#F0F0F0;
    border:1px solid #CCC;
    width:960px;
    margin:0px auto;
}
.content {
    width:960px;
    background: #CCC;
    border: 1px solid #CCC;
    height: 2000px;
    margin: 70px auto;
}
.ul
{
width:100%;
list-style-type:none;
}
.ul li
{
display:inline-block;
list-style-type:none;

}

First of write simple css for page in which we will make three part.Header,content and menu.this is for study so i m trying make it as simple as i can.


HTML

Lets see how whole code will do.

<html>
<head>
<style type="text/css">
body{
    margin:0px;
    background:#000;
}
.header-cont {
  position: fixed;
  width: 100%;
  text-align: center;
  font-size: 72px;
  height: 204px;
  background: #335C7D;
  color: #fff;
  font-family: 'PT Sans', sans-serif;
}
(this is css for sticky header.sticky header will work when we use position:fixed).just define this and header will take effect of sticky header.
.header {
    height:50px;
    background:#F0F0F0;
    border:1px solid #CCC;
    width:960px;
    margin:0px auto;
}
.content {
    width:960px;
    background: #CCC;
    border: 1px solid #CCC;
    height: 2000px;
    margin: 70px auto;
}
.ul
{
width:100%;
list-style-type:none;
}
.ul li
{
display:inline-block;
list-style-type:none;
}
</style>
</head>
<body>
<div class="header-cont">
<h5>This is Sticky header demo by Ruchi Sanghvi</h5>
    <div></div>
</div>
(this is portion for sticky header)

<div class="content">
<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</p>
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.

Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
</div>
</body>
</html>


happy coding!!

Tuesday 31 March 2015

Simple Registration using PHP

2 comments :
Hello Friends, As we have went through many topics like login,login with facebook,login with google,sms sending api,ffmpeg.But each and every website needs user to register on their website.they want user to be in touch with their website all time.Also they store data of user on website.For that one process is necessary which is known as registration.
All language like .NET,PHP,JAVA has codes to do registration.Even wordpress,drupal also do same.

But as PHP developer and being writing PHP codes,here i need to explain you how registration works and how code is implement.

First of all i will explain you process for same.


  • User come for visit on you website and signup for registration.
  • When he goes on registration page,he fills simple information form on your site and submit it.
  • All information which he inputs,they get stored into database.



Let's See this process in form of code:

HTML to create Form

index.php

<html>
<body>
<form action="" method="POST" name="form1" id="form1">
<label>Name:</label>
<input type="text" id="your_name" name="your_name" value=""/>
<label>User Name:</label>
<input type="text" id="user_name" name="user_name" value=""/>
<label>Password:</label>
<input type="text" id="pass" name="pass" value=""/>
<label>Confirm Password:</label>
<input type="text" id="c_pass" name="c_pass" value=""/>
<input type="submit" id="submit" name="submit" value="Submit"/>
</form>
</body>
</html>

PHP Code to store information:

 index.php

paste this code upside of html in same file.

<?php
include('connect.php');
if(isset($_POST['submit']))
{
$your_name=$_POST['your_name'];
$user_name=$_POST['user_name'];
$pass=$_POST['pass'];
$insert="INSERT INTO users SET name='".$your_name."',user_name='".$user_name."',password='".$pass."'";
$res=mysql_query($insert) or die(mysql_error());
$id=mysql_insert_id();
if($id > 0)
{
header('location:index.php?msg=1');
}
else
{
header('location:index.php?msg=2');
}
}
?>
 connect.php

<?php
$host="your_host_name";
$username="your_username";
$password="your_password";
$db="your_db_name";
$link=mysql_connect($host,$username,$password);
mysql_select_db($db,$link);
?>

Create database and make one table named "user" with fields username,password,name and other fields which you want from user to get stored.

run code...!!

Tuesday 3 March 2015

Online Voting System

No comments :
Hello Friends,Today I came with small application on this blog.I am sure you will like it.This system is name as "online voting system".

In this system,Right now voting functionality is shown.voting questions and options are static and also user is also static.



Here are two files are used and one database with one table.

config.php

<?php
$host="localhost";
$username="root";
$password="";
$db="test";
$link=mysql_connect($host,$username,$password);
mysql_select_db($db,$link);

?>

voting.php

<?php
include('config.php');
if(isset($_POST['submit1']))
{
$vote=$_POST['actor'];
$INSERT="insert into votes SET user_id='".$_SESSION['id']."',answer='".$vote."',create_date='now()'";
$res=mysql_query($INSERT) or die(mysql_error());
if(mysql_insert_id() > 0)
{
header("location:voting.php?msg=1");
}
}
$select="select * from votes where id>0";
$res1=mysql_query($select) or die(mysql_error());
$tot=mysql_num_rows($res1);
if(mysql_num_rows($res1) > 0)
{
    $answer1=0;
$answer2=0;
$answer3=0;
$answer4=0;
while($row_s=mysql_fetch_array($res1))
{
if($row_s['answer']==1)
{
$answer1+=1;
$per1=($answer1/$tot) * 100;
}
else if($row_s['answer']==2)
{
$answer2+=1;
$per2=($answer2/$tot) * 100;
}
else if($row_s['answer']==3)
{
$answer3+=1;
$per3=($answer3/$tot) * 100;
}
else if($row_s['answer']==4)
{
$answer4+=1;
$per4=($answer4/$tot) * 100;
}
}
}
?>
<html>
<head>
<title>Online Voting System</title>
</head>
<body>
<?php if($_GET['msg']==1){?><span style="background:green;color:#FFF;border-radius:5px;font-size:14px;width:100%;height:100%;">Your vote is submitted successfully</span><?php } ?><br/>
<?php echo 'Total Votes          '.$tot;?>
<div style="">
<span>Arjun Kapoor <?=$answer1;?>  <?= $per1.'%';?></span><br/>
<span>Ranvir Kapoor <?=$answer2;?> <?= $per2.'%';?></span><br/>
<span>Rabir Kapoor <?=$answer3;?>  <?= $per3.'%';?></span><br/>
<span>Varun Dhawan <?=$answer4;?>  <?= $per4.'%';?></span><br/>
</div>
<h1>Who will take place of superstar?</h1>
<form id="voteform" name="voteform" action="" method="post">
<input type="radio" name="actor" id="actor" value="1">Arjun Kapoor<br/>
<input type="radio" name="actor" id="actor" value="2">Ranvir Kapoor<br/>
<input type="radio" name="actor" id="actor" value="3">Rabir Kapoor<br/>
<input type="radio" name="actor" id="actor" value="4">Varun Dhawan<br/>
<input type="submit" name="submit1" id="submit1" value="Vote"/>
</form>
</body>

</html>

Database table structure:

table name:votes.
fields:id,user_id,answer,create_date


Integrate this code into your files.Enjoy coding!!!!

Tuesday 24 February 2015

How to get which checkbox is checked using jquery

No comments :
Today we will see how can we check which checkbox is checked in html using jquery
If i have group of checkbox of 3checkbox then how will I know which checkbox is checked.




Code:

HTML

<html>
<body>
<input name="sheeping1" class="add" id="ship"  type="radio" checked="checked">
<input name="sheeping1" class="add" id="bill" type="radio">
</body>
</html>

Jquery:

 $(".add").change(function () {
          if ($('.add:checked').length > 0) {
               var Id = $(this).attr('id');
               alert(Id);
                }
        });

Give class to each radio button named 'add'
then apply jquery.

Wednesday 19 November 2014

How To send sms using API in PHP??

No comments :
Today we guys mostly use sms services available on internet like way2sms,160by2.but have we ever thought to take them in our webapplications.

In PHP,We can do this with simple code of thirdparty api..
Here i have created simple code which sends sms to given mobile number using clickatell API.




Here is code:

<?php
    $user = "xxxxxx";
    $password = "xxxxxx";
    $api_id = "xxxxxx";
    $baseurl ="http://api.clickatell.com";

    $text = urlencode("This is an example message");
    $to = "+919408046690";

    // auth call
    $url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id";

    // do auth call
    $ret = file($url);

    // explode our response. return string is on first line of the data returned
    $sess = explode(":",$ret[0]);
    if ($sess[0] == "OK") {

        $sess_id = trim($sess[1]); // remove any whitespace
        $url = "$baseurl/http/sendmsg?session_id=$sess_id&to=$to&text=$text";

        // do sendmsg call
        $ret = file($url);
        $send = explode(":",$ret[0]);

        if ($send[0] == "ID") {
            echo "successnmessage ID: ". $send[1];
        } else {
            echo "send message failed";
        }
    } else {
        echo "Authentication failure: ". $ret[0];
    }
?>

In this code,user,password and api id are needed for code,which is available on www.clickatell.com/
site.

Happy Coding guys!!!