Advertisement
Guest User

Untitled

a guest
Mar 11th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. ===index.php===
  2. <?php include 'core/init.php'; ?>
  3. <?php include 'includes/header.php'; ?>
  4.  
  5. <h1>Home</h1>
  6. <p>Just a template.</p>
  7.  
  8. <?php include 'includes/aside.php'; ?>
  9. <?php include 'includes/footer.php'; ?>
  10.  
  11.  
  12. ===includes/aside.php===
  13. <aside>
  14. <?php include 'includes/widgets/login.php'; ?>
  15. </aside>
  16.  
  17. ===includes/widgets/login.php===
  18. <div class="widget">
  19. <h2>Login/Register</h2>
  20. <div class="inner">
  21. <form action="login.php" method="post">
  22. <ul id="login">
  23. <li>Username:<br><input type="text" name="username"></li>
  24. <li>Password:<br><input type="password" name="password"></li>
  25. <li><input type="submit" value="Log in"></li>
  26. <li><a href="register.php">Register</a></li>
  27. </ul>
  28. </form>
  29. </div>
  30. </div>
  31.  
  32. ===login.php===
  33. <?php
  34. include 'core/init.php';
  35.  
  36. if (user_exists('leroy') === true) {
  37. echo 'exists';
  38. }
  39. die();
  40.  
  41. if (empty($_POST) === false) {
  42. $username = $_POST['username'];
  43. $password = $_POST['password'];
  44.  
  45. if (empty($username) === true || empty($password) === true) {
  46. $errors[] = 'You need to enter a username and password';
  47. } else if (user_exists($username) === false) {
  48. $errors[] = 'We can\'t find that username. Have you registered?';
  49. }
  50. }
  51.  
  52.  
  53. ?>
  54.  
  55. ===core/functions/general.php===
  56. <?php
  57. function sanitize($data) {
  58. return mysql_real_escape_string($data);
  59. }
  60. ?>
  61.  
  62. ===core/functions/users.php===
  63. <?php
  64. function user_exists($username) {
  65. $username = sanitize($username);
  66. return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username'"), 0) == 1) ? true : false;
  67. }
  68. ?>
  69.  
  70. ===core/init.php===
  71. <?php
  72. session_start();
  73. error_reporting(0);
  74.  
  75. require 'database/connect.php';
  76. require 'functions/general.php';
  77. require 'functions/users.php';
  78.  
  79. $errors = array();
  80. ?>
  81.  
  82. ===core/database/connect.php===
  83. <?php
  84. $connect_error = 'Sorry, we\'re experiencing connection issues.';
  85. mysql_connect('localhost', 'adultaus_a', 'pass123');
  86. mysql_select_db('adultaus_up') or die($connect_error);
  87. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement