The online racing simulator
Check is user exist
1
(27 posts, started )
Check is user exist
Hi all, I'm trying to validate the field "lfs_username" in my signup form to avoid errors.

Is it possible to verify if the username exist without reloading the page?

Consider that the form is in php and I'm really a noob.

thanks
#2 - Silox
You'll need a combination between JavaScript (Ajax) and another PHP script.
AJAX Call into LFS World for their PST state. It returns the least amount of data that is guaranteed to be there with every valid LFS Username.
Quote from Dygear :AJAX Call into LFS World for their PST state. It returns the least amount of data that is guaranteed to be there with every valid LFS Username.

I know it's possible, but I also know that going on Mars is possible... but not for me

Any help (means=php code to copy and paste)?

P.S. i know I'm asking for your time,


<?php 

 
if ($anybodycandoit == 'yes')
{
 echo 
"it would be really appreciated";
}
 
else if (
$anybodycandoit != 'yes')

echo 
"No problem mate!";
 }

?>

Quote from lysergic :I know it's possible, but I also know that going on Mars is possible... but not for me

Any help (means=php code to copy and paste)?

P.S. i know I'm asking for your time,


<?php 

 
if ($anybodycandoit == 'yes')
{
 echo 
"it would be really appreciated";
}
 
else if (
$anybodycandoit != 'yes')

echo 
"No problem mate!";
 }

?>


bump

Is really so hard to code? Or to share it...?
Alright, you waited pretty patiently, It's on my todo list, ok?
Quote from Dygear :Alright, you waited pretty patiently, It's on my todo list, ok?

Thanks
After some trying I think I got it. The PHP Script isn't that complex, it just requests the stats for a certain racer and either returns 'Valid username.' or 'Invalid username.'.
The more difficult problem for me was the ajax request (I'm an ajax noob) but google helped me with that :P

Just upload the three files ('prototype.js','racer_exists.js','racer_exists.php') and paste the parts from ajax.html into you script. Then it should work
Attached files
LFS Stats.zip - 30.9 KB - 169 views
Quote from Dygear :AJAX Call into LFS World for their PST state. It returns the least amount of data that is guaranteed to be there with every valid LFS Username.

I think this won't work as someone can have his online stats hidden.
Quote from Dominic123 :After some trying I think I got it. The PHP Script isn't that complex, it just requests the stats for a certain racer and either returns 'Valid username.' or 'Invalid username.'.
The more difficult problem for me was the ajax request (I'm an ajax noob) but google helped me with that :P

Just upload the three files ('prototype.js','racer_exists.js','racer_exists.php') and paste the parts from ajax.html into you script. Then it should work

Hi, I told You I'm a noob...

I doesn't work, neither in a new form in an empty page. No errors, no results....
Quote from Flame CZE :I think this won't work as someone can have his online stats hidden.

But the question was, if the user exists. It will still return a result when there is a user with that user name, or it will return 'pst: no valid username'.
But when I tried to hide my stats and then run that query, it returned the "no valid username" message, too.
Quote from Flame CZE :But when I tried to hide my stats and then run that query, it returned the "no valid username" message, too.

No kidding. Huh. Well, that's a predicament!
Ok. There is a back door into this, but it's above my head to program for in JavaScript.

You have to use the clientscript/vbulletin_ajax_namesugg.js from here to check the username.


<div>User Name:</div>
<div id="userfield">
<input type="text" class="bginput" name="searchuser" id="userfield_txt" size="35" value="" style="width:250px" />
</div>
<div id="userfield_menu" class="vbmenu_popup" style="display:none"></div>
<script type="text/javascript" src="clientscript/vbulletin_ajax_namesugg.js?v=384"></script>
<script type="text/javascript">
<!--
vbmenu_register('userfield', true);
snc = new vB_AJAX_NameSuggest('snc', 'userfield_txt', 'userfield');
//-->
</script>

You can use that, as it does not honor LFSWorlds settings, unless Vic did something to cross pollinate these items.
But I'm not sure if every username appears here after registration at lfs.net. One thing that would be quick is to ask Victor if he couldn't make a simple page, where you'll select the username (?u=username) and it will return e.g. 1 when successful and 0 when the username wouldn't exist.
Quote from Flame CZE :But I'm not sure if every username appears here after registration at lfs.net. One thing that would be quick is to ask Victor if he couldn't make a simple page, where you'll select the username (?u=username) and it will return e.g. 1 when successful and 0 when the username wouldn't exist.

Possibly.
Quote from lysergic :Hi, I told You I'm a noob...

I doesn't work, neither in a new form in an empty page. No errors, no results....

Did you upload it on a webserver with PHP?
Quote from Dominic123 :Did you upload it on a webserver with PHP?

ok, I'm noob... but not so much

Yes, the server is php5, apache2 etc etc
That's weird because for me it works fine. Sry then

Check this one
I've just hidden my stats and it say my username is invalid.
But sometimes it says invalid, sometimes valid.... i tried entering "Flame CZE" and "Flame%20CZE"
Don't know what this exactly is about but you know that LFSW data is tarpitted unless you pay for it?

10 second delay if I recall correctly. => Invalid, valid, invalid, valid?
Quote from cargame.nl :Don't know what this exactly is about but you know that LFSW data is tarpitted unless you pay for it?

10 second delay if I recall correctly. => Invalid, valid, invalid, valid?

5 seconds. Any solution that queries LFSW should be aware of the existence of this limitation on free accounts and handle it gracefully. Whether that's letting the user know why there's a delay, displaying a countdown timer until the 5 seconds expires or something else is up to the individual programmer. Obviously returning the incorrect answer (e.g. returning invalid for a license name because the query failed due to the tarpit) is not a proper solution.
Its just a guess... What LFSW returns is 'this page can't be refreshed so quickly' or something like that. It doesnt say invalid.

But I dont know if the programmer took care of that, it was a suggestion
Quote from cargame.nl :Its just a guess... What LFSW returns is 'this page can't be refreshed so quickly' or something like that. It doesnt say invalid.

But I dont know if the programmer took care of that, it was a suggestion

Last time I looked the message was "can't reload this page that quickly after another". My point was that anyone developing code that's going to run against LFSW should know about the limitation. The specifics of how he/she handles that are up to them, but you need to cope with the limitation if you're using the free service.
1

Check is user exist
(27 posts, started )
FGED GREDG RDFGDR GSFDG