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!
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.
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?
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.
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
@phpacademy nice tutorial Alex but you can use $(function(){ ... }); instead of $(document).ready(function(){ ... }); it way shorter and equivalent as well
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
@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.
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.
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.
@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.
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! ;)
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
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"...
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?
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. :)
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.
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.
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..
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
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?
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)) { } ???????
@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.
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?
+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();
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(); } }); });
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.
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.
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
10 Whole years later and you're saving me on my final project!
Thanks for the timeless tutorial!
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!
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.
even your tutorials from 2010 are top notch, keep doing what you're doing!
Very useful. With some adjustments it's working in 2020 with Mysqli and php 7. Thank you for this awesome tutorial
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?
this tutorial is still relevant after 9 years
Your work continues to inspire me. You're a great teacher. Please donate to Alex! I know I did.
YOU ARE BEST BRO KEEP THAT UP!!!! I LEARN ALL PHP FROM YOUR TUTORIALS!1 THANK YOU !!
Thanks Alex
Works fine - solves some problems and sleepless nights for me
What changes do we need to make for using this method in a professional website?
@phpacademy YOU ARE THE BEST. DON'T SAY I AM NOT THE BEST!
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.
tnx man its working more simpler than ajax
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
@phpacademy nice tutorial Alex but you can use $(function(){ ... }); instead of $(document).ready(function(){ ... }); it way shorter and equivalent as well
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
@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.
GR88888888888888888 Tutorial ... very well explained / broken down .. keep up the good work
Amazing & very comprehensive tutorial among thousand tut, its that what i was looking for . thax a lot & carry on...........
I think there could be a resource problem on big websites since this does a mysql SELECT on each input to the field.
Is it possible to do this for two different fields with two different divs using the same check.php. Great video. Thanks
Also, can't you do mysql_query("SELECT username FROM mydatabase.users") instead of having the mysql_db_select??
Excellent tutorial! Easy to follow. Thanks,
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.
I'm sure you misspoke, but I think # in css indicates that feedback is an id, not a div.
you could use $(this).val() instead of form.username.value to take the value
Awesome description! I use this on my website now :)
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.
@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.
You're the best! This is the only explanation that has made sense to me! thanks!! :D
Excellent, once again alex!
if anyone Is having problems with this code, change the document.ready(function()) to just $function()
That worked for me
great tutorial!, code you please put the sorce code on your forum?
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! ;)
You are a life saver alex!!!
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
Nice tutorial but my page display by default
Notice: Undefined index: username in check.php on line 3
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"...
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?
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. :)
Thanks it's worked for me
also, could you please explain the difference between Ajax and jQuery?
in your code type in `username` instead of just username
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.
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.
good teaching
i liked how you made it and thank u
what's the difference, ability wise, from jquery and ajax?
Thank Again Sir. Amazing tutorial as always. Your a giver :)
You must be send by god :O
This is a bloody amazing tutorial! Thank you so so much!!!
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.
What about putting the scripts at the end of the page? Nice tutorial though, thanks!
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..
Can you make an autocomplete tutorial? Thanks!
Great video, this was very helpful.
@classensoft The mysql db require it to the WHERE data to be exactly the in db one.
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?
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
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.
THANK YOU!!! Awesome script and video!!
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?
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)) { } ???????
where did you learned jQuery from is there any book or online course ?
thank you alex for ur awesome videos :)
Awesome tutorial! Still, it would be awesome to see how you can put data etc in the DB etc :D
@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.
this is excellent tutorial....But there is something Unreadable(look so bad) by default in feedback div. although i works 100%.
good teaching
Thanks, Great tutorial.
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?
Thank you .I love you
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??
thank you very much!!! You're brilliant!
Thanx dude you ROCK
THANK YOU!
worked!! but i have button to submit the form to sql. how do i disable the submit button when username is not available?
+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();
not workin
Are you familiar with PDO?
no
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();
}
});
});
Notice: Undefined index: username , Why,plz?
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.
@RomanovichCS
It does work on my fireworks.
my falt i correct it and its working thanks !!
not working on firefox...any idea?
this maket my day...tanks man
Wow, extremely useful! Thanks.
I am not sure why the check.php file doesn't load. Can someone please help me? Thanks!
username : form.username.value or username : $('#username_input').val() is not working.....
thanks, I learned a lot ^_^
thanks a lot!
great but how can i disable button if it is too short
I replied to a similar question above.
@saikirakiva Actually found out why. Miss a letter..haha..
u teach good...
very nice sir.
what does the jquery.js file contain?
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.
@machine1112 you can learn it at jquery's site jquery.com or just google it
nice tutorial
if you made the code available I would be much more inclined to follow. Can't check my mistakes against your code.
Great.
Freaking Top Notch!
@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
I thought that only happens here in uganda...
thanks :)
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
buddyroach You should pass $link suppose where
$link=mysqli_connect(blah blah hlah);
mysqli_num_rows($link, blah)
@@indirabanjade9844 - You might see that if your database query returns no data. You might have an error in your SELECT statement.
@9081178 why is shorter videos better ?
@vlogger3000 hmmm.... thanks.... :)
@phpacademy
no you are :D