Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // all code html and functionality as follows
- <?php
- session_start();
- include("connection.php");
- $username=$_POST['email'];
- $password=$_POST['password'];
- $deleted='N';
- $sql1=mysql_query("select * from tbl_login where is_deleted='N'");
- while($result=mysql_fetch_array($sql1))
- {
- $email=$result['username'];
- $pass=$result['password'];
- if($username==$email && $password==$pass)
- {
- // set session name as
- $_SESSION['username']=$username;
- echo "<script>
- alert('your login has been successfully');
- window.location.href='register.php';
- </script>";
- }else
- {
- echo "<script>
- alert('login fail please try login again');
- //window.location.href='login.php';
- </script>";
- }
- }
- ?>
- <html>
- <head>
- <title> Login Demo </title>
- <style> .login_form{margin:50px 150px; padding:20px; border:1px solid black;}
- .btn{padding:8px 15px;}
- </style>
- </head>
- <body>
- <form name="login_form" class="login_form" method="POST" action="login.php" />
- <h2> Login Demo using core php </h2><br>
- <p><input type="email" name="email" placeholder="enter username" /></p>
- <p><input type="password" name="password" placeholder="enter password min 4 digit" /></p>
- <p> <button type="submit" name="submit">Submit</button>
- </form>
- </body>
- </html>
- // set session at the login check and check it on after login page as follows
- // after login i want to load register page so
- <?php
- include('connection.php');
- session_start();
- echo "session_id=".$session_id=$_SESSION[ 'username'];
- if($session_id==null)
- { header( "Location:login.php"); }
- else
- { ?>
- <!--- else section for load any view after login successfully----->
- // this section for register page body
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement