1

Topic: Test availability of Username

How about a feature that would test the availability of a username on the fly?? Ajax style or something

2

Re: Test availability of Username

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.

3

Re: Test availability of Username

Hi there - thanks so much, I'll look for it, remember, I'm not a php freak, little bit of knowledge. Eish

Thanks

4

Re: Test availability of Username

I did have a look for "Username availability" and only found a ASP script, will this work on my site (VLD Personals) or not?

5

Re: Test availability of Username

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 big_smile

Developer

6

Re: Test availability of Username

OI! Well, how about that?............ AWESOME, thanks Vlad

7

Re: Test availability of Username

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 >>>>>>> &nbsp;<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

8

Re: Test availability of Username

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 big_smile In short, it won't help you prevent people from copying your site's content.

Developer

9

Re: Test availability of Username

Thank you, I'll try again.

10

Re: Test availability of Username

: )))) oh my... I've just wrote the similar script smile))))
anybody interested in my sharing? smile

www.vldMagic.com - first choice customizations help desk
www.vldCrowd.com/radioact - my profile at vldCrowd

11

Re: Test availability of Username

Still not happening for me, NOT that I actually know what should be happening.

12

Re: Test availability of Username

radioact - me me me

13

Re: Test availability of Username

It's still not happening Vlad, same script, taken out the javascript in the header - nothing happens

14

Re: Test availability of Username

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)

www.vldMagic.com - first choice customizations help desk
www.vldCrowd.com/radioact - my profile at vldCrowd

15

Re: Test availability of Username

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.

16

Re: Test availability of Username

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.

Developer

17

Re: Test availability of Username

Hi there, I removed it because I implemented the other one from radioact. There is only one account_register.tpl, isnt there?

18

Re: Test availability of Username

Will be available since v2.4

Developer