File Manager
Editing: login.php
<?php require_once 'google-config.php'; $login_url = $client->createAuthUrl(); //ob_start(); //session_start(); $host = "127.0.0.1:3306"; $username = "u404542307_dacotywebsites"; $password = "daCotywebs1te5"; $database = "u404542307_eizon"; try { // Establish database connection $pdo = new PDO("mysql:host=$host;dbname=$database", $username, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die("Could not connect to the database: " . $e->getMessage()); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $identifier = $_POST['identifier']; // Accepts either email or username $password = $_POST['password']; // Use PDO to prepare and execute the query $query = "SELECT * FROM users WHERE username = :identifier OR email = :identifier"; $stmt = $pdo->prepare($query); $stmt->execute([':identifier' => $identifier]); $user = $stmt->fetch(PDO::FETCH_ASSOC); if ($user) { if (password_verify($password, $user['password'])) { // Debug: Log successful login error_log("Login successful for user: " . $user['username']); echo "Debug: Password verified.<br>"; $_SESSION['username'] = $user['username']; $_SESSION['email'] = $user['email']; $_SESSION['user_id'] = $user['id']; // Add this line if (headers_sent($file, $line)) { error_log("Headers already sent in $file on line $line."); exit("Cannot redirect. Headers already sent."); } // Redirect to dashboard header("Location: dashboard.php"); exit; } else { echo "<p style='color:red;'>Invalid password.</p>"; error_log("Invalid password for user: " . $identifier); } } else { echo "<p style='color:red;'>Invalid username/email or password.</p>"; error_log("Invalid username/email: " . $identifier); } } ?> <!DOCTYPE html> <html lang="en"> <head> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-Z6RR2PMZW4"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-Z6RR2PMZW4'); </script> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>eizon-login</title> <meta name="description" content="Access your Eizon account to manage your products, browse requests, and connect with buyers and sellers in your region. Login now."> <link rel="stylesheet" href="accounts.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"> <link rel="manifest" href="/manifest.json"> <style> .login{ background-color: #24e037; color: white; padding: 15px 20px; border: none; border-radius: 5px; font-size: 16px; width:99%; margin:auto; font-weight:900; margin-top:10px; position: relative; } .loginlink{ width: 50%; margin: auto; } @media (max-width: 768px) { .loginlink{ width: 99%; } } </style> </head> <body> <div class="google"> <form class="form" action="/login" method="POST"> <h1>e!zon</h1> <p>WELCOME TO EIZON</p> <?php if (!empty($error_message)): ?> <p style="color: red;"><?= htmlspecialchars($error_message) ?></p> <?php endif; ?> <input type="text" id="identifier" name="identifier" placeholder="username or email" required><br> <input type="password" name="password" placeholder="enter password" required><br> <button type="submit">LOGIN</button> <button style="color:green;"> <a href="register.php" style="color:green;text-decoration:none;">CREATE ACCOUNT</a></button> <p>Don't have an account? <a href="register.php">Sign up!</a></p> <div class="socials"> <a href="https://www.instagram.com/eizononline"> <i class="fa-brands fa-square-instagram"></i> </a> <a href="https://chat.whatsapp.com/BjYHA7zTwzN0EA0cdZJnzd"> <i class="fa-brands fa-square-whatsapp"></i> </a> <a href="https://www.facebook.com/eizononline/"> <i class="fa-brands fa-facebook"></i> </a> </div> <a href="/home">LOGIN LATER</a> </form> <div class="loginlink"> <a href="<?php echo htmlspecialchars($login_url); ?>"> <button class="login"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="20px" height="20px" style="vertical-align: middle; margin-right: 10px;"> <path fill="#EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"/> <path fill="#4285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"/> <path fill="#FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"/> <path fill="#34A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"/> <path fill="none" d="M0 0h48v48H0z"/> </svg> CONTINUE WITH GOOGLE </button> </a> </div> </div> </body> </html>
💾 Save
⬅ Back