Jump to content

Recommended Posts

Understand what I mean?

 

This is not your personal chat line!!

 

If you want to learn, you need to start by doing something on your own instead of holding out your hands.  Spend time at www.tizag.com then come back and post some code you have created. Ask a relevant, coherent question and you'll probably get an answer.

 

This thread is getting very close to being locked.

I done this for you mate.....................

 

 

1. Copy the database info paste it into mysql.....

 

2. Save the curent page as ban_users.php

 

Each time a user goes on your web site there ip will go into the database

and the date they were added......

 

if they are in the database there get a error message.....

 

use a include("ip_ban.php"); function to add this script to your index.php page.......

good luck..............

 

 

I EXSPECT YOU TO READ ALL THE PHP SIMPLE FUNCTIONS I

HAVE USED AND THE MYSQL FUNCTIONS...............

 

<?php
# mysql info..... copy and past this in mysql console.........

/*

create database ban_ip;
use ban_ip;
create table ip_bad(id int not null auto_increment primary key,
users_ip int not null,
date_added int not null);

*/

// provided form redarrow // simple ip ban script.............

?>



<?php

//database connection......

$db=mysql_connect("localhost","username","password");
$res=mysql_createdb("database_name",$db);

// current users ip.......

$users_ip=$_SERVER['REMOTE_ADDR'];

// post users ip.......

$users_ip=mysql_real_esape_string($_POST['users_ip']);

//current date......

$date_added=time();

// post the date......

$date_added=mysql_real_esape_string*($_POST['date_added']);


// if a ip exists start a condition...
if($user_ip){

// select the database..............
// see if the ip already in it if so echo a message....

$sql1="SELECT * FROM `ip_ban` WHERE `users_ip`='$users_ip'";
$res1=mysql_query($sql1)or die(mysql_error());

if(mysql_num_row($res1)){

   echo "SORRY YOUR BAN FROM MY WEB SITE!";

EXIT;

}else{

	//if the ip is not in the database put it in........

	sql2="INSERT INTO ip_ban(id,users_ip,date_added)VALUES('$id','$users_ip','$date_added'";
	$res2=mysql_query($sql2)or die(mysql_error());

}
 }
?>

Guest
This topic is now 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.