Advertisement
Guest User

Untitled

a guest
Aug 27th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. // all code html and functionality as follows
  2.  
  3. <?php
  4.  
  5. session_start();
  6. include("connection.php");
  7.  
  8.  
  9. $username=$_POST['email'];
  10. $password=$_POST['password'];
  11. $deleted='N';
  12.  
  13. $sql1=mysql_query("select * from tbl_login where is_deleted='N'");
  14.  
  15.  
  16. while($result=mysql_fetch_array($sql1))
  17. {
  18. $email=$result['username'];
  19. $pass=$result['password'];
  20.  
  21.  
  22. if($username==$email && $password==$pass)
  23. {
  24. // set session name as
  25. $_SESSION['username']=$username;
  26.  
  27. echo "<script>
  28. alert('your login has been successfully');
  29. window.location.href='register.php';
  30. </script>";
  31. }else
  32. {
  33.  
  34. echo "<script>
  35. alert('login fail please try login again');
  36. //window.location.href='login.php';
  37. </script>";
  38. }
  39.  
  40.  
  41. }
  42.  
  43. ?>
  44.  
  45. <html>
  46. <head>
  47. <title> Login Demo </title>
  48. <style> .login_form{margin:50px 150px; padding:20px; border:1px solid black;}
  49. .btn{padding:8px 15px;}
  50. </style>
  51. </head>
  52. <body>
  53. <form name="login_form" class="login_form" method="POST" action="login.php" />
  54.  
  55. <h2> Login Demo using core php </h2><br>
  56.  
  57.  
  58. <p><input type="email" name="email" placeholder="enter username" /></p>
  59. <p><input type="password" name="password" placeholder="enter password min 4 digit" /></p>
  60. <p> <button type="submit" name="submit">Submit</button>
  61.  
  62. </form>
  63.  
  64. </body>
  65. </html>
  66.  
  67. // set session at the login check and check it on after login page as follows
  68. // after login i want to load register page so
  69.  
  70. <?php
  71.  
  72. include('connection.php');
  73. session_start();
  74. echo "session_id=".$session_id=$_SESSION[ 'username'];
  75. if($session_id==null)
  76. { header( "Location:login.php"); }
  77. else
  78. { ?>
  79. <!--- else section for load any view after login successfully----->
  80. // this section for register page body
  81.  
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement