Jump to content

Archived

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

StirCrazy

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

Recommended Posts

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'");

[b]if user is hold='y' then Location: banned.php[/b]


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

Kind Regards,
S.C>


[b]Table name: Users | Column: hold | enum ('y','n')[/b]

Share this post


Link to post
Share on other sites
Do this:
[code]$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.

[/code]

Share this post


Link to post
Share on other sites
You need to check the "hold" value for a specific user using something like
[code]
.. WHERE userid = '$user'"[/code]

In the code above, if the first record in the table has a value of "y" then everyone gets sent to banned.php.

Share this post


Link to post
Share on other sites
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>

Share this post


Link to post
Share on other sites

×

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.