<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:series="http://unfoldingneurons.com/"
		>
<channel>
	<title>Comments on: Check username availability and validation using ajax,php</title>
	<atom:link href="http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/</link>
	<description>Technology tips for all</description>
	<lastBuildDate>Thu, 29 Jul 2010 06:37:51 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Brent</title>
		<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/#comment-30667</link>
		<dc:creator>Brent</dc:creator>
		<pubDate>Fri, 23 Jul 2010 20:31:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.digimantra.com/?p=2344#comment-30667</guid>
		<description>Cheers guys for the replies!

It turns out James it was that the file that &#039;action&#039; was pointing to, it used a session &#039;lastUrl&#039; which in some instances was &#039;checkUsername.php&#039;! When the form failed any field validation it redirected to this - hence the blank screen.

Nice one, thanks, great script Sachin!</description>
		<content:encoded><![CDATA[<p>Cheers guys for the replies!</p>
<p>It turns out James it was that the file that &#8216;action&#8217; was pointing to, it used a session &#8216;lastUrl&#8217; which in some instances was &#8216;checkUsername.php&#8217;! When the form failed any field validation it redirected to this &#8211; hence the blank screen.</p>
<p>Nice one, thanks, great script Sachin!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sachin Khosla</title>
		<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/#comment-30641</link>
		<dc:creator>Sachin Khosla</dc:creator>
		<pubDate>Fri, 23 Jul 2010 17:23:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.digimantra.com/?p=2344#comment-30641</guid>
		<description>just put onclick = &quot;return false;&quot; in case of submit buttons. It will stop the page to shift to the next action page.</description>
		<content:encoded><![CDATA[<p>just put onclick = &#8220;return false;&#8221; in case of submit buttons. It will stop the page to shift to the next action page.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sachin Khosla</title>
		<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/#comment-30639</link>
		<dc:creator>Sachin Khosla</dc:creator>
		<pubDate>Fri, 23 Jul 2010 17:20:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.digimantra.com/?p=2344#comment-30639</guid>
		<description>you can use a JS callback method instead, which takes JSON output as an argument.</description>
		<content:encoded><![CDATA[<p>you can use a JS callback method instead, which takes JSON output as an argument.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Eofys</title>
		<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/#comment-30619</link>
		<dc:creator>James Eofys</dc:creator>
		<pubDate>Fri, 23 Jul 2010 14:42:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.digimantra.com/?p=2344#comment-30619</guid>
		<description>My HTML got stripped out. I&#039;ll try posting again... sounds like you have something like:
&lt;form action=&quot;validate.php&quot;&gt; but validate.php is just for the ajax.</description>
		<content:encoded><![CDATA[<p>My HTML got stripped out. I&#8217;ll try posting again&#8230; sounds like you have something like:<br />
&lt;form action=&#8221;validate.php&#8221;&gt; but validate.php is just for the ajax.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Eofys</title>
		<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/#comment-30618</link>
		<dc:creator>James Eofys</dc:creator>
		<pubDate>Fri, 23 Jul 2010 14:41:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.digimantra.com/?p=2344#comment-30618</guid>
		<description>Brent,

Check the &#039;action=&#039; bit in your form declaration. Sounds to me (just a guess) that you have something like 

You should be pointing it somewhere else, like maybe action=&quot;join.php&quot;

-James.</description>
		<content:encoded><![CDATA[<p>Brent,</p>
<p>Check the &#8216;action=&#8217; bit in your form declaration. Sounds to me (just a guess) that you have something like </p>
<p>You should be pointing it somewhere else, like maybe action=&#8221;join.php&#8221;</p>
<p>-James.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brent</title>
		<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/#comment-30560</link>
		<dc:creator>Brent</dc:creator>
		<pubDate>Thu, 22 Jul 2010 23:07:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.digimantra.com/?p=2344#comment-30560</guid>
		<description>Hi,

Great and simple script, thanks!

I&#039;ve wrapped this up in a form with a submit button.  Without clicking the availability button and clicking submit everything works fine.  If I click the availability button, the script works, but if I follow this with my submit button a get a blank screen with {&quot;code&quot;:-1,&quot;result&quot;:&quot;Invalid username&quot;}.

It&#039;s as if it&#039;s calling my onclick event, any ideas?

Cheers.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Great and simple script, thanks!</p>
<p>I&#8217;ve wrapped this up in a form with a submit button.  Without clicking the availability button and clicking submit everything works fine.  If I click the availability button, the script works, but if I follow this with my submit button a get a blank screen with {&#8220;code&#8221;:-1,&#8221;result&#8221;:&#8221;Invalid username&#8221;}.</p>
<p>It&#8217;s as if it&#8217;s calling my onclick event, any ideas?</p>
<p>Cheers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Eofys</title>
		<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/#comment-30471</link>
		<dc:creator>James Eofys</dc:creator>
		<pubDate>Thu, 22 Jul 2010 07:34:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.digimantra.com/?p=2344#comment-30471</guid>
		<description>Hi, very helpful info thanks.
I wonder if you could elaborate on this: &quot;Some may not be comfortable in using eval in the Javascript code, you can deal with JSON the way you like to.&quot;

Eg. What exactly does the eval part do and where can I go to find alternatives?</description>
		<content:encoded><![CDATA[<p>Hi, very helpful info thanks.<br />
I wonder if you could elaborate on this: &#8220;Some may not be comfortable in using eval in the Javascript code, you can deal with JSON the way you like to.&#8221;</p>
<p>Eg. What exactly does the eval part do and where can I go to find alternatives?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sachin Khosla</title>
		<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/#comment-22595</link>
		<dc:creator>Sachin Khosla</dc:creator>
		<pubDate>Fri, 28 May 2010 04:34:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.digimantra.com/?p=2344#comment-22595</guid>
		<description>Rocky, 

This is fairly simple to do. You can remove the button and instead associate the JavaScript function onblur event of input text, instead of onclick for the button.
</description>
		<content:encoded><![CDATA[<p>Rocky, </p>
<p>This is fairly simple to do. You can remove the button and instead associate the JavaScript function onblur event of input text, instead of onclick for the button.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rocky</title>
		<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/#comment-22593</link>
		<dc:creator>Rocky</dc:creator>
		<pubDate>Fri, 28 May 2010 04:25:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.digimantra.com/?p=2344#comment-22593</guid>
		<description>Hi Sachin, 

thx for the code it really helps. 
however in your code, we gotta click on the &quot;check availability&quot; button first to validate the username right? what if i want to validate the username without even clicking the button?
so for example: i have 2 inputs, username and password. in this case i type &quot;rocky&quot; into the username box, and when i click my mouse on the password box (onchange), the website will alert whether the username is available or not. How can i achieve that?
Thank you.

Regards
Rocky</description>
		<content:encoded><![CDATA[<p>Hi Sachin, </p>
<p>thx for the code it really helps.<br />
however in your code, we gotta click on the &#8220;check availability&#8221; button first to validate the username right? what if i want to validate the username without even clicking the button?<br />
so for example: i have 2 inputs, username and password. in this case i type &#8220;rocky&#8221; into the username box, and when i click my mouse on the password box (onchange), the website will alert whether the username is available or not. How can i achieve that?<br />
Thank you.</p>
<p>Regards<br />
Rocky</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sava Intl</title>
		<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/#comment-18260</link>
		<dc:creator>Sava Intl</dc:creator>
		<pubDate>Tue, 06 Apr 2010 09:34:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.digimantra.com/?p=2344#comment-18260</guid>
		<description>I Advance,

Please remove– $available = true;

and

use the following lines

$result = mysql_query($query);
$rows= mysql_num_rows($result);

then fixed your problem (Error).

Thanks &amp; Regards.

Sava Intl.</description>
		<content:encoded><![CDATA[<p>I Advance,</p>
<p>Please remove– $available = true;</p>
<p>and</p>
<p>use the following lines</p>
<p>$result = mysql_query($query);<br />
$rows= mysql_num_rows($result);</p>
<p>then fixed your problem (Error).</p>
<p>Thanks &amp; Regards.</p>
<p>Sava Intl.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sachin Khosla</title>
		<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/#comment-15791</link>
		<dc:creator>Sachin Khosla</dc:creator>
		<pubDate>Tue, 23 Feb 2010 14:27:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.digimantra.com/?p=2344#comment-15791</guid>
		<description>I see, 
What you are missing here is, mysql_query 

So in the above code, 
REMOVE - $available = true;

and 

ADD the following two lines

$result = mysql_query($query);
$available = mysql_num_rows($result);

That should solve your problem.

Thanks
Sachin Khosla</description>
		<content:encoded><![CDATA[<p>I see,<br />
What you are missing here is, mysql_query </p>
<p>So in the above code,<br />
REMOVE &#8211; $available = true;</p>
<p>and </p>
<p>ADD the following two lines</p>
<p>$result = mysql_query($query);<br />
$available = mysql_num_rows($result);</p>
<p>That should solve your problem.</p>
<p>Thanks<br />
Sachin Khosla</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Janine</title>
		<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/#comment-15787</link>
		<dc:creator>Janine</dc:creator>
		<pubDate>Tue, 23 Feb 2010 13:06:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.digimantra.com/?p=2344#comment-15787</guid>
		<description>Hello Sachin,

it doesn&#039;t work. I post my code here.

&lt;?php
$DatabaseHost = &quot;localhost&quot;;
$DatabaseUser = &quot;xxx&quot;;
$DatabasePassword = &quot;xxx&quot;;
$Database = &quot;db&quot;;

mysql_connect($DatabaseHost, $DatabaseUser, $DatabasePassword) or die(mysql_error());
mysql_select_db(db);

$user = strip_tags(trim($_REQUEST[&#039;username&#039;]));
 
if(strlen($user)   -1,
  &#039;result&#039;  =&gt;  &#039;Invalid username, please try again.&#039;
  ));
  die;
}

$query = &quot;SELECT * FROM userdata WHERE Nickname = &#039;$user&#039; &quot;;
 
$available = true;
 
if($available)
{
  echo json_encode(array(&#039;code&#039;  =&gt;  1,
  &#039;result&#039;  =&gt;  &quot;Success,username $user is still available.&quot;
  ));
  die;
}
else
{
  echo  json_encode(array(&#039;code&#039;  =&gt;  0,
  &#039;result&#039;  =&gt;  &quot;Sorry but username $user is already taken.&quot;
  ));
  die;
}
die;
?&gt;

When i validate the nickname ever come Success,username xxx is still available

Whats wrong?
Pls help me. 

Thanks
Janine</description>
		<content:encoded><![CDATA[<p>Hello Sachin,</p>
<p>it doesn&#8217;t work. I post my code here.</p>
<p>&lt;?php<br />
$DatabaseHost = &quot;localhost&quot;;<br />
$DatabaseUser = &quot;xxx&quot;;<br />
$DatabasePassword = &quot;xxx&quot;;<br />
$Database = &quot;db&quot;;</p>
<p>mysql_connect($DatabaseHost, $DatabaseUser, $DatabasePassword) or die(mysql_error());<br />
mysql_select_db(db);</p>
<p>$user = strip_tags(trim($_REQUEST[&#039;username&#039;]));</p>
<p>if(strlen($user)   -1,<br />
  &#8216;result&#8217;  =&gt;  &#8216;Invalid username, please try again.&#8217;<br />
  ));<br />
  die;<br />
}</p>
<p>$query = &#8220;SELECT * FROM userdata WHERE Nickname = &#8216;$user&#8217; &#8220;;</p>
<p>$available = true;</p>
<p>if($available)<br />
{<br />
  echo json_encode(array(&#8216;code&#8217;  =&gt;  1,<br />
  &#8216;result&#8217;  =&gt;  &#8220;Success,username $user is still available.&#8221;<br />
  ));<br />
  die;<br />
}<br />
else<br />
{<br />
  echo  json_encode(array(&#8216;code&#8217;  =&gt;  0,<br />
  &#8216;result&#8217;  =&gt;  &#8220;Sorry but username $user is already taken.&#8221;<br />
  ));<br />
  die;<br />
}<br />
die;<br />
?&gt;</p>
<p>When i validate the nickname ever come Success,username xxx is still available</p>
<p>Whats wrong?<br />
Pls help me. </p>
<p>Thanks<br />
Janine</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sachin Khosla</title>
		<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/#comment-15783</link>
		<dc:creator>Sachin Khosla</dc:creator>
		<pubDate>Tue, 23 Feb 2010 10:36:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.digimantra.com/?p=2344#comment-15783</guid>
		<description>Hey Janine, 

The mysql query depends upon  your database structure, i.e. table name and the column names. The simplest query would be, 

$query = &quot;Select * from USER_TABLE where username = &#039;$user&#039;&quot;;

You need to replace 
USER_TABLE with the table name in whcih users are stored.
username with the actual column name you have in your table.

If you still have any problem, feel free to ask. 

Thanks
Sachin Khosla</description>
		<content:encoded><![CDATA[<p>Hey Janine, </p>
<p>The mysql query depends upon  your database structure, i.e. table name and the column names. The simplest query would be, </p>
<p>$query = &#8220;Select * from USER_TABLE where username = &#8216;$user&#8217;&#8221;;</p>
<p>You need to replace<br />
USER_TABLE with the table name in whcih users are stored.<br />
username with the actual column name you have in your table.</p>
<p>If you still have any problem, feel free to ask. </p>
<p>Thanks<br />
Sachin Khosla</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Janine</title>
		<link>http://www.digimantra.com/technology/javascript/check-username-availability-validation-ajaxphp/#comment-15781</link>
		<dc:creator>Janine</dc:creator>
		<pubDate>Tue, 23 Feb 2010 10:30:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.digimantra.com/?p=2344#comment-15781</guid>
		<description>Hello,
sorry my english is not so good.

I have a problem with this script. I will check the usernames from a mysql database.

How can i read the usernames from the database?

Pls help me

Janine</description>
		<content:encoded><![CDATA[<p>Hello,<br />
sorry my english is not so good.</p>
<p>I have a problem with this script. I will check the usernames from a mysql database.</p>
<p>How can i read the usernames from the database?</p>
<p>Pls help me</p>
<p>Janine</p>
]]></content:encoded>
	</item>
</channel>
</rss>
