PHP Tutorials: jQuery: Check if a username is available without refreshing

Поделиться
HTML-код
  • Опубликовано: 24 июл 2010
  • Want more? Explore the library at www.codecourse...
    Official site
    www.codecourse...
    Twitter
    / teamcodecourse

Комментарии • 143

  • @DayOldSoda1
    @DayOldSoda1 4 года назад

    10 Whole years later and you're saving me on my final project!
    Thanks for the timeless tutorial!

  • @fastsol
    @fastsol 14 лет назад

    Very good! I have tried to turn several people to your channel in hopes of helping them. It's awesome to see that when a suggestion is made about a tutorial you actually do listen to us and go forth. Thanks again!

  • @americancitizen748
    @americancitizen748 4 года назад

    Very good. I used a simple version of this in my website. Keep in mind that, after new releases of PHP, you must now use msqli_real_escape_string which requires TWO parameters. First parameter will be your database connection string.

  • @iluke95
    @iluke95 7 лет назад

    even your tutorials from 2010 are top notch, keep doing what you're doing!

  • @wordpressidee
    @wordpressidee 4 года назад

    Very useful. With some adjustments it's working in 2020 with Mysqli and php 7. Thank you for this awesome tutorial

  • @BrianClincy
    @BrianClincy 13 лет назад +4

    Alex would it be better to test the length before doing the query? Would this reduce the server load? Each key stroke being a query seem a lot if there are a lot of people connecting?

  • @watahecYT
    @watahecYT 5 лет назад

    this tutorial is still relevant after 9 years

  • @BugsVsHumans
    @BugsVsHumans 13 лет назад

    Your work continues to inspire me. You're a great teacher. Please donate to Alex! I know I did.

  • @TrojanOnSacnr
    @TrojanOnSacnr 12 лет назад

    YOU ARE BEST BRO KEEP THAT UP!!!! I LEARN ALL PHP FROM YOUR TUTORIALS!1 THANK YOU !!

  • @marc_h_cl
    @marc_h_cl 11 лет назад

    Thanks Alex
    Works fine - solves some problems and sleepless nights for me

  • @nayandeepyadav8790
    @nayandeepyadav8790 8 лет назад

    What changes do we need to make for using this method in a professional website?

  • @stheodosiadis
    @stheodosiadis 12 лет назад

    @phpacademy YOU ARE THE BEST. DON'T SAY I AM NOT THE BEST!

  • @panosgavalas7412
    @panosgavalas7412 11 лет назад

    Lets say you had a submit button next to the username field, Depending on the availability of the username, is there a way to disable / enable the use of the submit button? Thanks for all your effort.

  • @demon6937
    @demon6937 11 лет назад

    tnx man its working more simpler than ajax

  • @chrisleo6484
    @chrisleo6484 7 лет назад +1

    why are your tutorial codes hidden? i think it should be where your followers can be able to see it, download it and be able to test it should just following live tutorials doesn't work for them. just saying cause i followed your tutorial on this but after the first three lines of code it doesn't work, and there's no way of me checking yours with mine to see where what went wrong

  • @gonzo191
    @gonzo191 14 лет назад

    @phpacademy nice tutorial Alex but you can use $(function(){ ... }); instead of $(document).ready(function(){ ... }); it way shorter and equivalent as well

  • @joeydisessa
    @joeydisessa 14 лет назад

    Hello Alex , I have been watching your videos for a while and I must say you do a great job explaining while you te4ach PhP. Much appreciated. I'm not sure if you have a tutorial; on this already but i wasnt able to find it. Would you mind doing a simple video for passing XML using CURL in PhP? Thanks

  • @9081178
    @9081178 14 лет назад

    @nuwaus well, downloading is the main issue, here in Pakistan, load shedding is a big issue, the video is in the download process and the power goes out, and i have to download the whole thing again. i know its easier to watch the whole video at once, but download it is a main issue.

  • @MrFreshShizzle
    @MrFreshShizzle 13 лет назад

    GR88888888888888888 Tutorial ... very well explained / broken down .. keep up the good work

  • @champack2003
    @champack2003 13 лет назад

    Amazing & very comprehensive tutorial among thousand tut, its that what i was looking for . thax a lot & carry on...........

  • @AXNPictures
    @AXNPictures 11 лет назад

    I think there could be a resource problem on big websites since this does a mysql SELECT on each input to the field.

  • @SachinFern
    @SachinFern 10 лет назад

    Is it possible to do this for two different fields with two different divs using the same check.php. Great video. Thanks

  • @JamesAutoDude
    @JamesAutoDude 10 лет назад

    Also, can't you do mysql_query("SELECT username FROM mydatabase.users") instead of having the mysql_db_select??

  • @georgeiman
    @georgeiman 11 лет назад

    Excellent tutorial! Easy to follow. Thanks,

  • @nubilerasify
    @nubilerasify 6 лет назад

    Hi, thanks for the tutorial but I am having some issues. The php part is not working inside of the function block, all preliminary test with the javascript works fine however, when i start the PHP it stops working. Initially I got the undefined index error and I used the if isset but still, I haven't received the desired result. Can you assist in any way...i would be grateful.

  • @JohnInk
    @JohnInk 10 лет назад +1

    I'm sure you misspoke, but I think # in css indicates that feedback is an id, not a div.

  • @SaiyanJin85
    @SaiyanJin85 14 лет назад

    you could use $(this).val() instead of form.username.value to take the value

  • @JamesAutoDude
    @JamesAutoDude 11 лет назад

    Awesome description! I use this on my website now :)

  • @DarkXCyberZX
    @DarkXCyberZX 8 лет назад

    Sir, please help me. I'm Stuck and i really need this for my final project. I'm stuck at when you want to test your $('#feedback').html(result).show(); , i got the error of undefined index but i manage to remove the error with solution from the comment section(thank you) but i didn't get anything when i typed in the username textbox. When i remove everything inside the check.php and type something like aasdasd , it appeared on my index.php but when i use the php code echo $username = $_POST['username']; nothing appear or happen on my index.php.

  • @9081178
    @9081178 14 лет назад

    @shaunno2009 well, downloading is the main issue, here in Pakistan, load shedding is a big issue, the video is in the download process and the power goes out, and i have to download the whole thing again. i know its easier to watch the whole video at once, but download it is a main issue.

  • @JamesAutoDude
    @JamesAutoDude 11 лет назад

    You're the best! This is the only explanation that has made sense to me! thanks!! :D

  • @ChrisSnip
    @ChrisSnip 13 лет назад

    Excellent, once again alex!

  • @MrProMilkyBarKid
    @MrProMilkyBarKid 11 лет назад

    if anyone Is having problems with this code, change the document.ready(function()) to just $function()
    That worked for me

  • @shaya_sonnenberg
    @shaya_sonnenberg 14 лет назад

    great tutorial!, code you please put the sorce code on your forum?

  • @materally
    @materally 13 лет назад

    I wrote this code but it did not work..
    If you have that problem, here the solution:
    Because:
    "username: form.username.value"
    This row is not working.
    Change this row this:
    username: $('#username_input').val()
    And it is going to work :)
    Nice job Alex! ;)

  • @harleybalo
    @harleybalo 13 лет назад

    You are a life saver alex!!!

  • @imawesome4734
    @imawesome4734 7 лет назад

    Notice: Undefined index: username in C:\xampp\htdocs\medcares\check.php on line 2
    that's what it says when I refresh my page. please tell me how can i fix it

  • @shuaibbit
    @shuaibbit 10 лет назад +1

    Nice tutorial but my page display by default
    Notice: Undefined index: username in check.php on line 3

  • @JamesAutoDude
    @JamesAutoDude 11 лет назад

    Just a quick update... I tried implementing this to my site but, I got an error of "value" is not defined... So I went through the coding again and found that, you have to have "document.formname.fieldID.value" instead of "formname.fieldID.value"...

  • @ianrey8853
    @ianrey8853 10 лет назад +1

    could someone help me on this.
    When the page loads for the 1st time, it always show this Notice msg:
    "Notice: Undefined index: username"
    but when I wrote something on the textbox, it disappear.
    how could I fix this?

    • @ianrey8853
      @ianrey8853 10 лет назад +2

      I did fix the my own problem. if someone is having the same problem too, just add: if (isset ($_POST['username'])) {...} first before putting any code. :)

    • @Nova-uo3fp
      @Nova-uo3fp 6 лет назад

      Thanks it's worked for me

  • @9081178
    @9081178 14 лет назад

    also, could you please explain the difference between Ajax and jQuery?

  • @DeepakKapoorThePaandu
    @DeepakKapoorThePaandu 12 лет назад

    in your code type in `username` instead of just username

  • @scshil
    @scshil 8 лет назад +1

    Vary helpful. Thank you. But how can i disable the submit button if the name already exist? It will be really helpful if you suggest any solution.

    • @DrillManga
      @DrillManga 8 лет назад +2

      Give the submit button an id attribute, with an id e.g 'sub-btn'. When the result is false as in the username exists, write in javascript something like document.getElementById('sub-btn').disabled = true. You can use jQuery if you prefer, but it's rather easy to achieve in general. If you do the above, you will need to have code that enables the button, as it will now appear disabled and won't change unless you reload the page.

  • @MsMaxmax121
    @MsMaxmax121 13 лет назад

    good teaching
    i liked how you made it and thank u

  • @swamp_town47
    @swamp_town47 13 лет назад

    what's the difference, ability wise, from jquery and ajax?

  • @lucasgabule
    @lucasgabule 8 лет назад

    Thank Again Sir. Amazing tutorial as always. Your a giver :)

  • @jelst0991
    @jelst0991 11 лет назад +1

    You must be send by god :O
    This is a bloody amazing tutorial! Thank you so so much!!!

  • @nicksalad
    @nicksalad 13 лет назад

    All cool, but is not so much performance friendly when you have a big database if you are going to make a connection everytime the user presses a key, it should be on blur imo, and adding a wait period after checking would be useful as well. With a database of almost a million users like mine, it would kill the server, specially if those bad intentioned users play with it.

  • @JamesAutoDude
    @JamesAutoDude 10 лет назад

    What about putting the scripts at the end of the page? Nice tutorial though, thanks!

  • @100dablu
    @100dablu 12 лет назад

    I noitice error in error_reporting(E_ALL ^ E_NOTICE); is that when you copy this it will be pasted like
    error_reporting(E_ALL ? ^ E_NOTICE); means extra ? mark in pasted code..

  • @BugsVsHumans
    @BugsVsHumans 14 лет назад

    Can you make an autocomplete tutorial? Thanks!

  • @commanderzero891
    @commanderzero891 12 лет назад

    Great video, this was very helpful.

  • @katt157
    @katt157 14 лет назад

    @classensoft The mysql db require it to the WHERE data to be exactly the in db one.

  • @McDonaldilondu
    @McDonaldilondu 8 лет назад

    i'm using WAMP server 2.0 and i tried to show dummy data from check.php but its not displaying! what seems to be the problem?

    • @CarlSaptarshi
      @CarlSaptarshi 8 лет назад

      rather than placing the js script into another file, place it into the main html / php page that you are using and include the script tags at the bottom, then it should work - that is what i did when i had that problem

  • @RicardoTosin
    @RicardoTosin 13 лет назад

    I hav a question i made it here and its ok but i need to insert things in my database
    and wen i use action="insert.php" at form jquery do not work.

  • @mjohnson0321
    @mjohnson0321 12 лет назад

    THANK YOU!!! Awesome script and video!!

  • @ti07shadow
    @ti07shadow 13 лет назад

    I had it working but after typing the rest of the code. even after removing the new code after the displaying data from the check.php file it just stopped working?

  • @AreNyK
    @AreNyK 11 лет назад

    what if i want send more post variables for check.php via that javascript code.
    is it : $.post('check.php', { username:form.username.value , var2:value}, function(result)) { } ???????

  • @machine1112
    @machine1112 14 лет назад

    where did you learned jQuery from is there any book or online course ?

  • @MrKuntalstar
    @MrKuntalstar 13 лет назад

    thank you alex for ur awesome videos :)

  • @xatic1
    @xatic1 14 лет назад

    Awesome tutorial! Still, it would be awesome to see how you can put data etc in the DB etc :D

  • @DY357LX
    @DY357LX 14 лет назад

    @9081178 I prefer the full-length video's. No more looking for parts 2+3 of the relevant tutorials.
    Keep them this way please Alex, it's much better and more organized.

  • @drabsiddique
    @drabsiddique 10 лет назад

    this is excellent tutorial....But there is something Unreadable(look so bad) by default in feedback div. although i works 100%.

  • @MsMaxmax121
    @MsMaxmax121 13 лет назад

    good teaching

  • @ahmedihmeid
    @ahmedihmeid 13 лет назад

    Thanks, Great tutorial.

  • @nascal3
    @nascal3 12 лет назад

    mine is also not working and i have typed everything word to word letter to letter, is there any solution to this...........all am getting is an error message saying "Undefined index: username" when i run the code,any HELP out there?

  • @Nova-uo3fp
    @Nova-uo3fp 6 лет назад

    Thank you .I love you

  • @chesun8339
    @chesun8339 11 лет назад

    i'm using WAMP and i tried to show dummy data but doesnt work! i dont know why ?? i have to install other tools to read jquery??

  • @fkee73
    @fkee73 11 лет назад

    thank you very much!!! You're brilliant!

  • @nascal3
    @nascal3 12 лет назад

    Thanx dude you ROCK

  • @camillegarcia1438
    @camillegarcia1438 5 лет назад

    THANK YOU!

  • @paktongko90
    @paktongko90 8 лет назад +1

    worked!! but i have button to submit the form to sql. how do i disable the submit button when username is not available?

    • @tiagogoncalvesfaria1854
      @tiagogoncalvesfaria1854 8 лет назад

      +paktongko90
      Let us suppose you have a submit button with an id of "register_btn"..
      You could add this to elseif(check_num_rows==1) {
      echo "Not available!";
      ?>
      $('#register_btn').hide();

    • @mirshazia4436
      @mirshazia4436 8 лет назад

      not workin

    • @tiagogoncalvesfaria1854
      @tiagogoncalvesfaria1854 8 лет назад

      Are you familiar with PDO?

    • @mirshazia4436
      @mirshazia4436 8 лет назад

      no

    • @mirshazia4436
      @mirshazia4436 8 лет назад

      i dnt wnt it to lemme click on submit if notavailable
      i wrote this but not wrkin
      $(document ).ready(function()
      {
      $("#feedback").load("check.php");
      $("input#user_email").change(function()
      { $.post("check.php",{email:signupForm.email.value}, function(result){$("#feedback").html(result)
      .show(); });
      if($('#feedback').html()=="notavailable")
      {
      $('input#sub').hide();
      }
      });
      });

  • @tuanvietND
    @tuanvietND 13 лет назад

    Notice: Undefined index: username , Why,plz?

  • @9081178
    @9081178 14 лет назад

    hey Alex, you're no longer taking care of the video length. Please divide the videos in parts if possible. Its difficult to download such a big file at once. thanks.

  • @harleybalo
    @harleybalo 13 лет назад

    @RomanovichCS
    It does work on my fireworks.

  • @RicardoTosin
    @RicardoTosin 13 лет назад

    my falt i correct it and its working thanks !!

  • @Extjac
    @Extjac 14 лет назад

    not working on firefox...any idea?

  • @flaviusioan69
    @flaviusioan69 11 лет назад

    this maket my day...tanks man

  • @klassictechtutorials
    @klassictechtutorials 14 лет назад

    Wow, extremely useful! Thanks.

  • @saikirakiva
    @saikirakiva 13 лет назад

    I am not sure why the check.php file doesn't load. Can someone please help me? Thanks!

  • @rohitbellary
    @rohitbellary 13 лет назад

    username : form.username.value or username : $('#username_input').val() is not working.....

  • @lanceNull
    @lanceNull 12 лет назад

    thanks, I learned a lot ^_^

  • @learnfullstackqaonline
    @learnfullstackqaonline 8 лет назад

    thanks a lot!

  • @arnoldfederis
    @arnoldfederis 8 лет назад

    great but how can i disable button if it is too short

    • @DrillManga
      @DrillManga 8 лет назад

      I replied to a similar question above.

  • @saikirakiva
    @saikirakiva 13 лет назад

    @saikirakiva Actually found out why. Miss a letter..haha..

  • @alphabeta2091
    @alphabeta2091 12 лет назад

    u teach good...

  • @guduguminchu
    @guduguminchu 11 лет назад

    very nice sir.

  • @satyachillale
    @satyachillale 8 лет назад

    what does the jquery.js file contain?

    • @americancitizen748
      @americancitizen748 4 года назад

      It contains the standard jQuery script file (example: jquery-1.12.4.min.js) which is freely available for download. Get it at jquery.com. jQuery is easier to learn and use than raw AJAX code! Secret: The XMLHttpRequest command is buried in the jQuery file -- and that is the essence of AJAX.

  • @gonzo191
    @gonzo191 14 лет назад

    @machine1112 you can learn it at jquery's site jquery.com or just google it

  • @reojavier2477
    @reojavier2477 11 лет назад

    nice tutorial

  • @BelieveB23
    @BelieveB23 6 лет назад

    if you made the code available I would be much more inclined to follow. Can't check my mistakes against your code.

  • @fl366
    @fl366 9 лет назад

    Great.

  • @ToyObsessed
    @ToyObsessed 12 лет назад

    Freaking Top Notch!

  • @latlov
    @latlov 14 лет назад

    @glfunkyspyspy from jquery.com click on download. you'll get this file jquery-1.4.2.min.js but you can save it as jquery.js

  • @olukabruno
    @olukabruno 14 лет назад

    I thought that only happens here in uganda...

  • @kudafoolhu
    @kudafoolhu 13 лет назад

    thanks :)

  • @buddyroach
    @buddyroach 8 лет назад

    it keeps thinking a NULL is given.
    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in E:\wamp\www\phpscripts\signup.php on line 85

    • @indirabanjade9844
      @indirabanjade9844 7 лет назад

      buddyroach You should pass $link suppose where
      $link=mysqli_connect(blah blah hlah);
      mysqli_num_rows($link, blah)

    • @americancitizen748
      @americancitizen748 4 года назад

      @@indirabanjade9844 - You might see that if your database query returns no data. You might have an error in your SELECT statement.

  • @wideload123
    @wideload123 14 лет назад

    @9081178 why is shorter videos better ?

  • @9081178
    @9081178 14 лет назад

    @vlogger3000 hmmm.... thanks.... :)

  • @bohterham
    @bohterham 13 лет назад

    @phpacademy
    no you are :D