Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- session_start();
- if(isset($_POST['do_login']))
- {
- require_once '../inc/mysql_connect.php';
- $uname=$_POST['username'];
- $pass=$_POST['password'];
- $uname=strip_tags(mysqli_real_escape_string($con,trim($uname)));
- $pass=strip_tags(mysqli_real_escape_string($con, trim($pass)));
- $sql = "SELECT * from users where username='".$uname."'";
- $select_data=mysqli_query($con,$sql)or die(mysqli_error());
- if (mysqli_num_rows($select_data)>0) {
- $row = mysqli_fetch_array($select_data);
- $password_hash = $row['password'];
- $token = $row['token'];
- $email = $row['email'];
- $email_verified = $row['email_verified'];
- if (password_verify($pass,$password_hash)) {
- if ($email_verified > 0) {
- setcookie('token', $token, time()+31556926 , "/", "example.com", true, true);
- echo "success";
- }else {
- echo "email_not_verified";
- $_SESSION['email_not_verified'] = "true";
- $_SESSION['username'] = $uname;
- $_SESSION['email'] = $email;
- $_SESSION['token'] = $token;
- }
- }
- else{
- echo "fail";
- }
- exit();
- }}
- function do_login()
- {
- $("#btn-login").addClass('disabled');
- var username=$("#emailid").val();
- var pass=$("#password").val();
- if(username!="" && pass!="")
- {
- $.ajax
- ({
- type:'post',
- url:'https://example.com/core/auth/do_login.php',
- data:{
- do_login:"do_login",
- username:username,
- password:pass
- },
- success: function (response) {
- if (response =="success") {
- $('#login').modal('hide');
- window.location.href="https://example.com/account/";
- }else if (response=="email_not_verified") {
- window.location.href="https://example.com/login"
- }
- else{
- shakeModal();
- $("#btn-login").removeClass('disabled');
- }}
- });
- }
- return false;
- }
Add Comment
Please, Sign In to add comment