Advertisement
Guest User

login.php

a guest
Nov 27th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $arrayerror='';
  4. if (isset($_POST['submit'])) {
  5. if (empty($_POST['username']) || empty($_POST['password'])) {
  6. $arrayerror = "your username or password is empty";
  7. }
  8. else
  9. {
  10. $username=$_POST['username'];
  11. $password=$_POST['password'];
  12. include("configs/connect.php");
  13.  
  14. $query = mysql_query("select * from st_users where user_password='$password' AND user_name ='$username'");
  15. $rows = mysql_num_rows($query);
  16. if ($rows == 1) {
  17. $_SESSION['login_user']=$username;
  18.  
  19. header("location: profile.php");
  20. } else {
  21. $arrayerror = "your username or password is invalid ";
  22. }
  23. mysql_close($connection);
  24. }
  25. }
  26. ?>
  27. <?php
  28.  
  29. if(isset($_SESSION['login_user'])){
  30. header("location: profile.php");
  31. }
  32. ?>
  33. <!DOCTYPE html>
  34. <html>
  35. <head>
  36. <link href="style.css" rel="stylesheet" type="text/css">
  37. </head>
  38. <body>
  39. <div id="main">
  40. <h1>WELCOM</h1>
  41. <div id="login">
  42. <form action="" method="post">
  43. <label>UserName :</label></br>
  44. <input id="name" name="username" type="text"></br>
  45. <label>Password :</label></br>
  46. <input id="password" name="password" type="password"></br>
  47. <input name="submit" type="submit" value=" Login ">
  48. <span><?php echo $arrayerror; ?></span>
  49. </form>
  50. </div>
  51. </div>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement