Sanwebcorner | Programming Blog

How to create html multi step form using html and jquery

Question type html form with jquery validation is one of the simple and looking good html form. This is totally different look when comparing to the other html forms.  Because it haves Question for each field step by step. In this form one interesting matter is to stick your result in next step. For example the first question is what is your name when you fill the field and go with next step , it ask with your next data with your name some thing like that, Please refer below screenshots for form display or visit the demo link you will understand clearly.check out other multi level form here

This types of multi level html forms very impress to your users and its totally different concept. This html form includes the perfect jquery validation each steps check out demo link you can able to see the validation rules. It displays the full result in final steps and it ask to submit when submit the mail function will execute.






index.html: (Multi step for design with jquery validation)

<html>
<head>
<title>Html Multi step question form</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<link href="https://fonts.googleapis.com/css?family=Sniglet" rel="stylesheet">
<script type="text/javascript">
$(window).load(function(){
$( "input" )
.keyup(function() {
var value = $( this ).val(),
dataViewId = $( this ).data( "view-id" );  // get your data-attribute value
// use this value as a selector:
$( dataViewId ).text( value );
})
.keyup();
});
</script>
<script src="js/jquery-ui.min.js"></script>
<script src="js/jquery.validate.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script>
// register jQuery extension
jQuery.extend(jQuery.expr[':'], {
focusable: function (el, index, selector) {
return $(el).is('a, button, :input, [tabindex]');
}
});
$(document).on('keypress', 'input,select', function (e) {
if (e.which == 13) {
e.preventDefault();
// Get all focusable elements on the page
var $canfocus = $(':focusable');
var index = $canfocus.index(this) + 1;
if (index >= $canfocus.length) index = 0;
$canfocus.eq(index).focus();
}
});
</script>
<?php $result="" ?>
</head>
<body>
<div class="container">
<h3 style="text-align:center; color:#fff;">www.sanwebcorner.com</h3>
<br><br>
<?php echo $result; ?>
<br/> <br/>
<form class="form-horizontal form" action="emailing-data.php" method="POST"  method="post" onsubmit="return submitUserForm();">
<div class="col-md-8 col-md-offset-2">   
<div class="progress">
<div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div id="g-recaptcha-error"></div>
<div class="box row-fluid">
<br>
<div class="step">
<div class="form-group">
<label for="name" class="control-label">Hey! What's your name? *</label>
<p class="santext">Let's just stick to first names for now :)</p>
<input type="text"  name="name" class="form-control saninput" id="name" data-view-id="#namen" placeholder="Type your answer here...">
</div>
</div>
<div class="step">
<div class="form-group">
<label for="institution" class="control-label">Okay, <span id="namen"></span>. Please tell me your Institution Name? *</label>
<input type="text"  name="institution" class="form-control saninput" id="institution" data-view-id="#institution" placeholder="Type your answer here...">
</div>
</div>
<div class="step">
<div class="form-group">
<label for="number" class="control-label">And tell me your contact Number? *</label>
<input type="text"  name="number" class="form-control saninput" id="number" data-view-id="#number" placeholder="Type your answer here...">
</div>
</div>
<div class="step">
<div class="form-group">
<label for="email" class="control-label">Amazing, thanks <span id="namen"></span> :)
<p class="santext">Now, just give us your email address, hit the submit button and our team will contact you as soon as possible. * </p></label>
<input type="text"  name="email" class="form-control saninput" id="email" data-view-id="#email" placeholder="Type your answer here...">
</div>
</div>
<div class="step display">
<h4 style="color:#fff; text-align:center;     font-size: 45px;
text-decoration: underline;">Confirm Details </h4>
<div class="form-group">
<label class="col-sm-6 control-label sanq">Name :</label>
<label class="col-md-6 control-label lbl sana" data-id="name"></label>
</div>
<div class="form-group">
<label class="col-sm-6 control-label sanq"> Institution Name :</label>
<label class="col-md-6 control-label lbl sana" data-id="institution"></label>
</div>
<div class="form-group">
<label class="col-sm-6 control-label sanq">Email :</label>
<label class="col-md-6 control-label lbl sana" data-id="email"></label>
</div>
<div class="form-group">
<label class="col-sm-6 control-label sanq">Contact Number :</label>
<label class="col-md-6 control-label lbl sana" data-id="number"></label>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="pull-right">
<button type="button" class="action btn-sky text-capitalize back btn">Back</button>
<button type="button" class="action btn-sky text-capitalize next btn">Next</button>
<input type="submit" name="submit"  id="btn-validate"  class="action btn-hot text-capitalize submit btn" value="Submit Your Data" />
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<script type="text/javascript">
$(document).ready(function(){
var current = 1;
widget      = $(".step");
btnnext     = $(".next");
btnback     = $(".back");
btnsubmit   = $(".submit");
// Init buttons and UI
widget.not(':eq(0)').hide();
hideButtons(current);
setProgress(current);
// Next button click action
btnnext.click(function(){
if(current < widget.length){
// Check validation
if($(".form").valid()){
widget.show();
widget.not(':eq('+(current++)+')').hide();
setProgress(current);
}
}
hideButtons(current);
})
// Back button click action
btnback.click(function(){
if(current > 1){
current = current - 2;
if(current < widget.length){
widget.show();
widget.not(':eq('+(current++)+')').hide();
setProgress(current);
}
}
hideButtons(current);
})
$('.form').validate({ // initialize plugin
ignore:":not(:visible)",
rules: {
name     : "required",
number   : {required : true, number:true, minlength:10, maxlength:10},
email    : {required : true, email:true},
institution : "required",
},
});
});
// Change progress bar action
setProgress = function(currstep){
var percent = parseFloat(100 / widget.length) * currstep;
percent = percent.toFixed();
$(".progress-bar").css("width",percent+"%").html(percent+"%");
}
// Hide buttons according to the current step
hideButtons = function(current){
var limit = parseInt(widget.length);
$(".action").hide();
if(current < limit) btnnext.show();
if(current > 1) btnback.show();
if (current == limit) {
// Show entered values
$(".display label.lbl").each(function(){
$(this).html($("#"+$(this).data("id")).val());
});
btnnext.hide();
btnsubmit.show();
}
}
</script>
</body>
</html>


emailing-data.php

<?php
if(isset($_POST['submit'])){
$to = "Your Mail id";
$from = "Your Mail id";
$name = $_POST['name'];
$email = $_POST['email'];
$mobile = $_POST['number'];
$institution = $_POST['institution'];
$subject = "New Emailer Registration Information";
$message = " \n\n Name:".$name . "\n\n Institution Name:".$institution . "\n\n Email : " . $email ."\n\n Mobile :".$mobile."\n\n" ;
$headers2 = "New Emailer Registration Information: " . $email;
if (mail($to,$subject,$message,$headers2))
{
$result='<div class="alert alert-success">Thank for your interest, we will contact you soon...</div>';
}
else
{
$result='<div class="alert alert-danger">Sorry there was an error sending your message. Please try again later</div>';
}
}
?>
<html>
<head>
<title>Html Multi step question form</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<link href="https://fonts.googleapis.com/css?family=Sniglet" rel="stylesheet">
</head>
<body>
<div class="container">
<h3 style="text-align:center; color:#fff;">www.sanwebcorner.com</h3>
<br><br>
<?php echo $result; ?>
<br/> <br/>
</div>
</body>
</html>



Multi-Step html form Screenshots:



multi-step-form

question-type-form

html-type-form

html-step-form

different-type-form

html form-details

html form-result


Display Form Field data before Form submit

Now i will show you how to display form field validation before form submission. This is one of the simple concept and also useful one for our projects. This concept will done by using the JavaScript and Jquery.

