Posts

phone no validation

< form > Phone Number (format: xxx-xxx-xxxx): < input type = "tel" pattern = "^\d {3} -\d {3} -\d {4} $" required > < input type = "submit" value = "Submit" > </ form > < form > Phone Number (format: xxxxxxxxxx): < input type = "tel" pattern = "^\d {10} $" required > < input type = "submit" value = "Submit" > </ form >

Javascript onkeyup

<html>     <head>         <script>             function add()             {                 var a = parseInt(document.getElementById("t1").value);                 var b = parseInt(document.getElementById("t2").value);                 var result = a + b;                 document.getElementById("s1").innerHTML = result;             }         </script>         <title>Addition Using Aja...

Display records from database using pie chart

<?php $con=mysqli_connect('localhost','root','root','pie_chart') or die(mysqli_connect_error());    $query=mysqli_query($con,"select * from visitors") or die(mysqli_error($con));  ?> <html>   <head>     <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>     <script type="text/javascript">       google.charts.load('current', {'packages':['corechart']});       google.charts.setOnLoadCallback(drawChart);       function drawChart() {         var data = google.visualization.arrayToDataTable([           ['country', 'Visits'],           <?php           while ($row=mysqli_fetch_assoc($query)) {  ...

Difference between two dates

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <!-- daterange picker -->   <link rel="stylesheet" href="bower_components/bootstrap-daterangepicker/daterangepicker.css">   <!-- bootstrap datepicker -->   <link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">   <link href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="Stylesheet" type="text/css" />     <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>     ...

Dependent dropdown using ajax

index.php     <!DOCTYPE html>     <html>     <head>         <title></title>         <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">     </head>     <body>     <div class="container" style="margin-top: 70px;">     <div class="row">     <div class="col-md-3"></div>     <div class="col-md-6">                     <form  action="insert.php" method="post">                     <div class="form-group">     <label for="exampleInputEmail1">Department</label>     <input type="text" name...

Simple PHP Mysql Shopping Cart

<?php    session_start();   $connect = mysqli_connect("localhost", "root", "root", "test");   if(isset($_POST["add_to_cart"]))   {        if(isset($_SESSION["shopping_cart"]))        {             $item_array_id = array_column($_SESSION["shopping_cart"], "item_id");             if(!in_array($_GET["id"], $item_array_id))             {                  $count = count($_SESSION["shopping_cart"]);                  $item_array = array(                       'item...

Checkbox in select

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css"     rel="stylesheet" type="text/css" /> <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script> <link href="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/css/bootstrap-multiselect.css"     rel="stylesheet" type=...

Simple login

<?php $con=mysqli_connect("localhost","root","root","oes2") or die(mysqli_error($con)); if(isset($_POST['submit'])) {     extract($_POST);     $q=mysqli_query($con,"select * from student where stdname='$username' and stdpassword='$password'") or die(mysqli_error($con));     if(mysqli_num_rows($q)==1)         {     $row=mysqli_fetch_array($q);         $_SESSION['uname_admin']=$row['admname'];             echo"<script>";         echo"alert('Login Successfully..');";         echo"window.location.href='dashboard.php'";         echo"</script>";     }     else     {         echo"<script>";         echo"alert('Login Fa...

ajax insert

index.php <!DOCTYPE html> <html> <head>   <title>Ajax insert</title>   <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> </head> <body> <div class="container">     <div class="row">           <div class="col-md-3"></div>           <div class="col-md-6">           <form >     ...

cookie login

<?php $con = mysqli_connect("localhost","root","root","cookielogin") or die(mysqli_error($con)); session_start(); if(isset($_POST['btn_login'])) {     extract($_POST);             $query=mysqli_query($con,"select * from login where  username='$username' and password='$password'" ) or die(mysqli_error($con));      $row=mysqli_fetch_assoc($query);            if($row)      {          if(!empty($_POST['re'])){          setcookie("username",$_POST['username'],time() + (48*60*60));          setcookie("password",$_POST['password'],time() + (24*60*60));          }          else          {           ...