Guest User

Untitled

a guest
Oct 25th, 2017
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. REGISTER
  2. <!doctype html>
  3. <html>
  4. <head>
  5. <title>Register</title>
  6. <style>
  7. body{
  8. margin-top: 100px;
  9. margin-bottom: 100px;
  10. margin-right: 750px;
  11. margin-left: 300px;
  12. background-image: url("ebook.jpg");
  13. font-family: verdana;
  14. color:White;
  15.  
  16. }
  17. h1 {
  18. color: cyan;
  19. font-family: verdana;
  20. font-size: 100%;
  21. }
  22. h2 {
  23. color: cyan;
  24. font-family: verdana;
  25. font-size: 100%;
  26. h3{
  27. font-size : 50px;
  28. color:LightGray;
  29. }
  30. }</style>
  31. </head>
  32. <body> <h3 style="color:White;font-size:30px">EBOOKS</h3>
  33.  
  34. <center><h1>RegistrationProcess</h1></center>
  35. <p><a href="register.php">Register</a> | <a href="login.php">Login</a></p>
  36. <form action="" method="POST">
  37. <legend>
  38. <fieldset>
  39.  
  40. Username:<br> <input type="text" name="user"><br />
  41. Password:<br> <input type="password" name="pass"><br /> <br><br>
  42. <input type="submit" value="Register" name="submit" />
  43.  
  44. </fieldset>
  45. </legend>
  46. </form>
  47. <?php
  48. if(isset($_POST["submit"])){
  49. if(!empty($_POST['user']) && !empty($_POST['pass'])) {
  50. $user=$_POST['user'];
  51. $pass=$_POST['pass'];
  52. $con=mysqli_connect('localhost','root','ram@12111997','user_registration') or die(mysql_error()); $query=mysqli_query($con,"SELECT * FROM login WHERE username='".$user."'");
  53. $numrows=mysqli_num_rows($query);
  54. if($numrows==0)
  55. {
  56. $sql="INSERT INTO login(username,password) VALUES('$user','$pass')";
  57.  
  58. $result=mysqli_query($con,$sql);
  59. if($result){
  60. echo "Account Successfully Created Please Login to continue";
  61. } else {
  62. echo "Failure!";
  63. }
  64.  
  65. } else {
  66. echo "That username already exists! Please try again with another.";
  67. }
  68.  
  69. } else {
  70. echo "All fields are required!";
  71. }
  72. }
  73. ?>
  74. </body>
  75. </html>
  76. /
  77. /
  78. /
  79. LOGIN
  80. <!doctype html>
  81. <html>
  82. <head>
  83. <title>Login</title>
  84. <style>
  85. body{
  86.  
  87. margin-top: 100px;
  88. margin-bottom: 100px;
  89. margin-right: 150px;
  90. margin-left: 900px;
  91. background-image: url("ebook1.jpg");
  92. color: palevioletred;
  93. font-family: verdana;
  94. font-size: 100%
  95.  
  96. }
  97. h1 {
  98. color: Black;
  99. font-family: verdana;
  100. font-size: 100%;
  101. }
  102. h3 {
  103. color: cyan;
  104. font-family: verdana;
  105. font-size: 100%;
  106. } </style>
  107. </head>
  108. <body> <h3 style="color:Black;font-size:30px">EBOOKS</h3>
  109. <h1>Login Process</h1>
  110. <p><a href="register.php">Register</a> | <a href="login.php">Login</a></p>
  111. <form action="" method="POST">
  112. Username:<br> <input type="text" name="user"><br />
  113. Password:<br> <input type="password" name="pass"><br /> <br><br>
  114. <input type="submit" value="Login" name="submit" />
  115. </form>
  116. <?php
  117. if(isset($_POST["submit"])){
  118.  
  119. if(!empty($_POST['user']) && !empty($_POST['pass'])) {
  120. $user=$_POST['user'];
  121. $pass=$_POST['pass'];
  122.  
  123. $con=mysqli_connect('localhost','root','ram@12111997','user_registration') or die(mysql_error());
  124.  
  125. $query=mysqli_query($con,"SELECT * FROM login WHERE username='".$user."' AND password='".$pass."'");
  126. $numrows=mysqli_num_rows($query);
  127. if($numrows!=0)
  128. {
  129. while($row=mysqli_fetch_assoc($query))
  130. {
  131. $dbusername=$row['username'];
  132. $dbpassword=$row['password'];
  133. }
  134.  
  135. if($user == $dbusername && $pass == $dbpassword)
  136. {
  137. session_start();
  138. $_SESSION['sess_user']=$user;
  139.  
  140. /* Redirect browser */
  141. header("Location: member.php");
  142. }
  143. } else {
  144. echo "Invalid username or password!";
  145. }
  146.  
  147. } else {
  148. echo "All fields are required!";
  149. }
  150. }
  151. ?>
  152. </body>
  153. </html>
  154. //
  155. /
  156. /
  157. mEMBER
  158. <?php
  159. session_start();
  160. if(!isset($_SESSION["sess_user"])){
  161. header("location:login.php");
  162. } else {
  163. ?>
  164. <!doctype html>
  165. <html>
  166. <head>
  167. <title>Welcome</title>
  168. <style>
  169. body{
  170.  
  171. margin-top: 100px;
  172. margin-bottom: 100px;
  173. margin-right: 150px;
  174. margin-left: 80px;
  175. background-color: azure ;
  176. color: palevioletred;
  177. font-family: verdana;
  178. font-size: 100%
  179.  
  180. }
  181. h2 {
  182. color: indigo;
  183. font-family: verdana;
  184. font-size: 100%;
  185. }
  186. h1 {
  187. color: indigo;
  188. font-family: verdana;
  189. font-size: 100%;
  190. }
  191.  
  192.  
  193. </style>
  194. </head>
  195. <body>
  196. <h2>Welcome, <?=$_SESSION['sess_user'];?>! <a href="logout.php">Logout</a></h2>
  197. </body>
  198. </html>
  199. <?php
  200. }
  201. ?> /
  202. /
  203. /
  204. LOGOUT
  205. <?php
  206. session_start();
  207. unset($_SESSION['sess_user']);
  208. session_destroy();
  209. header("location:login.php");
  210. ?>
Add Comment
Please, Sign In to add comment