Jump to content

Make suspended user unable to login?


djfox

Recommended Posts

  • Replies 71
  • Created
  • Last Reply

Yeah but the problem is, if someone who has the isHold value of 0 should be able to log in. But the code stops them and says the log in failed when I put in what you gave me (or I`m assuming i put it in correctly). But if I remove your code, the person can log in normally with no problem.

 

Edit:

I tested with a user who`s isHold = 1 and the same thing occurs, the messages says log in failed, it doesn`t permit the person to log on but it doesn`t say anything about being suspended.

Link to comment
Share on other sites

doesnt this mean I was right? About the $row[5] for isHold...

 

Three posts above this is where is said that i was wrong. Even if it still makes no sense to me, i said im used to mysql_fetch_array(). Anyway for being right u arent getting an Academy Award :) lol jk.

 

djfox normally they should login as the code blocks only isHold = 1. Dont know whats wrong now.

Link to comment
Share on other sites

Ah, it always seems like every problem I have, no one knows the answer to.  :P

 

Then if the log in thing doesn`t want to cooperate, my only other option at this point then is to put in on every page something like

isHold > 0

(hide stuff with a message about the suspension)

else isHold < 1

(show stuff)

 

I do a similar thing with membership levels. It`s just such a pain to have to go through each and every page with that method. I was hoping maybe I could just end it before they even log in.

 

Well, thanks for trying.

Link to comment
Share on other sites

lol phpSensei, u actually are right. Logically it should work.

 

djfox u got the answer. A lot of people here streched their heads for you so you should be a bit more thankful. What i would suggest is reading about handling mysql data in php and create your own code, so u can learn in the process.

Link to comment
Share on other sites

I made some progress. I added and s to the $rows[5] (before it was just $row[5] ). If the person`s isHold is 1 they get the suspension notice. Good, that wasn`t happening before.

 

But it still wants to not let the other people logged in. I`m going to look more into the code and see if there is something I`m missing.

Link to comment
Share on other sites

Yah, it`s not the best setup in the world (fixing that comes later). But if you go to another page after that log in, you`re not logged in. The form to log in re-appears. If the log in was successful the login failed message would not be there and you`d be logged in for real.

Link to comment
Share on other sites

try using the following modified code:

 

if ($res=mysql_query("SELECT id,level,mailNum, echo_count, status, isHold FROM userdata WHERE login='$username' AND password='$password'")){
	   $rows=mysql_fetch_row($res))
                           $numRows = mysql_num_rows($res);
                           if($numRows == 1){
                                  if($row[6] == '1'){
                                        die('Your account is suspended');
                                  } else{
                                      if ($rows=mysql_fetch_row($res)) {
		    $_SESSION['sess_name'] = $username;
			$_SESSION['pass'] = $password;
			$_SESSION['gal'] = $rows[0];
			$_SESSION['mail'] = $rows[2];
			$_SESSION['level2'] = $rows[1];	
			$_SESSION['echos'] = $rows[3];
			$_SESSION['status'] = $rows[4];
		    $_SESSION['magic'] = SESSION_MAGIC;
		    $_SESSION['rows'] = $rows; /* stupid stupid hack */
		    $nmsg = CountMessages($rows[0]);
		    $ok=true;
	   } else {
		   include('login_failed.php');
	   }
	   mysql_free_result($res);
	   }
   return($ok);
                                  }
                            }
	   
	   
  
}

 

This way ull know when a user has an account or not. Try it this way and tell if the suspended thing is working.

Link to comment
Share on other sites

else{

                                      if ($rows=mysql_fetch_row($res)) {

   $_SESSION['sess_name'] = $username;

$_SESSION['pass'] = $password;

$_SESSION['gal'] = $rows[0];

$_SESSION['mail'] = $rows[2];

$_SESSION['level2'] = $rows[1];

$_SESSION['echos'] = $rows[3];

$_SESSION['status'] = $rows[4];

   $_SESSION['magic'] = SESSION_MAGIC;

   $_SESSION['rows'] = $rows; /* stupid stupid hack */

   $nmsg = CountMessages($rows[0]);

   $ok=true;

  } else {

  include('login_failed.php');

 

 

You put TWO else's, which will do both the session and the include...

 

am i wrong?

 

Maybe add something liek Elseif($record =  $username...etc

 

EDIT: nvm, I didnt see the "if"

Link to comment
Share on other sites

Line 74

$rows=mysql_fetch_row($res))

 

I changed it to

 

$rows=(mysql_fetch_row($res))

 

Then got this:

Parse error: syntax error, unexpected T_VARIABLE in /home/secrett1/public_html/auth.php on line 75

 

Line 75 is this:

$numRows = mysql_num_rows($res);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • 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.