Sunday, July 19, 2015

anil

How to create a login form without using database and display data on a next page in php




Step 1:- First create a page login.php in your specified folder as follow:-

#login.php
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript">
 function formvalidator(){     
// Make sure that all of the form variables, etc are valid
var f = document.outlet_search;
var atpos =f.email.value.indexOf("@");
if(f.name.value.length<1){
    alert('Name should be atleast 2 words.');
    f.name.focus();
   return false;
}
if (atpos<1 ) {
        alert("Not a valid e-mail address");
        return false;
    }
if(f.pass.value.length<3){
    alert('Password should be atleast 4 words.');
    f.pass.focus();
    return false;
}
</script>
</head>
<body>
 <div id="header">
   <div class="header-left">
     Your logo
   </div>   
 </div> 
    <div id="wrapper">
<div class="container">  
            <div class="center"> 
                <form action="show.php" onsubmit="return formvalidator();" name="outlet_search" method="POST">
                    <table cellspacing="0" cellpadding="8" width="100%" style="border:1px solid;">
                        <tr>
                            <td width="35%">Full Name:</td><td width="50%"><input class="input" type="text" id="name" name="name"></td>
                        </tr>
                        <tr>
                            <td>Email:</td><td><input class="input" type="text" name="email"></td>
                        </tr>
                        <tr>
                            <td>password:</td><td><input class="input" type="password" name="pass"></td>
                        </tr>
                        <tr>
                            <td></td><td><input type="submit" name="submit" value="submit" /></td>
                        </tr>
                    </table>
                </form>
            </div>
</div>
    </div>
</body>
</html>
Step 3:- Above I linked style.css because i created style.css and put it to in css folder.

#style.css
/* CSS Document */
body {
font-family: "Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 13px;
line-height: 19px;
color: #000;
background-color: #f5f5f5;}
#header{ height:78px; width:100%;background: #4d5b76;
background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #4d5b76), color-stop(1, #6c7a95));
background: -ms-linear-gradient(bottom, #4d5b76, #6c7a95);
background: -moz-linear-gradient(center bottom, #4d5b76 0%, #6c7a95 100%);
background: -o-linear-gradient(bottom, #4d5b76, #6c7a95);
    border-color: -moz-use-text-color;}
.header-left{height:auto; width:auto; background:url(images/logo.png); float:left; margin:10px 10px 10px 10px;}
#wrapper{ width: 100%;
margin: 0 auto; }
.container{width:630px; height:auto;  margin:0 auto;}
.center{width:600px; height:auto; /*margin-left:315px; */ margin-top:20px; padding:0;}
.center_left{ float:left; width:200px; height:auto}
.center_right{ float:right; width:200px; height:auto}
.center h1{height:20px; width:auto; margin:auto; padding:8px; background:#666666; color:#00000;}
.top-div {
width: 83%;
margin: 0 auto;
padding: 0;
background: url("../images/page_bg.gif");
}
.top-div span {
width: 100px;
height: 100px;
}
.contactt-left {
width: 414px;
margin-left: 20px;
margin-top: 20px;
float: left;
}
table {
max-width: 100%;
background-color: transparent;
border-collapse: collapse;
border-spacing: 0;
}
table tr{ margin:5px;}
.input{ width:200px;}
Step 2:- Above in the form I gave action on show.php so I am create a new page show.php.

#show.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="css/styel.css" />
</head>
<body>
 <div id="header">
   <div class="header-left">
      Your website Logo
   </div>   
 </div> 
    <div id="wrapper">
<div class="container" >  
            <div class="center">
                <?php if(isset($_REQUEST['submit'])){
                        $name=$_REQUEST['name'];
                        $email=$_REQUEST['email'];
                        $pass=$_REQUEST['pass'];
                       ?>
                  <table cellspacing="0" cellpadding="8" width="100%" style="border:1px solid;">               
                         <tr>
                           <td width="35%">Full Name:</td><td width="50%"><?php echo $name; ?></td>
                         </tr>
                                         <tr>
                           <td>Email:</td><td><?php echo $email; ?></td>
                         </tr>
                                         <tr>
                           <td>password:</td><td><?php echo $pass; ?></td>
                         </tr>

                 </table>
                 <?php } ?>    
            </div>
        </div>
    </div>
</body>
</html>
NOTE:- Above I used $_REQUEST(can be use in both case either method is get or post) method to get data after submitting from login.php page.

Stpe 3:- When you run it on browser it will look like this:-


Step 4:- After submit information you will see your information on show.php

So using this process you can create a simple login process without create session or database.


About Author -

Hi, I am Anil.

Welcome to my eponymous blog! I am passionate about web programming. Here you will find a huge information on web development, web design, PHP, Python, Digital Marketing and Latest technology.

Subscribe to this Blog via Email :

Note: Only a member of this blog may post a comment.