In this example form i am used two different form field one is firstname and another one is give your location. when you enter the location it shows your entered firstname value before the label. In this example haves the demo page. Check out the demo page you will get to know the result of this concept. you also download the script from download page below. I hope this example is really helpful.







<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Display Form Field data before Form submit</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(window).load(function(){

$( "input" )
.keyup(function() {
var value = $( this ).val(),
dataViewId = $( this ).data( "view-id" );  // get your data-attribute value
// use this value as a selector:
$( dataViewId ).text( value );
})
.keyup();

});

</script>
<style>
.swc
{
height:35px;
border:1px solid green;

}

</style>
</head>
<body>
<h2 style="text-align:center;">Display Form Field data before Form submit</h2>
<table style="width:480px; margin:0 auto;">
<tr>
<td>First Name:</td>
<td><input type="text" data-view-id="#firstname" class="swc"/></td>
</tr>

<tr>
<td>Hello <span id="firstname"> </span> <span id="lastname"> </span> Give your Location:</td>
<td> <input type="text" data-view-id="#location" class="swc" /></td>
</tr>
<br/><br/>
<h3><a href="http://www.sanwebcorner.com/">www.sanwebcorner.com </a></h3>
</body>
</html>


Lock & Unlock page scroll using Jquery

Some times we need to lock & unlock the scroll bar in the webpages. This is very simple we will do this using the simple javascript and jquery, In this post we will see how to lock & unlock the webpage scroll using jquery. This concept is full body will loack using the button and also unloack the scroll body using the unlock button this two button action will works based on the javascript. 

In this concept when you click the lock button the you can't able to scroll the mouse jin the particular page until you click the unlock button once you click the unlock boutton you can able to scroll the page. This is called as a fullscreen scroll lock and unloack. This example have live demo and the download file you can use it. I hope this example is very useful.



Code for lock and unlock page scroll using Jquery


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Lock & Unlock page scroll using Jquery</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="jquery.lockscroll.js"></script>
<style type="text/css">
#window {
position: fixed;
right: 10px;
top: 10px;
}
button {
margin-bottom: 20px;
}
#outer {
height: 1200px;
}

#element {
width: 400px;
height: 200px;
overflow: scroll;
}
h1
{
margin-top:125px;
}
</style>
</head>
<body>
<div id="window">
Window control
<button id="window-lock">Lock Scroll</button>
<button id="window-unlock">Unlock Scroll</button>
</div>
<h1>jQuery lockscroll Demo</h1>
</div>
Element control
<h1>jQuery lockscroll Demo</h1>
<h1>jQuery lockscroll Demo</h1>
<h1>jQuery lockscroll Demo</h1>
<h1>jQuery lockscroll Demo</h1>
<h1>jQuery lockscroll Demo</h1>
<h1>jQuery lockscroll Demo</h1>
<h1>jQuery lockscroll Demo</h1>
<h1>jQuery lockscroll Demo</h1>
<h1>jQuery lockscroll Demo</h1>
<h1>jQuery lockscroll Demo</h1>
<h1>jQuery lockscroll Demo</h1>
<h1>jQuery lockscroll Demo</h1>
<h1>jQuery lockscroll Demo</h1>
<h1>jQuery lockscroll Demo</h1>
<h1>jQuery lockscroll Demo</h1>

<script>
$(function() {
$("#window-lock").click(function() {
$.lockScroll();
});

$("#window-unlock").click(function() {
$.lockScroll(false);
});

$("#lock").click(function() {
$("#element").lockScroll();
});

$("#unlock").click(function() {
$("#element").lockScroll(false);
});
});
</script>
</body>
</html>

How to populate html dropdown based on another dropdown using Jquery

