Advertisement
Guest User

login.php

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