Advertisement
Guest User

Untitled

a guest
Jul 14th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['login-form'])) {
  3.  
  4. // Your Code Here
  5.  
  6. }
  7. ?>
  8.  
  9. <html>
  10. <body>
  11.  
  12. <form action=<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?> method="post" enctype="multipart/form-data" >
  13. Name: <input type="text" name="name"><br>
  14. E-mail: <input type="text" name="email"><br>
  15. <button type="submit" name="login-form"> Submit </button>
  16. </form>
  17.  
  18. <?php
  19. include('base.php');
  20. session_start(); // Starting Session
  21. $error=''; // Variable To Store Error Message
  22. if (isset($_POST['submit'])) {
  23. if (empty($_POST['username']) || empty($_POST['password'])) {
  24. $error = "Username or Password is invalid";
  25. }
  26. else
  27. {
  28. // Define $username and $password
  29. $username=$_POST['username'];
  30. $password=$_POST['password'];
  31.  
  32. $username = stripslashes($username);
  33. $password = stripslashes($password);
  34. $username = mysql_real_escape_string($username);
  35. $password = mysql_real_escape_string($password);
  36. // Selecting Database
  37. $db = mysql_select_db("company", $connection); //$connection -> Connection of the database from base.php
  38.  
  39. // Assuming you have table LOGIN or Change the table name with your along with the database columns
  40. // SQL query to fetch information of registerd users and finds user match.
  41. $query = mysql_query("select * from login where password='$password' AND username='$username'", $connection);
  42. $rows = mysql_num_rows($query);
  43. if ($rows == 1) {
  44. // Session to check whether the user is logged in or not in another pages
  45. $_SESSION['login_user'] = $username; // Initializing Session
  46. header("location: PageYouWantAfterLogin.php"); // Redirecting To Other Page
  47. } else {
  48. $error = "Username or Password is invalid";
  49. }
  50. mysql_close($connection); // Closing Connection
  51. }
  52. }
  53. ?>
  54.  
  55. <input type="text" name="username" class="user" value="Tu Correo Electrónico" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Tu Correo Electrónico';}"/>
  56.  
  57. <input type="password" name="password" class="lock" value="password" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email address:';}"/>
  58.  
  59. <input name="submit" type="submit" value=" Login ">
  60.  
  61. <form action="" method="post">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement