Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $secret = '*****';
- $response = $_POST['g-recaptcha-response'];
- $remoteip = $_SERVER['REMOTE_ADDR'];
- $captcha = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secret&response=$response&remoteip=$remoteip");
- $result = json_decode($url, TRUE);
- $username;$password;$captcha;
- if(isset($_POST['username']))
- $username=$_POST['username'];
- if(isset($_POST['password']))
- $password=$_POST['password'];
- if(isset($_POST['g-recaptcha-response']))
- $captcha=$_POST['g-recaptcha-response'];
- if(!$captcha){
- echo '<p class="error-message">Please Complete The Captcha!</p>';
- header("location: login.php");
- exit;
- }
- $response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6LfG-S8UAAAAAIqW1sBE31yMPyO4zeqOCgDzL1mA&response=".$captcha."&remote=".$_SERVER['REMOTE_ADDR']), true);
- if($response['success'] == false) {
- echo '<p class="error-message">Please Fill Captcha!</p>';
- }
- else {
- echo '<p class="error-message2">Welcome</p>';
- }
- if (isset($_POST['submit'])) {
- $username = $_POST['username'];
- $password = $_POST['password'];
- $q = $handler->prepare('SELECT * FROM users WHERE username = ?');
- $q->execute(array($username));
- $result = $q -> fetch(PDO::FETCH_ASSOC);
- if ($result !== false) {
- $hash_pwd = $result['password'];
- $hash = password_verify($password, $hash_pwd);
- if ($hash) {
- $_SESSION['username'] = $username;
- header("location:index.php");return;
- }
- else {
- echo '<p class="error-message3"><br><br>You have ented an incorrect login!<br>Please try again</p>';
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement