Topic: Test availability of Username
How about a feature that would test the availability of a username on the fly?? Ajax style or something
You are not logged in.
How about a feature that would test the availability of a username on the fly?? Ajax style or something
I actually added that when I was using 2.2.1 but since I upgraded to 2.3.1 have not had a chance to add the feature. It was pretty easy to add. I got the script from hotscripts.com and tied it into one of my templates. Sorry, can't remember the script, but I"m sure a little searching on hotscripts and you can find it. I'm pretty sure it was an ajax script that used javascript as well.
Hi there - thanks so much, I'll look for it, remember, I'm not a php freak, little bit of knowledge. Eish
Thanks
I did have a look for "Username availability" and only found a ASP script, will this work on my site (VLD Personals) or not?
It's rather easy I suppose. Here's what you can do. Create a file 'includes/lib/lib.checkusername.php' and put this code in it:
check_username();
function check_username()
{
global $DB;
$username = isset($_POST['username']) ? $DB->add_slashes($_POST['username']) : '';
if ( $username ) {
$result = $DB->query("SELECT count(*) as totalrows FROM " . DB_PREFIX . "members WHERE username='$username' LIMIT 1");
$obj = $DB->fetch_object($result);
echo ( $obj->totalrows ) ? 'This username is already taken.' : 'This username is available!';
}
else {
echo 'Type in your username.';
}
exit;
}Now in your registration template (account_register.tpl) add this code right at the bottom (but above footer).
<script type="text/javascript">
function checkusername()
{
var username = $('#field_username').val();
$.post(virpath+'index.php?m=checkusername', {'username':username},
function(response) {
$('#response_username').html(response);
return true;
}
);
}
</script>Now insert this element where you would like to display username availability status:
<span id="response_username"></span>Enjoy ![]()
OI! Well, how about that?............ AWESOME, thanks Vlad
This thing is not working or am I stupid?
I created the file lib.checkusername.php and uploaded it to my server on includes/lib/
**** I added this between <!-- ENDIF --> and <!-- INCLUDE footer.tpl --> on account_register.tpl like this ****
</form>
<div class="clear"></div>
</div>
<!-- ENDIF -->
<script type="text/javascript">
function checkusername()
{
var username = $('#field_username').val();
$.post(virpath+'index.php?m=checkusername', {'username':username},
function(response) {
$('#response_username').html(response);
return true;
}
);
}
</script>
<!-- INCLUDE footer.tpl -->
**** and I added this <span id="response_username"></span> to account_register.tpl here ****
<dl class="fieldset fieldgrid">
<dt><label for="field_online_only">{lang:"register","username"}</label></dt>
<dd><input type="text" class="text" id="field_username" name="username" value="{registration_username}" maxlength="16" size="32" />
>>>>>>>>>> here >>>>>>> <span id="response_username"></span></dd>
<dt><label for="field_password">{lang:"register","password"}</label></dt>
<dd><input type="password" class="text" id="field_password" name="password" value="{registration_password}" size="20" maxlength="16" /></dd>
<dt><label for="field_password_confirm">
But nothing shows on Register page... ???? Am I dumb or blind?
Please help thanks
Your have a javascript in your header (for disabling right click) that causes an error. Either fix it up or remove it. I'd suggest removing it completely since it's pretty much useless and annoying
In short, it won't help you prevent people from copying your site's content.
Thank you, I'll try again.
: )))) oh my... I've just wrote the similar script
))))
anybody interested in my sharing? ![]()
Still not happening for me, NOT that I actually know what should be happening.
radioact - me me me
It's still not happening Vlad, same script, taken out the javascript in the header - nothing happens
Ok, AtPetat. I'm sure Vlad's fast to use code should work fine but you can also try my new mod.
Last edited by radioact (2008-03-26 14:29:25)
My problem with doing these quick add ons is that they dont work for future vld releases..... it would be nice to see this feature integrated in an official VLD release.
It looks like you've edited the wrong template. Your current registration file does not have any of the above code in it so obviously it won't work.
Hi there, I removed it because I implemented the other one from radioact. There is only one account_register.tpl, isnt there?