Jump to content

[SOLVED] Trying to figure out how to do ....


SkyRanger

Recommended Posts

I am trying to figure out how to pull multiple info from a database to show a page or not.... for example:

 

if $row['userip] = $_SERVER['REMOTE_ADDR'] and $banned = 0 then show page
else if $row['userip] = $_SERVER['REMOTE_ADDR'] and $banned = 1 then don't show the page.

 

Any help would be appreciated.

Link to comment
Share on other sites

Ok, this is what I have so far:

 


mysql_connect("localhost", "dbuser", "dbpass") or die(mysql_error());
mysql_select_db("dbname") or die(mysql_error());


$result = mysql_query("SELECT * FROM table")
or die(mysql_error());
while($row = mysql_fetch_array( $result )) {

if($row['userip'] = $_SERVER['REMOTE_ADDR']) {
    if(!$ban) {
echo "show the webpage";
   }
  }
}
[code]

Tried banning my own IP but still showing page.

Link to comment
Share on other sites

where is the info if the user is banned or not?

if its in the database and u select it aswell (this example show's if there is a column in the table called 'ban')

try this

i am using a 0 for false and a 1 for true

while($row = mysql_fetch_array( $result )) {
if($row['userip'] = $_SERVER['REMOTE_ADDR']) {
	if($row['ban'] == 0) {                  //make sure the ROW array contains the key 'ban' with a value of 1 to ban the person (cause if its a 0 it will just show it)
		echo "show the webpage";
	}
}
}

 

 

i gave it a try without database and while loop but just make a array like this

$row = array('userip' => 'localhost','ban' => '1');

and it worked

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.