Advertisement
Guest User

Untitled

a guest
May 7th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. <?php
  2. require_once $_SERVER['DOCUMENT_ROOT'].'/ecomerce/core/init.php';
  3. try{
  4. $conn = new PDO('mysql:host=localhost;dbname=tutorial','root','');
  5. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  6. }catch(PDOException $e){
  7. echo "Erro ao conectar ao banco da de dados";
  8. }
  9. include 'includes/head.php';
  10. $email = ((isset($_POST['email']))?sanitize($_POST['email']):'');
  11. $email = trim($email);
  12. $password = ((isset($_POST['password']))?sanitize($_POST['password']):'');
  13. $password = trim($password);
  14. $error = array();
  15. ?>
  16. <style type="text/css">
  17. body{
  18. background-image: url('/ecomerce/img/headerlogo/background.png');
  19. background-size:100vw 100vh;
  20. }
  21. </style>
  22.  
  23. <div id="login-form">
  24. <div>
  25. <?php
  26. if($_POST){
  27. //form validation
  28. if(empty($_POST['email']) || empty($_POST['password'])){
  29. $error[] = 'You must provide email and password';
  30. }
  31.  
  32. //check is email in the database
  33.  
  34.  
  35. $sqle = $conn->prepare("SELECT * FROM uses WHERE email ='$email'");
  36. $sqle->execute();
  37. $usercount = $sqle->rowCount();
  38. $user = $sqle->fetch(PDO::FETCH_ASSOC);
  39. var_dump($sqle);
  40.  
  41.  
  42. if(!empty($error)){
  43. echo display_errors($error);
  44. }
  45. }
  46. ?>
  47. </div>
  48. <h2 class="text-center">Login</h2>
  49. <form action="login.php" method="post">
  50. <div class="form-group">
  51. <label for="email">Email:</label>
  52. <input type="text" name="email" id="email" class="form-control" value="<?=$email; ?>">
  53. </div>
  54.  
  55. <div class="form-group">
  56. <label for="password">Password:</label>
  57. <input type="password" name="password" id="password" class="form-control" value="<?=$password?>">
  58. </div>
  59.  
  60. <div class="form-group">
  61. <input class="btn btn-primary" type="submit" value="Login" />
  62. </div>
  63. </form>
  64. <p class="text-right"><a href="/ecomerce/index.php" alt="home">Visit Site</a></p>
  65. </div>
  66.  
  67.  
  68. <?php include 'includes/footer.php'; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement