Sanwebcorner | Programming Blog

Simple Breadcrumb Design using css

This is the simple breadcrumb navigation it is used to navigate previous pages links and also gives the current page in the website. Breadcrumb navigation one of the useful navigation to the user and also it is the seo friendly because it is act like a internal link building.

This is very simple to create you just follow the below css code to display the breadcrumb navigation bar, You can design various types of breadcrumb navigation bar usig the html and css. In this example i provided simple and nice breadcrumb design using html and css, Here also provided the demo link to check out the result of the example and also provided the download button download the code. I hope this simple concept will really helpful.



<html>
<head>
<title>simple Breadcrumb Design using css</title>
<style>
#my-breadcrumbs ul li {
list-style:none;
}

#my-breadcrumbs ul li a {
display: block;
    float: left;
    height: 30px;
    background: #3060A5;
    text-align: center;
    padding: 7px 30px 0 30px;
    position: relative;
    margin: 0 36px 0 0;
    font-family: "Open Sans", Helvetica, Arial, sans-serif;
    font-size: 20px;
    text-decoration: none;
    color: #fff;
}

#my-breadcrumbs ul li a:hover{
  background: #5172B8;
}

#my-breadcrumbs ul li a:after {
    content: "";
    border-top: 20px solid transparent;
    border-bottom: 17px solid transparent;
    border-left: 30px solid #3060A5;
    position: absolute;
    right: -30px;
    top: 0;
}

#my-breadcrumbs ul li a:before {
    content: "";
    position: absolute;
    margin-top: -7px;
    border-width: 18px 0 19px 30px;
    border-style: solid;
    border-color: #3060A5 #3060A5 #3060A5 transparent;
    left: -30px;
}

/* Hover Effects */
#my-breadcrumbs ul li a:hover::before {
  border-color: #5172B8 #5172B8 #5172B8 transparent;

}
/* Hover Effects */
#my-breadcrumbs ul li a:hover::after{
    border-top: 20px solid transparent;
    border-bottom: 17px solid transparent;
border-left: 30px solid #5172B8;
}

/* Hide the Before Pseudo Element */
#my-breadcrumbs ul li:first-child a:before {
display: none;
}

/* Add Border Radius */
#my-breadcrumbs ul li:first-child a{
border-top-left-radius: 10px; border-bottom-left-radius: 10px;border-bottom-right-radius: 1px;
}

</style>
</head>
<body>

<div id="my-breadcrumbs">
<ul style="height: 100px;">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">About our company</a></li>
<li><a href="#">Vision</a></li>
</ul>
</div>
</body>
</html>

Marquee text with close button using jquery

In this post i will tell you how to create close button in marquee text with the help of jquery and html. You can manually closing flash news section using jquery below javascript code is used to enable the close button in marquee div.

<script>
$(document).ready(function(c) {
$('.alert-close').on('click', function(c){
$('.message').fadeOut('slow', function(c){
$('.message').remove();
});
});
});
</script>

This types of flash news section most of the website now using to display the emergency flash news section dynamically using some technology. This types of marquee text with close button is one of the user friendly because when user don't want that message simple they close the section so none of the  flash news text will disturb the customers. Below i given full code and also i given demo link below you just check it out how it is working and also i given the download button download the code and use it, I hope this simple example is really helpful.



Code for Flash news with close button

<html>
<head>
<title>manually closing flash news section </title>
<style>
.alert {
background-color: #f39c12 !important;

}

.message {
border-radius: 2px;
display: block;
font-size: 10pt;
font-weight: bold;
margin: 0 0 15px;
padding: 10px 10px 10px 35px;
position: relative;
vertical-align: middle;
color: white;
}
.alert-close {

border-radius: 50%;
background-color: #F7C575;
color: #000;
opacity: .6;
cursor: pointer;
font-size: 18px;
font-weight: normal;
height: 22px;
line-height: 21px;
position: absolute;
right: 11px;
text-align: center;
top: 9px;
-webkit-transition: color 0.2s ease-in-out;
-moz-transition: color 0.2s ease-in-out;
-o-transition: color 0.2s ease-in-out;
transition: color 0.2s ease-in-out;
width: 22px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(c) {
$('.alert-close').on('click', function(c){
$('.message').fadeOut('slow', function(c){
$('.message').remove();
});
});
});
</script>
</head>
<body>
<div class="message alert"><marquee style="width:75%;">Flash News: This is manually closing flash news section jquery flash news. You can close this div by clicking the close button. </marquee>
<div class="alert-close"> x </div>
</div>
</body>
</html>

Full form for Mobile otp login system using sms gateway in php & mysql

Hi now i will tell you how to create login system using mobile otp. First you need to purchase sms gateway to send otp via sms to the registered mobile number. OTP means one time password, it is valid only one time after login using that otp, that otp number will expired this is the concept of the otp, Now we will see how to do this with the help of php and mysql.

First you should purchase sms gateway various types sms service providers available through the world. you will purchase from the serveice providers, they will share you api key and sender id using that only you can able to send the sms to the mobile number. Here i am used smsgatewayhub service provider.




Now you will create database in backend and then create two different table one is otp_expiry table it is used to store the randomly generated otp in the database to use for login and another one table is registered_users, it will used to store the mobile number in database i already stored the mobile number manually you can store this mobile number using signup form.

Step1: Create Database

Create database in your backend, Here i am using database name is " test" 

Step2: Create table with this name "otp_expiry"

create table name here i am using otp_expiry to store and alter the otp, Use below sql code to create the table.

CREATE TABLE `otp_expiry` (
  `otp` varchar(10) NOT NULL,
  `is_expired` int(11) NOT NULL,
  `create_at` datetime NOT NULL,
  `id` int(12) NOT NULL,
  `newid` int(12) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Step3: Create table with this name "registered_users"

Create table name here i am using registered_users to store the registered user mobile number here i directly inserted some mobile number in database , you may include the data using registration form, Use the below sql code to create registration user

CREATE TABLE `registered_users` (
  `id` int(11) NOT NULL,
  `mobile` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Below is the full opt login system code is available you can download this from by clicking the download button there i also included the database file. I already used this code in my project it works 100% . You can download and use this code to your project, you need to modify the code. you just replace your api key and sender id then the url when you purchase the sms gateway to the same service provider or you can use the php integration part from some other service providers.

OTP Full form code:

<?php
$success = "";
$error_message = "";
$conn = mysqli_connect("localhost","root","","test");
if(!empty($_POST["submit_email"])) {
$result = mysqli_query($conn,"SELECT * FROM registered_users WHERE mobile='" . $_POST["mobile"] . "'");
$count  = mysqli_num_rows($result);
if($count>0) {
// generate OTP
$otp = rand(100000,999999);
// Send OTP

$apikey = "YOUR API KEY";
$apisender = "SENDER ID";
$msg ="Your OTP for Login $otp";
$num = $_POST["mobile"];    // MULTIPLE NUMBER VARIABLE PUT HERE...!               

$ms = rawurlencode($msg);   //This for encode your message content                 

$url = 'https://www.smsgatewayhub.com/api/mt/SendSMS?APIKey='.$apikey.'&senderid='.$apisender.'&channel=2&DCS=0&flashsms=0&number='.$num.'&text='.$ms.'&route=1';
$mail_status=1;                 
//echo $url;
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,2);
$data = curl_exec($ch);
echo '<br/><br/>';
/* result of API call*/

if($mail_status == 1) {
$result = mysqli_query($conn,"INSERT INTO otp_expiry(otp,is_expired,create_at) VALUES ('" . $otp . "', 0, '" . date("Y-m-d H:i:s"). "')");
$current_id = mysqli_insert_id($conn);
if(!empty($current_id)) {
$success=1;
}
}
} else {
$error_message = "Mobile not exists!";
}
}
if(!empty($_POST["submit_otp"])) {
$result = mysqli_query($conn,"SELECT * FROM otp_expiry WHERE otp='" . $_POST["otp"] . "' AND is_expired!=1 AND NOW() <= DATE_ADD(create_at, INTERVAL 24 HOUR)");
$count  = mysqli_num_rows($result);
if(!empty($count)) {
$result = mysqli_query($conn,"UPDATE otp_expiry SET is_expired = 1 WHERE otp = '" . $_POST["otp"] . "'");
$success = 2;
} else {
$success =1;
$error_message = "Invalid OTP!";
}
}
?>
<html>
<head>
<title>User Login</title>
<style>
body{
background-color: #4CAF50;
}
.sanloginpanel {
border: #ffffff 1px solid;
background: #ffffff;
border-radius: 4px;
max-width: 480px;
padding: 42px 30px 46px;
text-align: center;
margin: 150px auto;
}
.tableheader { font-size: 20px; }
.tablerow { padding:20px; }
.error_message {
color: #b12d2d;
background: #ffb5b5;
border: #c76969 1px solid;
}
.message {
width: 100%;
max-width: 300px;
padding: 10px 30px;
border-radius: 4px;
margin-bottom: 5px; 
}
.login-input {
border: #4caf50 1px solid;
padding: 10px 20px;
border-radius:4px;
}
.btnSubmit {
padding: 10px 20px;
background: #2c7ac5;
border: #d1e8ff 1px solid;
color: #FFF;
border-radius:4px;
}
</style>
</head>
<body>
<?php
if(!empty($error_message)) {
?>
<div class="message error_message"><?php echo $error_message; ?></div>
<?php
}
?>

<form name="frmUser" method="post" action="">
<div class="sanloginpanel">
<?php
if($success == 1) { ?>
<div class="tableheader">Enter OTP</div>
<p style="color:#31ab00;">Check your Mobile for the OTP</p>

<div class="tablerow">
<input type="text" name="otp" placeholder="One Time Password" class="login-input" required>
</div>
<div class="tableheader"><input type="submit" name="submit_otp" value="Submit" class="btnSubmit"></div>
<?php
} else if ($success == 2) {
$result = mysqli_query($conn,"SELECT * FROM otp_expiry WHERE otp='" . $_POST["otp"] . "'");

$count=mysqli_num_rows($result);
$row=mysqli_fetch_array($result);

if($count > 0){
session_start();
$_SESSION['newid']=$row['newid'];

header('Location: securepage.php');
}

?>
<?php
}
else {
?>
<div class="tableheader">Enter Your Mobile Number to Login</div>
<div class="tablerow"><input type="text" name="mobile" placeholder="Enter Mobile Number" class="login-input" required></div>
<div class="tableheader"><input type="submit" name="submit_email" value="Submit" class="btnSubmit"></div>
<?php
}
?>
</div>
</form>
</body>
</html>


Here i generate the 6 digit otp code you can also generate the 4digit and whatever you want, just modify the rand(100000,999999) this code. I hope this opt form will really helpful and also i provided the screenshots below to refer

Screenshots:







Increment Decrements certain fixed amount of text box value multiply based on select box value

This is some thing different concept The textbox value is fixed amount it may any amount but in this example i used the fixed amount is 108 rs. When you select the qty in select box based on the quantity the text box value should be increase by multiplying the select box value. For example if you select the select box qty is 3 means the text box value is 3*108 = 324rs. This concept will done by using the javascript and jquery.


I hope this example is very useful to you, Using this concept you can modify the things according to your project requirement. This is the simple concept using html, css, jquery, I provided the demo and download code link below you can use this. Click the demo link to check live  working example. Thanks. 






<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<style>
input{
    height: 35px;
}

</style>
</head>
<body>
<form action="" method="post" name="payuForm">
<label>ENTER YOUR QTY: </label>
<input id="qty" name="qty" value="1"  placeholder="ENTER YOUR QTY" autocomplete="off" type="number" min="1"><br/><br/>
<label>TOTAL AMOUNT: </label><input type="hidden"  id="price" name="price" value="108"  >
<input type="text"  id="amount" name="amount" value="108" readonly ><br/>
</form>
<script>
jQuery(document).ready(function($){
jQuery(document).bind("click", "#qty", function(e)
{
e.preventDefault();
var qty=$("#qty").val();
var price=$("#price").val();
var reqv=parseInt(qty);
var stockv=parseInt(price);
if(reqv != 0)
{
var total=reqv*stockv;
$("#amount").val(total);
}
else
{
$("#amount").val("108");
}
});
});
</script>
</body>
</html>


Popup image on click the link using Jquery

Today will learn How to show image as a popup on click the link using Jquery. This is very simple concept will easily do with the help of jquery. You can customize the popup image by editing jquery.fancybox file. In this file you can set the speed of the animation open image in the popup and also you can set the loop and opacity, zoom option etc... 

In this example you should add the image to div with the id name is hidden-content that image will display in the popup field. And then you just call the id hidden-content in the <a> tag like below code after included necessary jquery and javascript and css files. This post shows image in the popup window while clicking the link. You can also add the link in the popup image by using <a> tag in your hidden-content div.

<a data-fancybox data-src="#hidden-content" href="javascript:;">
Click link View popup image
</a>

I hope this example will help you how to open an image in the popup mode on click the link. Below is the full code you can download code and use it your projects. And also i provided the demo link check it out below. I think this is very useful to you, If it is useful please support us by sharing this post to social media. Thanks lot.


Popup image on click the url using Jquery




Code for onclick Popup image:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Popup image on click the link using Jquery</title>

<!-- CSS -->
<link rel="stylesheet" type="text/css" href="jquery.fancybox.css">
</head>
<body>
<br/><br/><br/><br/><br/><br/>
<center><!-- Your HTML content goes here -->
<div style="display: none;" id="hidden-content">
<img src="sanwebcorner.jpg" />
</div>
<a data-fancybox data-src="#hidden-content" href="javascript:;">
Click link View popup image
</a>
<br/><br/><br/><br/><br/><br/>

<a href="http://www.sanwebcorner.com">www.sanwebcorner.com</a>
</center>
<!-- JS -->
<script src="http://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="jquery.fancybox.js"></script>
</body>
</html>

Redirect page Based on the select box while submit the form using Javascript

Here we will see how to redirect page after submit the form based on select box using simple javascript. This is one of the concept redirect a different website based on the select box (drop down box) in the form, For that we should remove default action from the form using the simple javascript code below,

<script>
document.getElementById('comment-form1').addEventListener('submit',(e)=>{
e.preventDefault();
window.location = (document.getElementById('option').value);
})
</script>

The above code is to remove default form submission and helps to redirect page using the option value, you should give the ulr in the select box option value. This is one of the requirement for me from my company  form redirect the different url based on the select box and also send the form information to admin email  id after submission. 


Code for Redirect page Based on the select box while submit the form 


index.php:

<html>
<head>
<title>Redirect page based on select box using javascript</title>
<style>
input, select
{
width: 280px;
margin: 19px;
height: 45 px;
padding: 10px;
}
</style>
</head>
<body>
<form  id="comment-form1" name="contact-form1"  onsubmit="return mysubmit();">
<input type="text"  name="name" placeholder="Your Name.." required><br>
<input type="text"  name="email" placeholder="Your Email.."required></br>
<input type="text"  name="phone" placeholder="Your 10 digit Phone.."require pattern="[0-9]{10}"><br/>
<select  id="option" class="chosen" >
<option selected disabled>Select Bank</option>
<option value="http://demos.sanwebcorner.com/">Sanwebcorner Demo</option>
<option value="http://www.sanwebcorner.com/" >Sanwebcorner Main Page</option>
<option value="http://www.sanwebcorner.com/2018/12/bounce-effect-on-hover-button-using-css-and-html.html" >Single page</option>
</select><br/>
<input name="submit" type="submit" value="Submit" /><br>
</form>

<script>
document.getElementById('comment-form1').addEventListener('submit',(e)=>{
e.preventDefault();
window.location = (document.getElementById('option').value);
})
</script>

</div>
</div>
</section>
</body>
</html>






Redirect Page based on select box and send form information to Admin Email Id:

You can use the below code if you want to send information to your admin email id and also to redirect the page url based on the dropdown box  after send the information to the admin mail. This is the redirect process based on the simple if condition, this conditions will execute after the email function executed.  This is the concept when you choose the particular net banking it should redirct the netbanking url. I hope this two concept will help you . I did'nt provide download option to this concept. pls use the below code it will works fine for me. I provided full code below.

<?php
if (isset($_POST['submit']))

{
$to = "admin@example.com";
$from = "admin@example.com";
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$bank=$_POST['bank'];
$subject = "New Donation Info";
$message = " \n\n Name: ".$name."<br/> \n\n Email: " .$email."<br/> \n\n Mobile: ".$phone."<br/> Bank Name: ".$bank. "<br/> \n\n" ;

//$message = " Hi this is test" ;
$headers =  'MIME-Version: 1.0' . "\r\n";
$headers .= 'From:Donation Info from Website:>' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to,$subject,$message,$headers);
echo '<script>alert("Your Enquiry Received . We will contact you soon...");</script>';
if($bank=="www.icicibank.com/safe-online-banking/safe-online-banking.page?itm=nli_hp_0_btn_ib_loginbtn")
{
echo '<script>location.href = "https://www.icicibank.com/safe-online-banking/safe-online-banking.page?itm=nli_hp_0_btn_ib_loginbtn"</script>';
}

elseif($bank=="netbanking.hdfcbank.com/netbanking/?_ga=2.196148587.673827790.1549438128-1636006557.1549438128")
{
echo '<script>location.href = "https://netbanking.hdfcbank.com/netbanking/?_ga=2.196148587.673827790.1549438128-1636006557.1549438128"</script>';

}


elseif($bank=="netbanking.canarabank.in/entry/ENULogin.jsp")
{
echo '<script>location.href = "https://netbanking.canarabank.in/entry/ENULogin.jsp"</script>';
}


}
?>


<html>
<head>
<title>Redirect page based on select box using javascript</title>
<style>
input, select
{
width: 280px;
margin: 19px;
height: 45 px;
padding: 10px;
}
</style>
</head>
<body>
<form  id="comment-form1" name="contact-form1" method="post"  onsubmit="return mysubmit();">
<input type="text"  name="name" placeholder="Your Name.." required>
<input type="text"  name="email" placeholder="Your Email.."required>
<input type="text"  name="phone" placeholder="Your 10 digit Phone.."require pattern="[0-9]{10}">

<select name="bank"  id="option" class="chosen" style="width:500px;">
<option selected disabled>Select Bank</option>
<option value="netbanking.hdfcbank.com/netbanking/?_ga=2.196148587.673827790.1549438128-1636006557.1549438128">Hdfc Bank</option>
<option value="www.icicibank.com/safe-online-banking/safe-online-banking.page?itm=nli_hp_0_btn_ib_loginbtn" >ICICI Bank</option>
<option value="netbanking.canarabank.in/entry/ENULogin.jsp" >Canara Bank</option>
</select>
<input name="submit" type="submit" value="Submit" /><br>
</form>

</div>
</div>
</section>
</body>
</html>

How to calculate age by date of birth using PHP Programming

Here we will learn how to calculate age by date of birth ( DOB) using php programming. This php age calculator will calculate your age in years, months, and days as of any date of your choosing. The php calculator will also translate that age into how old you are in terms of months, weeks, days, hours, minutes, and seconds. Plus, When you select the date of birth it shows th exact ages in different format like age in years, age in months, age in weeks, age in minutes, age in seconds in the different lines. This is the time calculation by using php.

The below example have the demo page check out the demo page for calculating your age in different format. Download the code from download section. I hope this concept is useful.



index.php

<html>
<head>
<title>How to calculate age by date of birth using PHP Programming</title>
<style>
.san1
{
border: 1px solid #084a08;
padding: 43px 23px;
margin:  23px;
max-width: 595px;
background-color: #e9ffe9;
border-radius: 35px;
}

.san
{
border: 1px solid #084a08;
padding: 10px;
margin: 23px;
max-width: 595px;
background-color: #bee4be;
}

</style>
</head>
<body>
<div class="san1">
<form method="post" style="width: 400px; margin: 0 auto;">
Select Your DOB <input type="date" name="date2"  min="2012-01-01" max="2019-01-01" >
<input type="submit" name="submit" value="calculate">
</form>

<?php
if(isset($_POST["submit"]))
{
$date1=$_POST['date2'];

$hours_in_day   = 24;
$minutes_in_hour= 60;
$seconds_in_mins= 60;

$birth_date     = new DateTime("$date1");
$current_date   = new DateTime();

$diff           = $birth_date->diff($current_date);
?>
<div class = "san"> <strong>Age in Years: </strong><?php echo $years     = $diff->y . " years " . $diff->m . " months " . $diff->d . " day(s)"; echo "<br/>"; ?></div>
<div class = "san"> <strong>Age in Months: </strong><?php echo $months    = ($diff->y * 12) + $diff->m . " months " . $diff->d . " day(s)"; echo "<br/>";?></div>
<div class = "san"> <strong>Age in Weeks: </strong><?php echo $weeks     = floor($diff->days/7) . " weeks " . $diff->d%7 . " day(s)"; echo "<br/>";?></div>
<div class = "san"> <strong>Age in Days: </strong><?php echo $days      = $diff->days . " days"; echo "<br/>";?></div>
<div class = "san"> <strong>Age in Hours: </strong><?php echo $hours     = $diff->h + ($diff->days * $hours_in_day) . " hours"; echo "<br/>";?></div>
<div class = "san"> <strong>Age in Minutes: </strong><?php echo $mins      = $diff->h + ($diff->days * $hours_in_day * $minutes_in_hour) . " minutest"; echo "<br/>";?></div>
<div class = "san"> <strong>Age in Seconds: </strong> <?php echo $seconds   = $diff->h + ($diff->days * $hours_in_day * $minutes_in_hour * $seconds_in_mins) . " seconds"; echo "<br/>";?></div>
<?php
}
?>
<br/>
<center><h3><a href="http://demos.sanwebcorner.com/">www.sanwebcorner.com</a></h3></center>
</div>
</body>
</html>

OTP Login System through email address using php and Mysql

Hi, Today i am going to post a article about Email otp concept. It will help you to login through the email otp. First OTP means one time password, It will randomly generated using php function, then it will store the database, when you login using opt then it will expired it valid only one time.

In this first you have to create database and tables, For that you just follow the below given sql query. Here is the two different table one is userprofile table to store the user emails and the second one is otpstore to store the randomly generated otp. First system checks the email is available in the database table. If not it shows the error email not exist. Just store some emails in database table and then try this program, then it will work perfectly and gives the otp to your registered email , After enter the OTP it takes the secure page.


The otp will send using the smtp through the phpmailer so you can provide the host name and email id, password, port number everyting in this mailfunction.php file. to deliver the otp email id. Using this concept you can set this for mobile otp concept. will post the Otp login via mobile in next post. I hope this example is very useful.





Database and Tables:

First create one database name called 'demo'

Use the below sql query to create table.

CREATE TABLE IF NOT EXISTS `userprofile` (
`id` int(11) NOT NULL,
  `email` varchar(255) NOT NULL
)

CREATE TABLE IF NOT EXISTS `otpstore` (
`id` int(11) NOT NULL,
  `otp` varchar(10) NOT NULL,
  `is_expired` int(11) NOT NULL,
  `create_at` datetime NOT NULL
)

index.php


<?php
$success = "";
$error_message = "";
$conn = mysqli_connect("localhost","root","","demo");
if(!empty($_POST["submit_email"])) {
$result = mysqli_query($conn,"SELECT * FROM userprofile WHERE email='" . $_POST["email"] . "'");
$count  = mysqli_num_rows($result);
if($count>0) {
// generate OTP
$otp = rand(1000,9999);
// Send OTP
require_once("mail_function.php");
$mail_status = sendOTP($_POST["email"],$otp);

if($mail_status == 1) {
$result = mysqli_query($conn,"INSERT INTO otpstore(otp,is_expired,create_at) VALUES ('" . $otp . "', 0, '" . date("Y-m-d H:i:s"). "')");
$current_id = mysqli_insert_id($conn);
if(!empty($current_id)) {
$success=1;
}
}
} else {
$error_message = "Email not exists!";
}
}
if(!empty($_POST["submit_otp"])) {
$result = mysqli_query($conn,"SELECT * FROM otpstore WHERE otp='" . $_POST["otp"] . "' AND is_expired!=1 AND NOW() <= DATE_ADD(create_at, INTERVAL 24 HOUR)");
$count  = mysqli_num_rows($result);
if(!empty($count)) {
$result = mysqli_query($conn,"UPDATE otpstore SET is_expired = 1 WHERE otp = '" . $_POST["otp"] . "'");
$success = 2;
} else {
$success =1;
$error_message = "Invalid OTP!";
}
}
?>
<html>
<head>
<title>User Login</title>
<style>
body{
font-family: calibri;
}
.form_container {
    border: 1px solid rgba(0, 0, 0, .05);
    box-shadow: 15px 26px 30px rgba(0, 0, 0, .09);
    border-left: 1px solid rgba(0, 0, 0, .06);
border-radius: 4px;
max-width: 500px;
padding: 20px 30px 30px;
text-align: center;
margin:0 auto;
}
.sanhead { font-size: 20px; }
.san { padding:20px; }
.error_message {
color: #b12d2d;
text-align: center;
background-color: #ffd9d9;
}
.message {
width: 100%;
max-width: 300px;
padding: 10px 30px;
border-radius: 4px;
margin: 0 auto;
margin-bottom: 5px;    
text-align: center;
}
.inputclass{
border: #CCC 1px solid;
padding: 10px 20px;
border-radius:4px;
}
.submit_button {
padding: 10px 20px;
background: #a9961e;
border: #736615 1px solid;
color: #FFF;
border-radius:4px;
}
</style>
</head>
<body>
<?php
if(!empty($error_message)) {
?>
<div class="message error_message"><?php echo $error_message; ?></div>
<?php
}
?>

<form name="frmUser" method="post" action="">
<div class="form_container">
<?php 
if($success == 1) { ?>
<div class="sanhead">Enter OTP</div>
<p style="color:#31ab00;">Check your email for the OTP</p>
<div class="san">
<input type="text" name="otp" placeholder="One Time Password" class="inputclass" required>
</div>
<div class="sanhead"><input type="submit" name="submit_otp" value="Submit" class="submit_button"></div>
<?php 
} else if ($success == 2) {
$result = mysqli_query($conn,"SELECT * FROM otpstore WHERE otp='" . $_POST["otp"] . "'");

$count=mysqli_num_rows($result);
$row=mysqli_fetch_array($result);

if($count > 0){
session_start();
$_SESSION['newid']=$row['newid'];
header('Location: securepage.php');
}
?>

<?php
}
else {
?>
<div class="sanhead">Enter Your Login Email</div>
<div class="san"><input type="text" name="email" placeholder="Email" class="inputclass" required></div>
<div class="sanhead"><input type="submit" name="submit_email" value="Submit" class="submit_button"></div>
<?php 
}
?>
</div>
</form>
</body>
</html>


mail_function.php

<?php
function sendOTP($email,$otp) {
require('phpmailer/class.phpmailer.php');
require('phpmailer/class.smtp.php');
$message_body = "One Time Password for PHP login authentication is:<br/><br/>" . $otp;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = 'tls'; // tls or ssl
$mail->Port     = "587";
$mail->Username = "your-mail-address";
$mail->Password = "password";
$mail->Host     = "your-host";
$mail->Mailer   = "smtp";
$mail->SetFrom("your-mail-address", "web");
$mail->AddAddress($email);
$mail->Subject = "OTP to Login";
$mail->MsgHTML($message_body);
$mail->IsHTML(true);
$result = $mail->Send();
return $result;
}
?>


securepage.php

<?php 
$conn = mysqli_connect("localhost","root","","demo");
ob_start(); session_start();
if(isset($_SESSION['newid']))
{
// header("location:index.php");
}
else
{
header("location:index.php");
}
?>
<div align="right"><a href="logout.php" style="margin-right:80px;">logout</a></div>
secure page test


logout.php

<?php
session_start();
session_destroy();
header('location:index.php');
?>

Change Textbox Value based on Select Box using Javascript & Jquery

Here i will tell you how to change the text box value based on above selected box value. This simple concept will done by using the JavaScript and Jquery. In this example i am taking the state when you selected the state from the drop down list it will display in the below text box. The selected value is passed from the select box to text box. The text box is read only you can't able to change the text box value. 

This value will passed the value using ids with the help of javascript. In this example have the live demo link, Please check out the demo and also download the code and use it. I hope this concept is very helpful to you



<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Change Textbox Value Based on Select Box</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script
type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"
></script>
<style type="text/css">
select, input
{   width: 200px;
padding: 12px;
margin:0 auto;
display:block;

}

.sandiv
{
width: 350px;
margin: 0 auto;
display: block;
padding: 40px;
text-align:center;
background-color: #4EAD51;
}
</style>
<script type="text/javascript">
$(window).load(function(){

$(document).ready(function() {

$("#state1 option").filter(function() {
return $(this).val() == $("#state").val();
}).attr('selected', true);

$("#state1").live("change", function() {

$("#state").val($(this).find("option:selected").attr("value"));
});
});

});

</script>
</head>
<body>

<div class="sandiv">
<h1 style="color:#fff;">Change Textbox Value Based on Select Box</h1>
<select id="state1" name="state1">
<option value="">Please State...</option>
<option value="Andhra">Andhra</option>
<option value="TamilNadu">TamilNadu</option>
<option value="Karnataka">Karnataka</option>
<option value="Kerala">Kerala</option>
</select>
<br/>
<br/>
Your Selected State <input type="text" id="state" name="state" value="" readonly="readonly">
<h3><a href="http://www.sanwebcorner.com/">www.sanwebcorner.com</a></h3>
</div>
<script>
if (window.parent && window.parent.parent){
window.parent.parent.postMessage(["resultsFrame", {
height: document.body.getBoundingClientRect().height,
slug: "nafnR"
}], "*")
}
</script>
</body>
</html>

Html5 In-built Validation for Form fields without any validation code

Here we will see now how to set the validation for all form fields without any validation code means Validation without validation code. Yes it is called as a built in validation, It is available in html5. Now we will see one by one with live example. Below i list out some of the fields with validation please check out those examples. Mostly here we will use the patterns to validate the fields with the specific format and conditions. 

Html5 In-built Validation for Form fields

Validation Without Validation Code in Html5

Html5: Required

required is one of the attribute used to validate the input field should not be blank(empty), It should contain some value. If you are not entering any value to the particular input required field it displays the error messages like 'Please fill out this field'.

Code:
<form onsubmit="alert('Submitted.');return false;" action="" >
  Name:  <input type="text" name="name" required>
  <input type="submit" value="submit">
</form>

Live Example:
Name:



Html5 Name Field Validation:

Mostly the name or username condition is should be the character small letter or capital letter. So i validate this name field like to enter only the character no special character and numbers are allowed here. Some of the usernames contain number so you can modify the pattern here just add 0-9 in pattern. Almost this is the Html5 name validation.

Name validation code:
<form onsubmit="alert('Submitted.');return false;">          
<input type="text" required="" pattern="[a-zA-Z]+" value="" >          
<input type="submit" value="submit">
 </form>

Live Demo



Html5 Email Field Validation:

Html5 Email validation is one of the important validation it is pre defined validation you just set the type="email" so the email validation done. No need to enter any email patterns here in Html5. check out the below live example.

Email validation code:
<form onsubmit="alert('Submitted.');return false;">          
<input type="email" required="" >          
<input type="submit" value="submit">
 </form>

Live Demo



Html5 Mobile Number Field Validation:

Most of the Html5 Mobile validation is should be number and digit restriction. Here i will validate the mobile number should be only numeric number and minlength=10 and maxlength=12. I think this is validation is enough to get real mobile number, If you want to add some condition please update the html5 pattern. see the live demo below to validate 
  
Mobile validation code:
<form onsubmit="alert('Submitted.');return false;">          
<input type="text" minlength="10" maxlength="12" pattern="[0-9]+" name="mobile" required="">           
<input type="submit" value="submit">
 </form>

Live Demo



Html5 Password Field Validation:

Html5 password validation is fully customization it is not a unique some of the people don't have any restriction for this password field. This password validation is totally different from different websites. here have a restriction at least  one capital letter and at least one small letter at least one number and  it should be 10 digit longer.

If you want one special character and one number and caps letter and small letter  AND min 8 character means you can use this pattern to validation : (?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$

Password validation code:
<form onsubmit="alert('Submitted.');return false;">          
<input type="password" minlength="10"  pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$name="password" required="">           
<input type="submit" value="submit">
 </form>

Live Demo



Html5 Date Field Validation:

Date validation in html5 is one of simple thing but it haves the different format Here i will used this format  DD.MM.YYYY . If you want different format means you can use the different html5 pattern. check the live example demo below for date field.

For example i given some pattern here
YYYY-MM-DD : [0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])
MM/DD/YYYY : (0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d
Date validation code:
<form onsubmit="alert('Submitted.');return false;">          
<input type="text" required="" pattern="(0[1-9]|1[0-9]|2[0-9]|3[01]).(0[1-9]|1[012]).[0-9]{4}" placeholder="Format: DD.MM.YYYY">         
<input type="submit" value="submit">
 </form>

Live Demo



Html5 Time Field Validation:

Here is the time validation using html5 inbuilt validation. You can use this time pattern for time validation. checkout the live example demo below to check the how the time validation working. If you want different time format please update the pattern .

Time validation code:
<form onsubmit="alert('Submitted.');return false;">          
<input type="text" required="" pattern="(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]){2}" placeholder="Format: HH:MM:SS">        
<input type="submit" value="submit">
 </form>

Live Demo



Html5 URL Field Validation:

This is url field html5 validation. This is predefined one, No need any of the validation pattern for this field only set the type="url" so it automatically check the validation for url. Check the below live example how the validation works for the url.
url validation code:
<form onsubmit="alert('Submitted.');return false;">          
<input type="url" id="url" name="url" required>       
<input type="submit" value="submit">
 </form>

Live Demo



Html5 Credit card Number Validation:

Credit card number validation in html5 with the help of pattern. This credit card number should be 13 to 16 digit numeric number to validate this using this html5 pattern [0-9]{13,16}. Check out the below example for credit card number validation.

credit card validation code:
<form onsubmit="alert('Submitted.');return false;">          
<input type="text" required="" pattern="[0-9]{13,16}" value=""  placeholder="Credit card No.">     
<input type="submit" value="submit">
 </form>

Live Demo



Html5 Indian Postal Code (pin code)  Validation:

This is one of the validation to validate the postal code or pin code validation. The Indian postal code contains the 6 digit number and not start with 0. Here i validate the pin code should be 6 digits number and it should not be start with 0. If you want any updation in the postal code validation you can change the  html5 pattern according to your requirement. Please refer the demo below 

Postal code  validation code:
<form onsubmit="alert('Submitted.');return false;">          
<input type="text" required="" pattern="^[1-9][0-9]{5}$" value=""  placeholder="Postal Code">  
<input type="submit" value="submit">
 </form>

Live Demo



Html5 Number Validation:

You can also validate numbers. Here is the validation is to accept numbers both decimal and without decimal numbers for example 5.8, 1500, 15,000 like that. check the below live example. you can change the  html5 patterns for validation according to your condition.
Numbers with or without decimals:
<form onsubmit="alert('Submitted.');return false;">          
<input type="text" required="" pattern="[-+]?[0-9]*[.,]?[0-9]+" value=""  placeholder="Format: 7 or 7.9 or 7,9"> 
<input type="submit" value="submit">
 </form>

Live Demo



Html5 Color Code Validation:

You also validate the color code, check the below  html5 pattern to validate color code and check the below live example  demo. I hope this will be very useful.
Color code  validation code:
<form onsubmit="alert('Submitted.');return false;">          
<input type="text" required="" pattern="^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$" value=""  placeholder="Format is #CCC or #CCCCCC">  
<input type="submit" value="submit">
 </form>

Live Demo



Html5 Price format  Validation:

You can validate price also. Here the  html5 price validation should be allowed the price two digits after the decimal point. If you are entering more than 2 digits it won't accept the value. You will modify the patterns according to your validation. 
Price  validation code:
<form onsubmit="alert('Submitted.');return false;">          
<input type="text" required="" pattern="\d+(\.\d{2})?" value=""  placeholder="Price (Format: 5.00)">  
<input type="submit" value="submit">
 </form>

Live Demo



Html5 Domain format  Validation:


Here you can validate the domain name it should be a string with dot after the dot 2digit minimum condition set in the html5 pattern. check out he live example demo below
Domain validation code:
<form onsubmit="alert('Submitted.');return false;">          
<input type="text" required="" pattern="^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$" value=""  placeholder="san.com">  
<input type="submit" value="submit">
 </form>

Live Demo
If you want to customize the error code means you can use the javascript to customize the form field validation error codes. 

Labels

360 degree view product image 3d rotate 3d text 3step-form Accordion menu ajax All Browsers Animated Background Gradient animation audio controller auto complete Best accordion menu bootstrap border bounce effect on hover Breadcrumb calculate age by dob calendar Captcha change image on mouse move color chooser countdown Counter on scroll Css css animation css buttons css hover css3 customized upload Button Date picker delete data from table Different scroll speed email otp verification email verifier Embed eventlist Expanding Menu feedbck form flash news section close button full screen menu Google custom search Google Maps Google reCAPTCHA Google site search gradient hide menu Horizontal News ticker Hover Htm Html html5 html5 form validation Iframe image hover increment decrement textbox value based on select box Javascript Jquery js Layered image effect on mouse hover marquee marquee with close button mobile number validation mobile otp login Multi-level-drop-down-menu multi-level-form mysql News ticker on hover change text to image our team page password strength checker Photoshop PHP Popup image on click the link pure css Random password Redirect page Based on the select box while submit the form responsive responsive menu responsive popup box Responsive Vertical Time line design rotate image simple coming soon page simple countdown based on end date simple typing effect slider sliding tab sms otp login statistic counter on scroll switch tag shape team member Time picker toggle toggle view transparent button underline animation up down slide validation vertical fixed sidebar Webtips Youtube