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
https://forums.phpfreaks.com/topic/149765-solved-trying-to-figure-out-how-to-do/
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.

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

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.