Code:
<html>
<head>
<title>Add New MySQL User</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
if(isset($_POST['add']))
{
include 'c:\sokkit\config.php';
include 'c:\sokkit\opendb.php';
$ip=$_SERVER['REMOTE_ADDR'];
$username = $_POST['username'];
$password = $_POST['password'];
$country = $_POST['mydropdown'];
$query = "INSERT INTO account (username, password, location, forumip) VALUES ('$username', '$password', '$country', '$ip')";
mysql_query($query) or die('Error, insert query failed');
$query = "FLUSH PRIVILEGES";
mysql_query($query) or die('Error, insert query failed');
include 'c:\sokkit\closedb.php';
echo "New MySQL user added";
}
else
{
?>
<form method="post">
<div align="left">
<select name="mydropdown">
<option value="Zimbabwe">Zimbabwe</option>
</select>
</div>
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Username</td>
<td><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td width="100">Password</td>
<td><input name="password" type="text" id="password"></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td><input name="add" type="submit" id="add" value="Add New User"></td>
</tr>
</table>
</form>
<?
}
?>
</body>
</html>
kinda like this:
select * from `account` where forumip=$ip';
So basically when someone presses submit, if ip in database already to error rather then submitting the info.
Any help in this area is greatly appreciated.
Comment