How do I create a code in PHP and MySQL to prevent people from creating duplicate accounts by recording their IPs in the database?
So far I've found this piece of PHP code but not sure what to do for the database:
Any help is greatly appreciated.PHP Code:<?php
// * Check for duplicates.
$request = "SELECT * FROM jamroom_check_dup_ip";
$db_result = mysql_query($request);
$ipaddress = mysql_fetch_object($db_result);
$num_rows = mysql_num_rows($db_result);
$row_count = 0;
while ($row_count < $num_rows) { // While I haven't checked all the rows.
$ipaddress = mysql_fetch_object($db_result); // Put each object into $ipaddress.
$row_count++; // * And add one to row count.
if ($ipaddress->session == $session) { // If session equates to session...
if ($ipaddress->username == $username) {
if ($ipaddress->password == $password) {
if ($ipaddress->day == $day) {
if ($ipaddress->securityquestion == $securityquestion) {
if ($ipaddress->securityanswer == $securityanswer) {
displayError("Duplicate accounts are not allowed.");
exit();
}
}
}
}
}
?>
Thanks in advance.



Reply With Quote

Bookmarks