Sanwebcorner | Programming Blog

Download selected file in zip format using php form

Hi friends now we will see how to download user selected files from php form in zip file format. In this example I used 3 different dummy files for download, format of this files are file1 php format, file2 doc format, file3 image format. This files I saved in the folder name called as a files. I stored all this option files in the array name called as a lang[]. I used get method this php form to get the user selected files. I stored the zip file in temp path.

I provided full code here you can modify this in your way. Visit the live demo then you will get an idea how it is working. You can download the files by clicking download button below. I hope this Download selected file in zip format using php form example will help you.




Code for download zip file format for selected file:


<!DOCTYPE html>
<html lang="en">
<head>
<title>Download selected file in zip format using php form</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<style>

.container {
max-width: 500px;
width:100%;
margin: 100px auto;
display: block;
background-color: #ffc107;
padding: 40px;
border: 1px solid #cc9b09;
border-radius: 22px;
}

.sanf
{
margin-right: 40px;
font-size: 18px;
}

[type=button]:not(:disabled), [type=reset]:not(:disabled), [type=submit]:not(:disabled), button:not(:disabled)
{
background-color: #b78d0f;
border: 0px;
padding: 10px 25px;
margin: 18px auto;
width: 250px;
display: block;
color: #fff;
font-weight: bold;

}
</style>
</head>
<body>


<div class="container">
<!-- Control the column width, and how they should appear on different devices -->
<form method="GET" action=""  class="form-group">
<div class="form-group"> <input type="text" placeholder="Enter your name" class="form-control"  /></div><br/>
<div class="checkbox">
<p><span> <strong>Select Your Files</strong></span></p>
<span class="sanf"><input type="checkbox" name='lang[]' value="file1.php" > File1 </span>
<span class="sanf"><input type="checkbox" name='lang[]' value="file2.docx"> File2 </span>
<span class="sanf"><input type="checkbox" name='lang[]' value="file3.png" > File3  </span><br/><br/>
<input type="submit" value="Submit" name="submit" >
</form>
</div>
</div>
</body>
</html>

<?php
$error = ""; //error holder

$post = $_GET;
$file_folder = "files/"; // folder to load files
if(extension_loaded('zip'))
{
// Checking ZIP extension is available
if(isset($post['lang']) and count($post['lang']) > 0)
{
// Checking files are selected
$zip = new ZipArchive(); // Load zip library
$zip_name ="Download.zip"; // Zip name
if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE)
{
// Opening zip file to load files
$error .= "* Sorry ZIP creation failed at this time";
}
foreach($post['lang'] as $file)
{
$zip->addFile($file_folder.$file); // Adding files into zip
}
$zip->close();


if(file_exists($zip_name))
{

// push to download the zip
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$zip_name.'"');
readfile($zip_name);
// remove zip file is exists in temp path
unlink($zip_name);
}

}
else
$error .= "* Please select file to zip ";
}
else
$error .= "* You dont have ZIP extension";

?>

WishList Heart Animation on Click

Today will see one interesting animation using simple html and css, Heart shape change animation on click event this animation is very useful for anything especially for wishlist. This animation is fully play with background property. In this main thing is heart shape image. Please check the code below and check the live demo how it is working... You can download the file by clicking the download button below. I hope this example is very useful to you.



WishList Heart Animation on Click


<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
  <title>onclick wishlist heart animation</title>
  <style>
.heart {
  width: 100px;
  height: 100px;
  background: url("heart.png") no-repeat;
  background-position: 0 0;
  cursor: pointer;
  transition: background-position 1s steps(28);
  transition-duration: 0s;
}
.heart.is-active {
  transition-duration: 1s;
  background-position: -2800px 0;
}



.stage {
  position: fixed;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
}
</style>
</head>
<body>

<div class="stage">
  <div class="heart"></div>
</div>

  <script src='https://code.jquery.com/jquery-2.2.4.min.js'></script>
  <script>
  $(function() {
  $(".heart").on("click", function() {
    $(this).toggleClass("is-active");
  });
});
  </script>

</body>
</html>

Simple Html Paypal Integration Form

Now we will see how to create html donation form using paypal. This is very simple for that you need one paypal account then you can create a html form. But you need to pass the paypal required parameter values. Now we can see what all are the parameter requrired by paypal



1. item_name

2. item_number

3. amount

4. Shipping values

5. currency_code

6. CustomerName

7. CustomerEmail

You will give those values in the form, you can pass the some values in the hidden field also. In this example you can see the code some of the values i given in the hidden field. This is not only a donation form you can use it for your product also. Now this form is in sandbox mode if you want live mode change form action from https://sandbox.paypal.com/cgi-bin/webscr url to https://www.paypal.com/cgi-bin/webscr This example have the demo you can check it out in the damo link and you can also download full code by clicking the download button below. I hope this example is very useful to you.

Html Paypal Form:

<html>
<head>
<title></title>
<style>
.sanform
{
   width: 400px;
    background-color: #FFC107;
    padding: 25px;
    margin: 0 auto;
}

input, select{
width: 400px;
    height: 40px;
}

input[type="submit"]
{
background-color: #82640a;
    border-color: #82640a;
    color: #fff;
}
</style>
</head>
<body>

<form action="https://sandbox.paypal.com/cgi-bin/webscr" method="post" class="sanform">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="sanwebcorneronline@gmail.com">
    <strong>Donation / Contribution? </strong><br />
    <select name="item_name">
      <option value="Donation">Donation</option>
      <option value="Contribution">Contribution</option>
    </select><br />   <br />

    <strong>Which tutorial are you donating for?</strong><br /> 
    <select name="item_number">
      <option value="PayPal Form Tutorial">sanwebcorner.com</option>
      <option value="Amazon S3 Tutorial">sanwebtutorial</option>
      <option value="Some Other Tutorial">others</option>
    </select>
    <input type="hidden" name="amount" value="200" >
    <input type="hidden" name="no_shipping" value="0">
    <input type="hidden" name="no_note" value="1">
    <input type="hidden" name="currency_code" value="USD">
<input value="CustomerName" name="on0" type="hidden">
<input value="CustomerEmail" name="on1" type="hidden">
<br /><br />
<div class="first_name_invoice_payment">
    <strong>First/Last name (required)</strong> <br />
    <input value="" name="os0" required>
</div>
<br />
<div class="email_invoice_payment">   
   <strong> Email (requiered)</strong><br />
    <input value="" name="os1" required>
</div>

    <input type="hidden" name="return" value="http://www.sanwebcorner.com/">

    <br /><br />
    <input type="submit" value="Pay with PayPal!">
</form>
</body>
</html>


Live JavaScript Form Validation

Now will see how to create a from with user friendly live validation using JavaScript and bootstrap. Here i just created a from contains three field namely Name, Email, Password field. In the name field i did validation like it should allows only alphabets it should not contain any number or special character. If you type a number or any special character in the name field immediately it will show the validation error because i used keyup function for validation.

In the same way the Email should be email format and Password should be 6 to 16 character. Must contain one letter, one number, one special character. If you use some other combination it shows the validation error. This concept is very useful and it is user friendly , in the field itself the user get to know how the field should be, No need to click submit button.





This example have the live demo link, Just click the link you will see how the validation will work. And also download the code by clicking the download button i given full code there you can modify and use it to your projects. I hope this concept is very useful.

Bootstrap form:

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

</head>
<body>

<div class="container">
  <h2>Live User friedly Validation.</h2>
  <form action="#">
    <div class="form-group">
      <label for="Name">Name: (try to Enter Special character)</label>
      <input type="text" class="form-control Name" required id="Name" placeholder="Enter Name" name="Name">
    </div>
   
      <div class="form-group">
        <label for="email">Email:</label>
        <input type="email" class="form-control" required id="email" placeholder="Enter email" name="email">
      </div>
    <div class="form-group">
      <label for="pwd">Password:</label>
      <input type="password" class="form-control" required id="pwd" placeholder="Enter password" name="pswd">
    </div>
    <button type="submit" class="btn btn-primary">Submit</button>
  </form>
</div>

</body>
</html>

Javascript code for Validation

<script>
$('.Name').keyup(function() {
    $('span.error-keyup-2').remove();
    var inputVal = $(this).val();
    var characterReg = /^\s*[a-zA-Z,\s]+\s*$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error error-keyup-2" style="color:red">No special characters and numbers allowed.</span>');
    }
});


$('#email').keyup(function() {
    $('span.error-keyup-7').remove();
    var inputVal = $(this).val();
    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,8})?$/;
    if(!emailReg.test(inputVal)) {
        $(this).after('<span class="error error-keyup-7" style="color:red">Invalid Email Format.</span>');
    }
});



$('#pwd').keyup(function() {
    $('span.error-keyup-8').remove();
    var inputVal = $(this).val();
    var emailReg = /^(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9!@#$%^&*]{6,16}$/;
    if(!emailReg.test(inputVal)) {
        $(this).after('<span class="error error-keyup-8" style="color:red">Password should be 6 to 16 character. Must contain one letter, one number, one special character.</span>');
    }
});
</script>


Auto Hide Alert Box using Bootstrap and Jquery

 Today we are going to see how to create auto hide alert box. This type of auto alert box is useful when you display message on any of the user activities. This is user friedly it automatically close the alert box based on the time you set. It also contain the close icon to manually close the alertbox by clicking close button.

 This alert box responsive one because we are using bootstrap framework. This auto close alert box created by using bootstrap and jquery. Here is the demo page you can see the live demo by click demo button below. You can download the code and use it. I hope this is very simple and very useful to you.


Auto Hide Alert box using Bootstrap:

<!DOCTYPE html>
<html>
<head>
<title> Auto Hide Alert box using Bootstrap</title>
<style>
.alert
{
max-width:500px;
margin:0 auto;
margin-top:50px;
}

.san-button
{
    background-color: #009688 !important;
    color: #fff !important;
    width: 161px;
    margin: 0 auto;
    display: block !important;
}
</style>
</head>
<body>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />

<div class="product-options">
  <a id="myWish" href="javascript:;" class=" san-button btn btn-mini">Click for Alert box </a>
</div>
<div class="alert alert-success" id="success-alert">
  <button type="button" class="close" data-dismiss="alert">x</button>
  <strong>Success! </strong> Product have added to your wishlist.
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
  $("#success-alert").hide();
  $("#myWish").click(function showAlert() {
    $("#success-alert").fadeTo(2000, 500).slideUp(500, function() {
      $("#success-alert").slideUp(500);
    });
  });
});
    </script>
</body>
</html>

Multi Select Checkbox jquery and Bootstrap


Now we will see how to create dropdown muliple select with checkbox. bootstrap multiselect.js is convert the normal select box to multi select box with select all button. the select all button used to select the all values and return the values. Using keyboard and mouse you can select the muliple check box in the dropdown.

Below example shows you How to use Checkbox inside Select Option. This example have the full source code and demo link. check out the example and demo link and code. I hope this example really helpful.




Multi Select Checkbox Code:

<html>
<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="text/css" />
<script src="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/js/bootstrap-multiselect.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#lstFruits').multiselect({
includeSelectAllOption: true
});

$('#btnSelected').click(function () {
var selected = $("#lstFruits option:selected");
var message = "";
selected.each(function () {
message += $(this).text() + " " + $(this).val() + "\n";
});
alert(message);
});
});
</script>
<body>
<select id="lstFruits" multiple="multiple">
<option value="1">Mango</option>
<option value="2">Apple</option>
<option value="3">Banana</option>
<option value="4">Guava</option>
<option value="5">Orange</option>
</select>
<input type="button" id="btnSelected" value="Get Selected" />
</body>
</html>

How to create whatsapp link for website


Now a days WhatsApp is one of the important Messenger. Lot of peoples using WhatsApp Messenger so it is important to add whatsapp link to the website. Now will see how to add the whatsapp link to social media icon. when you add this link to site client directly will chat with your whatsapp number using your whatsapp number. Now we can see how to link this to website. Below is the code to link the whatsapp to website. You just use the code and link it to your website. Below code you can change your number from the below code.

whatsapp-link-for-website



Html code for whatsapp link

<html>
<head>
<title>How to create whatsapp link for website  </title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>


<i class="fa fa-whatsapp" aria-hidden="true"></i> <a class="btn-fill btn-blue sanbg" href="https://api.whatsapp.com/send?phone=919902142421&amp;text=Hi there! I have a question :)">Send Message</a>

</body>
</html>

Screenshots


whatsapp-social-link-website

whatsapp-website-link

Multiple File Upload in PHP


In this article we will see how to upload multiple files in php. It is possible to upload multiple files in single input upload field using html and php. After upload will send the data and uploaded files to the particular email id using the php mailer. First you need to create html form with the required fields and you should add the enctype="multipart/form-data" to the form to accept upload and add post method to form.

Then set action to "mail-send.php" file. Here you can write the code to send the form fields data to mail using php mailer. Here you can set the loop for multiple attachments. This example is working fine and i given complete code to your reference and also i given the demo link for this example. Click the demo link and check it out the result of this example.


index.php

<html>
<head>
<title>Upload multiple files in php form at a time</title>
<link rel="stylesheet" type="text/css" href="swc.css">
<script src="jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function (e){
$("#sanForm").on('submit',(function(e){
e.preventDefault();
$('#loader-icon').show();
var valid;
valid = validateContact();
if(valid) {
$.ajax({
url: "mail-send.php",
type: "POST",
data:  new FormData(this),
contentType: false,
cache: false,
processData:false,
success: function(data){
$("#mail-status").html(data);
$('#loader-icon').hide();
},
error: function(){}      

});
}
}));

function validateContact() {
var valid = true;
$(".formfield").css('background-color','');
$(".info").html('');
$("#u_name").removeClass("invalid");
$("#u_email").removeClass("invalid");
$("#subject").removeClass("invalid");
$("#comment").removeClass("invalid");

if(!$("#u_name").val()) {
$("#u_name").addClass("invalid");
        $("#u_name").attr("title","Required");
        valid = false;
}
    if(!$("#u_email").val()) {
        $("#u_email").addClass("invalid");
        $("#u_email").attr("title","Required");
        valid = false;
    }
    if(!$("#u_email").val().match(/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/)) {
        $("#u_email").addClass("invalid");
        $("#u_email").attr("title","Invalid Email");
        valid = false;
    }
if(!$("#subject").val()) {
$("#subject").addClass("invalid");
        $("#subject").attr("title","Required");
valid = false;
}
if(!$("#comment").val()) {
$("#comment").addClass("invalid");
        $("#comment").attr("title","Required");
valid = false;
}

return valid;
}

});
</script>
</head>
<body>
<form id="sanForm" action="" method="post" enctype='multipart/form-data'>
<div id="loader-icon" style="display: none;">
    <img src="ajax-loading-icon.gif" style="width: 85px;"/>
</div>
    <div id="mail-status"></div>
    <div>
        <input
            type="text" name="u_name" id="u_name"
            class="formfield" placeholder="Name">
    </div>
    <div>
        <input type="text" name="u_email" id="u_email"
            class="formfield" placeholder="Email">
    </div>
    <div>
        <input type="text" name="subject" id="subject"
            class="formfield" placeholder="Subject">
    </div>
    <div>
        <textarea name="comment" id="comment" class="formfield"
            cols="60" rows="6" placeholder="comment"></textarea>
    </div>
    <div>
        <label>Attachment</label><br /> <input type="file"
            name="attachment[]" class="formfield" multiple="multiple">
    </div>
    <div>
        <input type="submit" value="Send" class="san_button" />
    </div>
</form>
</body>
</html>

mail-send.php

<?php
require('phpmailer/class.phpmailer.php');
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->Mailer = "mail";
$mail->SMTPDebug = 1;
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = "tls";
$mail->Port     = 587;
$mail->Username = "Your username";
$mail->Password = "Your password";
$mail->Host     = "Your Host";
$mail->Mailer   = "smtp";
$mail->SetFrom("From Email", "website");
$mail->AddReplyTo($_POST["u_email"], $_POST["u_name"]);
$mail->AddAddress("To Email");
$mail->Subject = $_POST["subject"];
$mail->WordWrap   = 80;
$message='';
$message.="Name  : ".$_POST['u_name']." <br/>";
//$message='';
$message.="Email  : ".$_POST['u_email']." <br/>";
$message.="Subject  : ".$_POST['subject']." <br/>";
$message.="Email  : ".$_POST['comment']." <br/>";
$mail->MsgHTML($message);

foreach ($_FILES["attachment"]["name"] as $k => $v) {
    $mail->AddAttachment( $_FILES["attachment"]["tmp_name"][$k], $_FILES["attachment"]["name"][$k] );
}

$mail->IsHTML(true);
if(!$mail->Send()) {
echo "<p class='error'>Problem in Sending Mail.</p>";
} else {
echo "<p class='success'>Mail Sent Successfully.</p>";
}
?>



Multi File upload result screenshot:

How to generate php random number

Here i will tell you how to generate random number using php random function, rand() this is the function to create the random number in php if you are used this function it generate the random number with any of the digits it may display the 5 digit number or 8 digit number or any thing.
 if you are using the specified range in the random number it generates the specified digits.

 If you want two digit random number then you can use this function echo(rand(10,99)); if you can want the 5 digit random number then you can use  echo(rand(10000,99999)) this function this is nothing but you can set the minimum and maximum number , 

This function displays the random number between the the minimum and maximum number you specified in the function. I hope this is really helpful to you to create simple random code. It is very useful to generate opt in some projects. In this example have the demo link check the result of the below example. and also have the download code please check



kllk


How to Create random number using php:

<html>
<head>
<title>How to create random number using php</title>
</head>
<body>
<h1>Default random number</h1>
<?php echo(rand() . "<br>"); ?><br/>

<h1>Random number for specified(with min number and max number)</h1>
<?php echo(rand(10,1000)); ?><br/>

<h1>Random number with digit</h1>

<h2>If you want two digit number</h2>
<?php echo(rand(10,99)); ?><br/>

<h2>If you want five digit number</h2>
<?php echo(rand(10000,99999)); ?><br/>


<h2>If you want nine digit number</h2>
<?php echo(rand(100000000,999999999)); ?><br/>


<h2>If you want seven digit number</h2>
<?php echo(rand(1000000,9999999)); ?><br/>

<h2>If you want one digit number</h2>
<?php echo(rand(0,9)); ?><br/>
</body>
</html>

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


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 Bootstrap form validation border bounce effect on hover Breadcrumb calculate age by dob calendar Captcha change image on mouse move color chooser countdown Counter on scroll create random number Css css animation css buttons css hover css3 customized upload Button Date picker delete data from table Different scroll speed donation form download zip 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 heart animation hide menu Horizontal News ticker Hover Htm Html html dropdown html form html form validation html5 html5 form validation Iframe image hover increment decrement textbox value based on select box Javascript javascript validation Jquery jquery validation 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-select-checkbox Multi-Step-form Multiple File Upload in PHP mysql News ticker on hover change text to image our team page password generator password strength checker paypal form paypal html form Photoshop PHP php mailer populate html selectbox Popup image on click the link pure css Question type form random number generate 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 whatsapp link website Whislist Youtube