Guest User

Untitled

a guest
Sep 8th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <?php
  2. require_once('includes/config.php');
  3. if( $user->is_logged_in() ){ header('Location: index.php'); exit(); }
  4. if(isset($_POST['submit'])){
  5. if (!isset($_POST['username'])) $error[] = "No username.";
  6. if (!isset($_POST['password'])) $error[] = "Type pass.";
  7. if(!$captcha){
  8. echo 'Check ReCaptcha';
  9. exit;
  10. }
  11. $secretKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  12. $ip = $_SERVER['REMOTE_ADDR'];
  13. $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
  14. $responseKeys = json_decode($response,true);
  15. if(intval($responseKeys["success"]) !== 1) {
  16. echo 'Check ReCaptcha';
  17. exit;
  18. } else {
  19. $username = $_POST['username'];
  20. if ( $user->isValidUsername($username)){
  21. if (!isset($_POST['password'])){
  22. $error[] = 'Type pass';
  23. }
  24. $password = $_POST['password'];
  25.  
  26. if($user->login($username,$password)){
  27.  
  28. $_SESSION['username'] = $username;
  29. header('Location: memberpage.php');
  30. exit;
  31.  
  32. } else {
  33. $error[] = 'Wrong pass.';
  34. }
  35. }else{
  36. $error[] = 'Wrong pass.';
  37. }
  38. }
  39.  
  40. }
Add Comment
Please, Sign In to add comment