Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- </head>
- <body>
- <style>
- body {
- width:400px;
- height:auto;
- margin: 0 auto;
- padding-top:20px;
- }
- body a {
- text-decoration:none;
- color:#0099CC;
- }
- .border{
- border:#999999;
- border-style:solid;
- border-width:thin;
- }
- </style>
- <?php
- include('connect.php');
- ?>
- <table width="350" class="border" >
- <form id="form1" name="form1" method="post" action="login.php" onSubmit="return validate()">
- <tr>
- <td width="112"> </td>
- <td colspan="2"> <strong>Login</strong></td>
- <td width="22"> </td>
- </tr>
- <tr>
- <td height="35">
- <div align="right">User Name : </div>
- </td>
- <td colspan="2"><label>
- <input type="text" name="name" id="name" /></label>
- </td>
- <td> </td>
- </tr>
- <tr>
- <td>
- <div align="right">Password : </div>
- </td>
- <td colspan="2"><input type="password" name="password" id="password" /></td>
- <td> </td>
- </tr>
- <tr>
- <td>
- <div align="right">select your role : </div>
- </td>
- <td colspan="2">
- <!-- <input type="radio" checked="checked" name="title" value="member" id="member" /> member</label>
- <label for="admin"> <input type="radio" name="title" value="admin" id="admin" /> admin</label> -->
- <label>
- <select name="member" id="member">
- <option title="title" value="member"> member
- <option title="title" value="admin"> admin
- </select>
- </label>
- </td>
- <td> </td>
- </tr>
- <tr>
- <td> </td>
- <td width="69"><label>
- <input type="submit" name="Submit" value="Login" id="add" /></label>
- </td>
- <td width="127"><label>
- <input type="reset" name="reset" value="reset" /></label>
- </td>
- <td> </td>
- </tr>
- <tr>
- <td> </td>
- <td><a href="register.php">Register ?</a> </td>
- <td><a href="forget_password.php">Forget Password?</a> </td>
- <td> </td>
- </tr>
- </form>
- </table>
- <script>
- function validate()
- {
- if( document.form1.name.value == "" )
- {
- alert( "Please provide your name!" );
- document.form1.name.focus() ;
- return false;
- }
- if( document.form1.password.value == "" )
- {
- alert( "Please provide your password!" );
- document.form1.password.focus() ;
- return false;
- }
- }
- </script>
- </body>
- </html>
- <?php
- session_start();
- include('connect.php');
- $name = $_POST['name'];
- $password = $_POST['password'];
- $role = $_POST['member'];
- $sql = "select * from login_register where name = '$name'
- and password = '$password' and role = '$role'";
- $retain = mysql_query($sql, $con);
- // Mysql_num_row is counting table row
- $count=mysql_num_rows($retain);
- $row=mysql_fetch_array($retain);
- if($count == 1)
- {
- if ( $role == "admin")
- {
- $_SESSION['adminuser']=$_POST['name'];
- header("location:admin_home.php");
- }
- else if ( $role == "member")
- {
- header("location:member_home.php");
- $_SESSION['user']=$_POST['name'];
- }
- }
- else
- {
- echo "<a href='index.php'>click here to login </a>";
- }
- ?>
- $.ajax({
- type : "POST",
- data : { username: "user name", password: "user password", role:"your role" },
- url : 'some.php',
- dataType: 'json',
- success : function(response) {
- console.log( "response data: " + response );
- }
- });
- <?php
- session_start();
- include('connect.php');
- if(isset($_POST['name']))
- {
- $sql = "select * from login_register where name = ".$_POST['name'];
- $retain = mysql_query($sql, $con);
- // Mysql_num_row is counting table row
- $count=mysql_num_rows($retain);
- if($count < 1)
- {
- echo "Wrong user name";
- }
- }
- ?>
Add Comment
Please, Sign In to add comment