Jump to content


Photo

*SOLVED* $r = my_query("select hold from users where hold='y'");


  • Please log in to reply
3 replies to this topic

#1 StirCrazy

StirCrazy
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 22 April 2006 - 04:44 PM

Wonder if someone can help me:

I already have a login script fully working and have decided to add a banning function.

I want to add to the login code... something along these lines:

$r = my_query("select hold from users where hold='y'");

if user is hold='y' then Location: banned.php


Sorry, find it hard to explain ~ Can anyone help with the proper syntax?

Kind Regards,
S.C>


Table name: Users | Column: hold | enum ('y','n')

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 22 April 2006 - 05:03 PM

Do this:
$sql = "SELECT * FROM users";
$query = mysql_query($sql) or die("MySQL Error: " . $query . " : " . mysql_error());

$user = mysql_fetch_array($query);

if($user['hold'] == "Y")
{
    header("Location: banned.php");
}

//continue login process or what ever here as user is not banned.



#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 23 April 2006 - 08:59 AM

You need to check the "hold" value for a specific user using something like
.. WHERE userid = '$user'"

In the code above, if the first record in the table has a value of "y" then everyone gets sent to banned.php.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 StirCrazy

StirCrazy
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 30 April 2006 - 12:24 PM

sorry I didn't thank you before for your help -
had a play using the info above and managed to get it to work.

Thank you guys.

S.C>




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users