Jump to content

Recommended Posts

If it will make any sense on it's own:

 

// We want to prevent quick signups
	$query = $db->query('SELECT joined
							FROM members
							WHERE ip_address = "'.$_SERVER['REMOTE_ADDR'].'"');


	// Have they JUST registered?  
	if ($db->num_rows($query) > 0) 
	{
		$t = $db->fetch_assoc($query);
		echo 'yes';

		echo time().'<br />';
		echo $t['joined'].'<br />';

		$last_signup = (time() - $t['joined']);
		echo $last_signup;
		if ($last_signup < 120) $core->error('Error', 'A registration has recently occurred');
	}

	// Trim and clean vars
	$fname = $core->cleanVar(trim($_POST['fname']));
	$lname = $core->cleanVar(trim($_POST['lname']));
	$password = $core->cleanVar(trim($_POST['password']));
	$email = $core->cleanVar(trim($_POST['email']));
	$sex = $_POST['sex'];
	$dob = $_POST['birth_day'].$_POST['birth_month'].$_POST['birth_year'];

	// Create salt and hash password
	$salt = $core->create_salt();
	$hash_pass = hash('sha256', $salt.$password);

	// Generate an activation code for the user
	$code = $core->keygen(20);

	// Add the user to the database
	$db->query('INSERT INTO members
				(first_name, last_name, password, salt, ip_address, email, joined, last_visit, sex, dob, group_id, status, code)
				VALUES
				("'.$fname.'", "'.$lname.'", "'.$hash_pass.'", "'.$salt.'", "'.$_SERVER['REMOTE_ADDR'].'", "'.$email.'", "'.time().'", "'.time().'", "'.$sex.'", "'.$dob.'", "1", "0", "'.$code.'");');

Why are you potentially grabbing multiple results? I told you before you should be checking based on dateline as well.

 

<?php
// We want to prevent quick signups
if ($db->query('
SELECT joined
FROM members
WHERE ip_address = "' . $_SERVER['REMOTE_ADDR'] . '"
	AND joined >= ' . (time() - 3600) . ' # Current time minus an hour. Can change this value to whatever you want.
LIMIT 1
')
{
$core->error('Error', 'A registration has recently occurred');
}
?>

 

Much cleaner code. More efficient as well.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.