Jump to content

easy function help


mikefrederick

Recommended Posts

Well don't do that, just notify the user that the login name is already in use. On your registration page, use this code

<?php
if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) {
	echo '<ul class="err"><strong><font size=5>';
	foreach($_SESSION['ERRMSG_ARR'] as $msg) {
		echo '<li>',$msg,'</li>'; 
	}
	echo '</ul></strong</font>';
	unset($_SESSION['ERRMSG_ARR']);
}
?>

then make a register-exec.php and use this



$qry = "SELECT count(*) AS c FROM members WHERE login='$login'";
$result = mysql_query($qry);
if($result) {
	$result_array = mysql_fetch_assoc($result);
	if($result_array['c'] > 0) {
		$errmsg_arr[] = 'Login ID already in use';
		$errflag = true;
	}
	@mysql_free_result($result);
}
else {
	die("Query failed");
}

 

And obviously modify the select queries as needed.

 

This last piece of code checks to make sure that none of the required fields are missing, add more if u need.

             if($login == '') {
	$errmsg_arr[] = 'Login ID missing';
	$errflag = true;
}
if($password == '') {
	$errmsg_arr[] = 'Password missing';
	$errflag = true;
}

Link to comment
https://forums.phpfreaks.com/topic/113580-easy-function-help/#findComment-583589
Share on other sites

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.