Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Re: [MJ_] Username availability checker

Quote Reply
Re: [MJ_] Username availability checker In reply to
Hi,

Something like this should do it (afraid I don't have any more free time to provide exact step by step instructions - so if you stuggle setting it up, lemme know - and I'll try and set it up for you at some point, but may have to charge)

Code:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>

<%-- add this into your <head></head> section in user_signup.html --%>
<script>
function checkUserAvail(thisuser) {
document.getElementById('inline_check_avail').src = '<%config.db_cgi_url%>/page.cgi?p=user_avail_check;user=' + thisuser;
}
</script>

</head>

<body>

<%-- be sure to add the name="" bit into the form action, otherwise it won't be accessing the right bit of the form =))
<form name="signup_form" action="<%config.db_cgi_url%>/user.cgi">

<%-- add the bit in bold to your signup_form.html template, in the Username field --%>
<input type="text" name="Username" size="20" onkeyup="checkUserAvail(this.value);">

<%-- this is the important bit, as it will change from red to green, depending on if the user is available --%>
<p>
<iframe name="inline_check_avail" name="inline_check_avail" src="<%config.db_cgi_url%>/page.cgi?p=user_avail_check" width="113" height="43" scrolling="no" border="0" frameborder="0">
Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe>
</p>

</form>



</body>

</html>

Then, make a new template called "user_avail_check.html" , with the following:


Code:
<%set isAvail = check_availability_username($user)%>
<html>
<%if isAvail%>
<body bgcolor="green">
<%else%>
<body bgcolor="red">
<%endif%>
</html>

Then, add a new global - called "check_availability_username", with the following code:
Code:
sub {
if (!$_[0]) { return 0; }

if ($DB->table('Users')->count( { Username => $_[0] } ) > 0) { return 0; } else { return 1; }

}

As I said, none of this is really tested (I quickly tested the HTML in Frontpage, but that doesn't guarantee it'll work =))

Hope that helps

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Dec 11, 2008, 10:11 AM
Subject Author Views Date
Thread Username availability checker MJ_ 7953 Dec 11, 2008, 7:02 AM
Thread Re: [MJ_] Username availability checker
Andy 7830 Dec 11, 2008, 7:13 AM
Thread Re: [Andy] Username availability checker
MJ_ 7818 Dec 11, 2008, 7:19 AM
Thread Re: [MJ_] Username availability checker
Andy 7820 Dec 11, 2008, 7:28 AM
Thread Re: [Andy] Username availability checker
MJ_ 7816 Dec 11, 2008, 7:34 AM
Thread Re: [MJ_] Username availability checker
Andy 7817 Dec 11, 2008, 7:49 AM
Thread Re: [Andy] Username availability checker
MJ_ 7812 Dec 11, 2008, 8:42 AM
Thread Re: [MJ_] Username availability checker
Andy 7804 Dec 11, 2008, 8:54 AM
Thread Re: [Andy] Username availability checker
MJ_ 7795 Dec 11, 2008, 9:42 AM
Thread Re: [MJ_] Username availability checker
Andy 7789 Dec 11, 2008, 9:46 AM
Post Re: [Andy] Username availability checker
MJ_ 7782 Dec 11, 2008, 10:09 AM