Note that there are some explanatory texts on larger screens.

plurals
  1. POFaceBook Registration Plugin Async Validate form (to check Username availbility)
    primarykey
    data
    text
    <p>Ok, So I have Google the hell out of this problem and the <a href="https://developers.facebook.com/docs/plugins/registration/advanced/" rel="nofollow">FB Advanced Registration</a> documentation also did not help. I want to have a Facebook Registration where a user can choose(&amp; Check availability of) his username like this:<br> (Screenshot of what I plan to do but have failed to do, since I cant post picturesin this question directly) <a href="https://lh3.googleusercontent.com/-AslFHlhW2TA/T9B52EjzpOI/AAAAAAAAALU/mD4wGeQdi1w/s683/prob.PNG" rel="nofollow">A link to Screenshot of what I wanted</a>! </p> <p>I plan to check the availability of the username from my DB in mysql using PHP, but I am stuck with this weird JSON callback thing which I have failed to understand. My Registration Plugin looks something like this </p> <pre><code>&lt;fb:registration fields='[{"name":"name"},{"name":"username","description":"Username","type":"text"}]' onvalidate="validate_async" redirect-uri="http://mysite.com/loginFB.php" fb_only="false" width="530"&gt; &lt;/fb:registration&gt; &lt;script src="http://code.jquery.com/jquery-1.7.1.min.js"&gt;&lt;/script&gt; &lt;script&gt; function validate_async(form, cb) { // $.getJSON('https://graph.facebook.com/' + form.username + '?callback=?',//CODE obtained from FB documentation $.getJSON('https://mysite.com/checkUsername.php?username=' + form.username + '?callback=?', function(response) { if (response.error== "false") { // Username isn't taken, let the form submit cb(); } cb({username: 'That username is taken, Sorry!'}); }); } &lt;/script&gt; </code></pre> <p>I wanted to know WHAT EXACTLY do I write the in the <b>checkUsername.php</b>.<br> Right now I have come up with the following code for checkUsername.php which does NOT work: </p> <pre><code> &lt;?php $conn = dbconnect(GLOBAL_Db); $username = $_GET['username']; $data = array(); $table = mysql_real_escape_string(GLOBAL_Db. "." . GLOBAL_Users); $sqlCommand = "SELECT * FROM ".$table." WHERE username='$username'"; $query = mysql_query($sqlCommand) or die (mysql_error()); $num_rows = mysql_num_rows($query); if($num_rows&gt;0){ $data['error'] = "true"; } else { $data['error'] = "false"; } echo json_encode($data); ?&gt; </code></pre> <p>This code does not give me that that <i>"The username is taken, Sorry"</i> Message , WHY???<br> I would really appreciate it if anyone could actually help me out with this getJSON function in the script , AND Also help me out with the checkUsername.php since I have a very crude knowledge of JSON, (JSONP) etc. ! Would be glad to put in more effort to explaain my problem coz this is bugging me for like a Week now! Happy to accept some valuable help from you guys!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload