Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. $secret = '*****';
  2. $response = $_POST['g-recaptcha-response'];
  3. $remoteip = $_SERVER['REMOTE_ADDR'];
  4. $captcha = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secret&response=$response&remoteip=$remoteip");
  5. $result = json_decode($url, TRUE);
  6. $username;$password;$captcha;
  7. if(isset($_POST['username']))
  8. $username=$_POST['username'];
  9. if(isset($_POST['password']))
  10. $password=$_POST['password'];
  11. if(isset($_POST['g-recaptcha-response']))
  12. $captcha=$_POST['g-recaptcha-response'];
  13. if(!$captcha){
  14. echo '<p class="error-message">Please Complete The Captcha!</p>';
  15. header("location: login.php");
  16. exit;
  17. }
  18. $response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6LfG-S8UAAAAAIqW1sBE31yMPyO4zeqOCgDzL1mA&response=".$captcha."&remote=".$_SERVER['REMOTE_ADDR']), true);
  19. if($response['success'] == false) {
  20. echo '<p class="error-message">Please Fill Captcha!</p>';
  21. }
  22. else {
  23. echo '<p class="error-message2">Welcome</p>';
  24. }
  25. if (isset($_POST['submit'])) {
  26. $username = $_POST['username'];
  27. $password = $_POST['password'];
  28. $q = $handler->prepare('SELECT * FROM users WHERE username = ?');
  29. $q->execute(array($username));
  30. $result = $q -> fetch(PDO::FETCH_ASSOC);
  31. if ($result !== false) {
  32. $hash_pwd = $result['password'];
  33. $hash = password_verify($password, $hash_pwd);
  34.  
  35. if ($hash) {
  36. $_SESSION['username'] = $username;
  37. header("location:index.php");return;
  38. }
  39. else {
  40. echo '<p class="error-message3"><br><br>You have ented an incorrect login!<br>Please try again</p>';
  41. }
  42. }
  43. }
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement