Files
4WDCSA.co.za/login.php

123 lines
5.7 KiB
PHP

<?php include_once('header02.php');
// Include Google login PHP logic
require_once 'google-client/vendor/autoload.php';
$client = new Google_Client();
$client->setClientId('948441222188-8qhboq2urr8o9n35mc70s5h2nhd52v0m.apps.googleusercontent.com');
$client->setClientSecret('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');
$client->setRedirectUri($_ENV['HOST'] . '/validate_login.php');
$client->addScope("email");
$client->addScope("profile");
// 👇 Add this to force the account picker
$client->setPrompt('select_account');
$login_url = $client->createAuthUrl();
?>
<style>
@media (min-width: 991px) {
.container {
max-width: 720px;
padding: 0 15px; /* Ensure padding doesn't cause overflow */
}
}
</style>
<!-- Contact Form Area start -->
<section class="contact-form-area py-120 rel z-1">
<div class="container">
<div class="row align-items-center">
<!-- <div class="col-lg-6">
<div style="text-align: center;">
<img style="width:400px;" src="assets/images/logos/weblogo.png" alt="About">
</div>
</div> -->
<div class="">
<div class="comment-form bgc-lighter z-1 rel mb-30 rmb-55">
<form id="loginForm" class="loginForm" name="loginForm" action="assets/php/form-process.php" method="post" data-aos="fade-left" data-aos-duration="1500" data-aos-offset="50">
<input type="hidden" name="csrf_token" value="<?php echo \Middleware\CsrfMiddleware::getToken(); ?>">
<div class="section-title">
<h2>Log in</h2>
<div style="text-align: center;" id="responseMessage"></div> <!-- Message display area -->
</div>
<!-- Google login button -->
<div class="row mt-35">
<div class="col-md-12">
<div class="form-group">
<a href="<?php echo $login_url; ?>" style="width:100%;" class="theme-btn style-three">
<img src="/assets/images/google.png" alt="Google Icon" style="width:20px; height:20px; margin-right: 10px; vertical-align: middle;">
Login with Google
</a>
</div>
</div>
</div>
<div style="text-align: center; margin: 20px 0;">
<!-- <hr style="border: 1px solid #ddd; width: 50%; margin: 0 auto;"> -->
<span style="top: -10px; padding: 0 10px;">or</span>
</div>
<!-- Email login fields -->
<div class="row mt-35">
<div class="col-md-12">
<div class="form-group">
<label for="email">Email Address</label>
<input type="email" id="email" name="email" class="form-control" placeholder="Enter Email" value="" required data-error="Please enter a valid Email address">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-12"></div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" class="form-control" placeholder="Enter Password" value="" required data-error="Please enter your password">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-12">
<div class="form-group mb-0">
<button type="submit" class="theme-btn style-two" style="width:100%;">Log In</button>
</div>
</div>
<div class="pt-20" style="text-align: center;">Don't have an account? <a href="register.php"><b>Register here.</b> </a>| <a href="forgot_password.php"><b>Forgot your password?</b></a></div>
</form>
</div>
</div>
</div>
</div>
</section>
<!-- Contact Form Area end -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('#loginForm').on('submit', function(event) {
event.preventDefault(); // Prevent the default form submission
$.ajax({
url: 'validate_login.php',
type: 'POST',
data: $(this).serialize(),
dataType: 'json',
success: function(response) {
if (response.status === 'success') {
window.location.href = 'index.php';
} else {
$('#responseMessage').html('<div class="alert alert-danger">' + response.message + '</div>');
}
},
error: function() {
$('#responseMessage').html('<div class="alert alert-danger">An error occurred while processing your request.</div>');
}
});
});
});
</script>
<?php include_once("insta_footer.php"); ?>