1. is users which has rows username, and last_ip_address
2. is banned_ips with the row ID, and IP
I have a form that is labeled username and the idea is to put the name of the user that I want to ban into the form, submit it and then it takes the last ip address from that user and copies it into the banned ip row.
The code I have is
Code: Select all
<?
include "login_config.php"; // this is the file from your login script
$con = mysql_connect($db_host, $db_username, $db_password)
or die("Error! Could not connect to database: " . mysql_error());
mysql_select_db($db)
or die("Error! Could not select the database: " . mysql_error());
$safe_username = ($_POST['username']);
$result = mysql_query("SELECT last_ip_address FROM users WHERE
username = $safe_username");
$ip = mysql_result($result, 0, 0);
mysql_query("INSERT INTO banned_ips ('$ip')");
mysql_close($con);
?>