Jump to content

Help with login.php plz


Davie33

Recommended Posts

Hi am in the middle of sorting this code but came across a problem that you may be able to help me with.

 

As you can see this part of the code stops anyone from logging in if not activated there account but this seems to be doing it for those who have activated there account too if you need full code let me know plz thanks.

 

    if ($row['activated'] == 0) {
        echo 'Your email is not yet active. Please check your email!';
	    exit();
	}

Link to comment
Share on other sites

I have tryed a few things but none working.

 

Here is my login code this may help abit more.

 

<?php
ob_start();
session_start();
include("includes/db_functions.inc.php");
include("includes/config.inc.php");
switch ($_GET['site']) {
case 'facebook':
	include ($setting['sitepath']."/includes/social/login-facebook.php");
	break;
case 'twitter':
	include ($setting['sitepath']."/includes/social/login-twitter.php");
	break;
default:
	$username = yasDB_clean($_POST["username"]);
	$password = md5($_POST["password"]);
	$rememberme = $_POST["remember"];
	$result = yasDB_select("select * from user where username='$username'",false);
	$rows = $result->fetch_array(MYSQLI_ASSOC);

	if (!$result || $result->num_rows == 0) {
		header("Location: index.php");
		echo '<script type="text/javascript">alert("Wrong password and username combination.");</script>';
		exit();
	}
	$result->close();
    if ($row['activated'] == 0) {
	yasDB_update("UPDATE * from user where username='$username'",true);
        echo 'Your email is not yet active. Please check your email!';
	    exit();
	}
	if($rows['endban'] > time()) {
		$banend = date("F j, Y g:i a", $rows['endban']);
		echo 'Sorry, this user is banned until '.$banend;
		exit();
	}
	if($rows['endban'] < time()) {
		yasDB_update("UPDATE user SET endban='0' WHERE username='$username'",false);
	}
	$loginok = '';
	if($rows["password"]==$password && $rows["username"] == $username) { 
		$loginok = TRUE;
	}
	else {
		$loginok = FALSE;
	}
	if ($loginok == TRUE){
		$ref = $_SERVER['HTTP_REFERER'];
		if ($rememberme == "remember"){
			setcookie("user", $username, time()+86400); // cookie lasts 24 hours
		}
		$_SESSION['user'] = $username;		 
		$_SESSION['userid'] = $rows['id'];
		$now = time(); 
		$query = yasDB_select("SELECT `id` FROM `membersonline` WHERE `memberid` = '{$rows['id']}'");
		if ($query->num_rows==0) {
			yasDB_insert("INSERT INTO `membersonline` (id, memberid, timeactive) VALUES ('', '{$rows['id']}', '$now')",false);
		}
		else {
			yasDB_update("UPDATE `membersonline` SET timeactive='$now' WHERE `memberid`='{$rows['id']}'");
		}
		header ("Location: ".$setting['siteurl']);
		$query->close();
		exit();
	}
	else  {
		echo '<script type="text/javascript" src="'.$setting['siteurl'].'includes/alert.js"></script>';
		header ("Location: index.php"); 
		exit();
	}		
	break;
}
ob_end_flush();
?>

Link to comment
Share on other sites

Hi every other part of the code works its just this file that doesn't which i know its missing something but dont know what.Without that activated code in login.php login works but.I need something in that file to stop the ones that have not activated there account

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.