Populate the Dropdown based on another dropdown is very easy and simple, Now we will see how to do this without any database using jquery and javascript. This will done by using html dropdown or select box, It is dynamically display the particular dropdown data based on main html dropdown. In this example i am using the list of branch in main dropdown, the branches like Machanical , css&IT, Civil, EEE based on this select box display the differnt courses when you select the machanical the machanical course will display the another html dropdown, this will automatically populated based on main dropdown.

 This example completely working with the help of Jquery and javascript. The below javascript code is used to poplulate the data to the dropdown.

<script type="text/javascript">
var courseByCategory = {
Mechanical: ["Mec-course-1", "Mec-course-2", "Mec-course-3", "Mec-course-4"],
Civil: ["Civ-course-1", "Civ-course-2", "Civ-course-3", "Civ-course-4"],
IT: ["IT-course-1", "IT-course-2", "IT-course-3", "IT-course-4"],
EEE: ["EEE-course-1", "EEE-course-2", "EEE-course-3", "EEE-course-4"]
}
function changecat(value) {
if (value.length == 0) document.getElementById("course").innerHTML = "<option></option>";
else {
var catOptions = "";
for (categoryId in courseByCategory[value]) {
catOptions += "<option>" + courseByCategory[value][categoryId] + "</option>";
}
document.getElementById("course").innerHTML = catOptions;
}
}
</script>

The below example haves the demo link and download link you will visit the demo page how the html dorpdown populate based on the another dropdown or select box and i also provided the download link you can download and use the code based on your requirement. It may very useful in various places in your web application development. I hope this is very useful to you.




Code for html dorpdown based on another dropdown:


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>How to populate html dropdown based on another dropdown using Jqery</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<!-- TODO: Missing CoffeeScript 2 -->
<script type="text/javascript">
var courseByCategory = {
Mechanical: ["Mec-course-1", "Mec-course-2", "Mec-course-3", "Mec-course-4"],
Civil: ["Civ-course-1", "Civ-course-2", "Civ-course-3", "Civ-course-4"],
IT: ["IT-course-1", "IT-course-2", "IT-course-3", "IT-course-4"],
EEE: ["EEE-course-1", "EEE-course-2", "EEE-course-3", "EEE-course-4"]
}

function changecat(value) {
if (value.length == 0) document.getElementById("course").innerHTML = "<option></option>";
else {
var catOptions = "";
for (categoryId in courseByCategory[value]) {
catOptions += "<option>" + courseByCategory[value][categoryId] + "</option>";
}
document.getElementById("course").innerHTML = catOptions;
}
}
</script>


<style>
select
{
padding: 12px;
min-width:280px;
margin-top:10px;
}

.san{
width:280px;
margin:0 auto;
margin-top:90px;
background-color:#009688;
padding:55px;
}

label
{
color:#fff;
margin-bottom:25px;
}

html{
    background-color: #0aa798;
}
</style>

</head>
<body>
<div class="san">
<label>Select Branch: &nbsp; &nbsp; &nbsp; </label>
<select name="branch" id="branch" onChange="changecat(this.value);">
<option value="" disabled selected>Select</option>
<option value="Mechanical">Mechanical</option>
<option value="Civil">Civil </option>
<option value="IT">Csc & IT</option>
<option value="EEE">EEE</option>
</select>
<br/><br/>

<label>Select Course:  &nbsp; &nbsp; &nbsp; </label>
<select name="course" id="course">
<option value="" disabled selected>Select</option>
</select>
</div>
<h1 style="text-align:center; text-decoration:none; color:#fff;"><a style="text-decoration:none; color:#fff;" href="http://www.sanwebcorner.com/">www.sanwebcorner.com</a></h1>
</body>
</html>

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>

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 html dropdown html form html5 html5 form validation Iframe image hover increment decrement textbox value based on select box Javascript Jquery js Layered image effect on mouse hover lock & unlock page scroll marquee marquee with close button mobile number validation mobile otp login Multi-level-drop-down-menu multi-level-form Multi-Step-form mysql News ticker on hover change text to image our team page password strength checker Photoshop PHP populate html selectbox Popup image on click the link pure css Question type form 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 selectbox based on select box 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