Jump to content

Function register() Problems


OmgPwnt

Recommended Posts

Hi,

 

I am trying to create a Register form, which submits data to a MySQL database and allows the user to log in. But the problem is, it also verifies the password so i need to have 4 variables going inside the register() (register($email, $uname, $password1, $password2)) But this does not work, however if i remove one of the variables it does...So i am guessing register() can only handle 3 parameters. Is there a way to change this?

 

Here is the function.

}
function register($uname, $email, $password1, $password2) 
{
global $db;

if (($uname == '') || ($email == '') || ($password1 == '') || ($password2 == '')) {
	registerpage("Please fill in all fields.");
} else if ($password1 != $password2) {
	$errtext = "Your password and verification password do not match.<br />";
	$errtext .= "Please try entering your password again.";
	registerpage($errtext);
}  else {

	$uname = htmlentities($uname);
	$db->query("SELECT user_id FROM rdorg_userdata WHERE user_name='" . $uname . "' LIMIT 1");
	if ($db->num_rows() == 1) {
		$errtext = "The username you had selected is already in use.<br />";
		$errtext .= "Please try a different username.";
		registerpage($errtext);
}  else {

	$email = htmlentities($email);
	$db->query("SELECT user_id FROM rdorg_userdata WHERE user_email='" . $email . "' LIMIT 1");
	if ($db->num_rows() == 1) {
		$errtext = "The E-Mail you had selected is already in use.<br />";
		$errtext .= "Please try a different E-Mail.";
		registerpage($errtext);
		return;
	}
}
	$username = $uname;
	$uemail = $email;

	if (!check_md5_format($password1)) {
		$errtext = "An error occured during the registration process.<br />";
		$errtext .= "Please make sure your browser supports JavaScript and has it enabled.";
		registerpage($errtext);
		return;
	}

	$salt = rand_str(12);
	$password = md5($password1 . $salt);

	$db->query("INSERT INTO rdorg_userdata (user_name, user_email, user_password, user_salt) VALUES ('" . $username . "','" . $uemail . "', '" . $password . "', '" . $salt . "')");

	$message = "Your account has been created successfully.<br />";
	$message .= 'You can now <a href="./index.php">login</a>. Use the Profile page to set up character data.';
	prnmessage($message);
}
}

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/118984-function-register-problems/
Share on other sites

I'm looking at it

function register($uname, $email, $password1, $password2)

it takes 4 parameters...

 

a proper call would be something like

 

register('john', '[email protected]', 'omgbatman123', 'omgbatman123');

 

or with variables...

 

register($username, $email, $pass1, $pass2);

 

ps. if your password is omgbatman123, I'm sorry for blowing your cover.. but really.. that's a terrible password

Archived

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