Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once $_SERVER['DOCUMENT_ROOT'].'/ecomerce/core/init.php';
- try{
- $conn = new PDO('mysql:host=localhost;dbname=tutorial','root','');
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }catch(PDOException $e){
- echo "Erro ao conectar ao banco da de dados";
- }
- include 'includes/head.php';
- $email = ((isset($_POST['email']))?sanitize($_POST['email']):'');
- $email = trim($email);
- $password = ((isset($_POST['password']))?sanitize($_POST['password']):'');
- $password = trim($password);
- $error = array();
- ?>
- <style type="text/css">
- body{
- background-image: url('/ecomerce/img/headerlogo/background.png');
- background-size:100vw 100vh;
- }
- </style>
- <div id="login-form">
- <div>
- <?php
- if($_POST){
- //form validation
- if(empty($_POST['email']) || empty($_POST['password'])){
- $error[] = 'You must provide email and password';
- }
- //check is email in the database
- $sqle = $conn->prepare("SELECT * FROM uses WHERE email ='$email'");
- $sqle->execute();
- $usercount = $sqle->rowCount();
- $user = $sqle->fetch(PDO::FETCH_ASSOC);
- var_dump($sqle);
- if(!empty($error)){
- echo display_errors($error);
- }
- }
- ?>
- </div>
- <h2 class="text-center">Login</h2>
- <form action="login.php" method="post">
- <div class="form-group">
- <label for="email">Email:</label>
- <input type="text" name="email" id="email" class="form-control" value="<?=$email; ?>">
- </div>
- <div class="form-group">
- <label for="password">Password:</label>
- <input type="password" name="password" id="password" class="form-control" value="<?=$password?>">
- </div>
- <div class="form-group">
- <input class="btn btn-primary" type="submit" value="Login" />
- </div>
- </form>
- <p class="text-right"><a href="/ecomerce/index.php" alt="home">Visit Site</a></p>
- </div>
- <?php include 'includes/footer.php'; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement