Added: 3 years ago
From: phpacademy
Views: 47,402
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (196)

Sign In or Sign Up now to post a comment!
  • Hey Alex, thank you so much for your time in making these clips. I've learned so much since I started watching them. I am having some difficulty with them as I have altered them to conform to my website. I was wondering if there were source codes for these tutorials as I have spent the last two weeks pouring over the code and have not found the problem yet. Again thanks for your time in making these.

  • Thank you :D

  • THANK YOU SO MUCH!!!

  • Parse error: syntax error, unexpected T_ECHO in C:\xampp\htdocs\register.php on line 25

    My error!

  • Comment removed

  • Thank you so much . your the best Tutorial !

  • 'very nice tutorial!! Thank you

  • Comment removed

  • thank u so much! ur d man!

  • thanks mate, really helped

  • you helped me a lot! Thank you

  • can i get this code please?

  • youtube now becoming more and more money chaser!! stop that dumbass ads!!

  • it still says my password is incorrect even after having changed my database $password character length to 1000 characters.

  • Comment removed

  • i've only been exposed to PHP for close to 3 months now...u can say im still an extreme novice...but i gotta say, that these tutorials are absolutely brilliant. no matter what others have said about them, or the dislikes about them, they are just fantastic. easy to understand. if you follow them step by step, and be patient, they are very helpful. thank you so much!

  • Can't use function return value in write context in C:\xampp\htdocs\bautista\login­.php on line 20......

    this is the line if ($username == $dbusername&&md5($password) = $dbpassword)

    why does this problem go out?

  • You can check if the user exists by using his login example. $query = mysql_query("SELECT * FROM users WHERE username='$username'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { while ($row = mysql_fetch_assoc($query)) //Checks the password $dbusername = $row['username']; $dbpassword = $row['password']; } if {blah blah blah (check if username and password match)} else die("The username is already taken")
  • @emrickgj omg I lost all my formatting. uhh. . . yeah go to his login example

  • Ok then, how do I check that the username hasn't already been taken?

  • @LEilllLEi his version is from 2009, its almost 2012, so the format has been modified somewhat.

  • my register isnt working !!! php academy. org/

    forum/ post69915.html#p69915

  • @l4dhehe what exactly is the error?

  • Your tutorials are very helpful and informative, but I am a php rookie and sometimes it's hard to keep up. I am having trouble with some errors here and there but your acknowledgment of your own mistakes and encouragement to seek through the code for mine has made me feel like I am just making common trip ups like anyone else.

    Thanks for a great tutorial, I will definitely be back for more!

    ~Komrade Vlad

  • you are my php hero...thanks mate.your tutorials are very clear..most likely think is the way your are solving errors. its is very help full for me...thanks you very much

  • you should learn some better html syntax

  • HELP when i click on register i have this error

    Notice: Undefined index: submit in C:\xampp\htdocs\login\register­.php on line 4

    Notice: Undefined index: Name in C:\xampp\htdocs\login\register­.php on line 5

    Notice: Undefined index: username in C:\xampp\htdocs\login\register­.php on line 6

    Notice: Undefined index: password in C:\xampp\htdocs\login\register­.php on line 7

    Notice: Undefined index: repeatpassword in C:\xampp\htdocs\login\register­.php on line 8

  • @DarlingBryan

    place an

    @

    before the

    $_POST['submit']

    so it looks like

    @$_POST['submit']

  • @DarlingBryan Do that for every one

  • @AbhishekPratapa thanks the guy from the phpacademy taught me that too!

  • Thanks a lot...

  • echo "Alex:

    Great work, you come to the level of user and then explain every thing absolutely beautiful";

  • Dear Alex, this is the first tutorial that you have made that I have tried my hardest not to exactly duplicate, but to add my own little coding style to it. This tutorial has been AMAZING to help me remember things like semi colons to terminate and just learn altogether, I would recommend anyone in an intermediate level looking to polish up some skills to this tutorial, I love you, =P

  • Your tutorials are great!....Would you be willing to do a tutorial on how to create a clear button that clears all fields once clicked?

  • @Naeem237 there is one in HTML, it resets the form. input type="reset" value="reset"

  • @getupkid203 dont forget to put the open and close tags on each end...

  • @phpacademy, What if a user tries to register with the same username as another user ? Can you show us how we can prevent it ?

  • Correct me if I'm wrong.

    My research says that

    hash('sha512', $password, false);

    is far more better than md5($password);

    encryption

  • how do you fix the MD5 error problem, the user is in the DB with correct username and password then when I try to login it says username or password incorrect.

    

  • I'd like a simple script as a n IF statement to check if the user is logged in. then do a set of commands.

  • If you re-type the password wrong, ALL box text will be deleted. if I press back in my browser all the content will apear again because of the echo $fullname But why do I have to go back in my browser to see it?

  • Try it, if you type in the password wrong, you will get "Your passwords do not match" and all the content is deleted.

    And if you go back in your browser you will see everything again. But if you refresh the page all will be deleted. Help please!

  • Comment removed

  • awesome man, suscribed you! thanks for great tuts n keep up de gr8 work :)

  • if i'm register the account isn't in my database D: Please help me!!!

  • awsome work buddy thanks heeps :-D

  • Comment removed

  • Remove unwanted errors when a variable isn't declared by placing this code at the top of your php file:

    error_reporting (E_ALL ^ E_NOTICE);

    This works on all your pages.

    Thumbs up so everyone can see!

  • Thanks Alex!

    Quick Question: If there is no POST data to be echoed by php as a value in the form fields, I am getting an "undeclared variable" error message. In other words, the first time my register page is visited, I am getting error messages above the input fields.

    How do you code the register.php page such that a user's first visit (ie there is nothing to be echoed in the form fields) will display a clean empty form instead of an error message as a result of an "undeclared variable?"

  • Thank you SO much for this tutorial! I am a total PHP N00B and I understood everything.

  • "0:48 typed in a load of rubbish here."

    i swear the accent is the best lol.

  • great tutorial but i think that you forgot to check if usere name already exist

  • thank u ,

    but how can i move the result to another place in website?

    i want all the warrning result be in the same page with the form ,so if it shows username already exist for example iwant it to be undeer the form so they wont go back?

  • Thank you! But can you not make a opdate where you show how to move all the boxes to another place of the website? :D That could be really nice :)

  • lol I tried to sign into the phpacademy Youtube account using sliceruk1

  • Good job. Thank you very much. .Awesome...

  • Thank you and very good job. thanks

  • Very nice tutorials! Helps me understand the basics of PHP alot faster!

  • There is a big problem, with this script you can have an unlimited number of users with the same username. You never check during the registration if the username already exists in the database.

  • yay i got an error Parse error: syntax error, unexpected T_ELSE in /blabla my website/register.php on line 30

  • Best user and login registration tutorial, it works perfect to me (i had a litle problem with the md5 part, but is fixed now!! THANKS ALEX!!!!!

  • Comment removed

  • I would just like to say thank you very much, very nice job and I look forward to your future videos!

  • you didnt show us how to check if the username is already taken!!!!

  • @daeheadshot no brainer. use an if statement... if($username==$dbusername) echo "Username taken."; It's just common sense.

  • Comment removed

  • @daeheadshot this checks if the database already has the username. $query = mysql_query("SELECT * FROM users WHERE username='$username'"); //queries database for usernames $numrow = mysql_num_rows($query); if ($numrow!=0) { // if rows are not empty while ($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; } //check to see if matched to any user if ($username==$dbusername) { //if username is already stored in database die("Sorry. Username is already taken."); } }
  • With your help, I managed to get it all working, and even managed to add a Captcha image as well.

    Much appreciated, bro!

  • This is powerful stuff.

  • @rhoffer21

    I'm not talking about that part . Take the code you have done from this video and try and register and then create a password less than 6 characters. It will say you have been registered, and it will also say passwords must be between 6 ad 25 characters.

    The user is registered into the database even though they got an error while running the register script.

  • the register code doesn't work properly. fill in all the fields and input a password less than 6 and it will still register the user.

  • @ljk1181 That was addressed two tutorials ago, take a look at that one.

  • u actualy are the best, ever throught of becoming a lecturer?

  • still cant login D:

    it says incorrect password!

  • Hey, thanks for making the video.

    Mine's working, it registers a user and says 'you're in Click here to enter the member page.'

    However, when i click 'here' to enter, it says you must be logged in.

    tips?

  • @salrathor1 Session variables

  • When i use md5($password) it says incorrect password and when i take it off it works but my varchar for password is set for 100 any help?

  • @iamjoseph951 he went thru that -.- watch the video again.

  • Comment removed

  • try this:

    if(isset($_POST["submit"]))

    {

    $fullname = strip_tags($_POST["fullname"])­;

    $username = strip_tags($_POST["username"])­;

    $password = strip_tags($_POST["password"])­;

    $repeatpassword = strip_tags($_POST["repeatpassw­ord"]);

    $date = date("Y-m-d");

    }

  • Always "Notice: Undefined index: submit in C:\xampp\htdocs\xampp\clyde\re­gister.php on line 4

    Notice: Undefined index: fullname in C:\xampp\htdocs\xampp\clyde\re­gister.php on line 6

    Notice: Undefined index: username in C:\xampp\htdocs\xampp\clyde\re­gister.php on line 7

    Notice: Undefined index: password in C:\xampp\htdocs\xampp\clyde\re­gister.php on line 8

    Notice: Undefined index: repeatpassword in C:\xampp\htdocs\xampp\clyde\re­gister.php on line 9" i get in register.php.why..but itis working

  • alex, I like how you sometimes make common mistakes that most of us will also make, it just helps the learning a lot when I am making mistakes and solving them. THANK YOU!

  • Is MD5 really safe??

    I mean, if an attacker gained access to your database, they can get the md5 hash, use an md5 decrypter or check a rainbow table and recover the password. Unless maybe you used a salted password.

  • md5 will be good in $_POST

  • I followed this series of tutorials exactly and until now I've had no problems. I have coded the same perfectly but no matter what I always get "Incorrect Password" when I attempted to login with my created account. Anyone else having this problem?

  • Thanks guys :)

  • wow I'm learning a lot from this than those stupid pdfs I download all the time

  • I keep getting a 'unexpected T_STRING'

    on this line: mysql_select_db("phplogin");

  • @FPSRecorder check above that line of code for things missing like semi-colons and unclosed speech marks :)

  • @FPSRecorder

    its because you have to use the single ' instead of double ".

  • @FPSRecorder

    you most likely forgot to put a ';' after the $connect line

  • Anything encrypted with md5 will ALWAYS a length of 32 characters!

    Always good to know =)

  • @gDoxe that means that more passwords can have the same md5 chiper..... :)))) so md5 isn't good for password encryption .. lol

  • @AlexGuerrero007 Well, yes, but... you got 36 characters (a-z and 0-9) to mix freely on 32 spots in the md5 string, that means the amount of combinations = 32^36 which is equal to 6.33402867 × 10^49 different combinations, which is: 63 340 286 700 000 000 000 000 000 000 000 000 000 000 000 000 000 different combinations, so i'd say ur fairly safe with md5 ;)

    Im quite sure my math is correct =>

  • all done really nice tutorial. do we have any anything in reverse for md5 or we are secure here.

  • nice tutorials .. thanx a lot for uploading..

  • One question, would this I've learned be safe to the outside world? (sql injections and stuff like that)

  • I followed all of your tutorials up to and including this one and I've had no problems yet, great tutorials by the way! but I have now run into a problem. I changed the length of characters in phpmyadmin for the db to 100 and added md5( to the password part in the login. When I sign in it says you've logged in successfully, click here to continue to your account. But when I'm on the account page, it says please login to your account. What have I done wrong for that to happen.

  • THANK YOU! Your tutorials are the best! I am a student and without your tutorials i'd have a hard time at school! Thank you very much! Respect!

    p.s: I cant find a tutorial on how to use javascript in php. Is it possible? Like when you echo succes could javascript alert box opened and write success or avtomatic redirect back to index page? Tnx.

  • @sabalmoza Javascript is possible in php yes. It's all about the order you put it in. Go to w3schools com and they will definately help with any problems you may be having with that.

  • done everything and everything seems to be working fine except it only say im registered but nothing is stored on my database

    i already did all the corrections below but it is still not working ..pls help :(

  • very good tutorial. thanks.

  • Email Verification and Captcha.

  • fast easy learning! :D subscribed and rated

  • Hey. Good day to you. I have a problem with regards to registering users. When i click register, following notices appears. Notice: Undefined index: submit in Notice: Undefined index: fullname in Notice: Undefined index: username in Notice: Undefined index: password in Notice: Undefined index: password in All files in mylocal. Hope you can, teach me how to resolve it. many thanks codec
  • @codecbreaker i guess the problem is because you are defining the variables like $username and $password before checking if the register button is pressed.

    Try including the variables inside the check. eg :

    if($_POST['submit'])

    { $username=$_POST['username']; $password=$_POST['password'];

    }

    This worked for me!

    Hope it works for u too.

    happy diwali!

    cheers

  • Will be great if u make those in mp3 audio format so people can listen and understand the php basics.

  • i can watch these tuts all day...thanks man

  • thank you very much for your tutorial helped me

  • how do you un-encrypt the password :P

  • The field length in the db was the bug. Very tricky. Good to know. Thanks

  • For whatever reason when I try to insert into my db it doesn't insert the info.

    I changed my pw to hold a length of 32 and still had problems so I put a "or die(mysql_error());" after my mysql_query function and got this as an error:

    Incorrect integer value: '' for column 'ID' at row 1

    any ideas to why this is?

    Here is my query:

    mysql_query("

    INSERT INTO users VALUES ('','$firstName','$lastName','­$username','$password','$email­','$date')

    ") or die(mysql_error());

    Thanks a lot.

  • @brEws0 I figured out my problem apparently windows versions of phpmyadmin have bugs so the fix is rejecting the ID field completely in your query but you have to specify which fields you want to insert into the db eg.

    INSERT INTO users (fullname, username, password, date) VALUES ('$fullname','­$username','$pa­ssword','$email­','$date')");

    (fullname, username, password, date) comes directly from the fields in my db the auto_increment handles setting the ID.

  • @brEws0 still the problem isnt solve :/

  • Ur the Best... imo subscribe...........

  • omg i get this error , Parse error: syntax error, unexpected '}'

  • Comment removed

  • Hey Alex, I keep getting a user login error i followed the code exactly. If I I login using the md5 password its fine but cant login normally. thanks!

  • @RSkwiat I have this same exact problem, did you get it resolved?

  • thank you very much! I had some problems but it worked perfectly!

  • Why do I get this error? "Incorrect integer value: '' for column 'ID' at row 1" This is when I register a new user. It doesn't get added to the db.

  • great tut....

    thanx...

  • thanks man, it was really good you helped me keep it up bro

  • to fix the md5 probelm. another way you can do it is on ur login.php file u have if ($username&&$password). Change it to if ($username&&md5($password)) while u still have the md5($password)==$dbpassword. Problem sloved without the hassel of increasing the password value :)

  • @garky247 thats exactly what he did......

  • Can you please expand on this by having it so that after a registered user logs in they are taken to a page that is specific to them? I am a teacher and I want to add something like this to my class site so that I can actually leave my students secure comments and links and things on their "User Page" that shows up only to them after they've logged in with their information. Thanks for any help you can give! God bless!

  • Hey man i love you... finally something that really works... congratulations...

  • I get this error when I navigate to the register page that I created using your code on the Register tutorial you did. On that line is a die message saying that you have successfully registered.

    Parse error: syntax error, unexpected T_EXIT in C:\Xampp\xampp\htdocs\phpacade­my\register.php on line 45

  • I still had errors after making the password match the md5 DB password.

    What I did to fix this was in $query change $password to md5($password).

  • why does my page apears blank ( register.php ) ? NEED HELP!

  • @GDamnGuy DEAR CHEK YOUR PAGE REFERENCE THEN APPLY THE CHECKS ON EACH VARIABLE WHICH YOU MAKE TO STORE THE VALUES LIKE _POSTED VALUES AND DATABASE CONNECTION AND ALSO APLY CHECK ON QUERY RETRIVEL THEN SEE WHAT HAPPEN

    FOR ANY HELP CONTACT TALIB_NAZ@YAHOO.COM

  • @GDamnGuy Theres most likely a error in your coded... Look for missin

    "[,],(,),{,} and ;"

    If you miss some it may resoult in your error

  • I can also cr8 multiple account with the same ID

  • I have adjusted the password field to 200 chars, still no joy, I can register but when I go to log in the password error still comes up

  • @dashbyictfd have managed to solve it now

  • Alex, I dont know whether this is just my problem or a general problem with the user login, I have set my username as the PK in MySQL as you dont want two users with same usernames, however if i register under 1 username then register under different name but use the same username the form says I am registered but the user does not appear in the database, can you shed any light on this?

    Thanks

  • Alex, any chance you can add an email field to this form with all the error checking for an email address format being entered?

  • you rock, dewd. i'm learning with your tutorials....they are great and useful ! but, you are in a hurry, so take it eazy.... let us time for looking and doing :)

  • Everything other than the password is working for me. It only registers "password" as the password and will not accept any other values. Looking at your code i can't notice any differences. :s

  • Hi, thanks so much for the great tutorials! Do you have any tutorials that demonstrate use of classes? I understand the basics of classes but would like to see classes interacting with other classes and more practical examples. Thanks!

  • what would happen if the user forgot their password? how can the use retrieve it?

  • THANKS MAN! YOU SAVE MY DAY!

  • read somewhere that MD5 encryption needs a 32 character field to store the encrypted password, so defining your password field to VARCHAR with length=32 on your USER table should work

  • good stuff. I learned more from these tutorials (3 user login + 5 register) in a day or so ... than I would learn from lectures / notes / reference manuals in months. got all of this code to work! great teaching style.

  • yess we want to expand this tutorial! really help. uhm. i also want to know to edit or update and also to display the submitted data.. uhm. the other comment has a point. what if the username they enter is already taken. u know your tutorial is the best among all those i have searched. this really helps me on my studies. thank you so much!!!♥♥♥

  • it not works! It says always "password incorrect!"

  • for some reason when i try .php, it wants me to download a file

  • yeah, you have to put it up on a webserver, or a local server...

  • @movierobban you have to setup a webserver in order to work with .php files, google up xampp and download it and you should be set.

  • you're great man nice vid it helped me a lot

  • Thanks!! Nice tutorial!

  • Great!! THANKS!! and subbed..

  • Thanks a lot. I learned some really useful things from the registration tutorial such as keeping the form fields filled in, making sure the password field in the DB can accomodate the password hash, and submitting a form to the same page. Great stuff.

  • Very good tutorial!

    Thanks!

  • how do i make it so they cant use the same username as someone else??? did i miss that part somewhere???

  • He said it.

    $get = mysql code;

    while ($row = mysql_fetch_assoc($get))

    { $dbusername = $row['username'];

    }

    if ($dbusername = $username_who_the_user_wanted)  echo "That username is already taken.";

  • why didnt I just watch this first.... dang missing md5 - from first tut... :-)

  • Great!!!! Awesome!!!! Thank you Alex.

  • Great tutorials, man! Please, keep publishing new ones. Thanks for sharing.

  • vary good, tank you alex

  • A MD5 encryption is 32 chars .. :)

    No need to over-do-it

  • I did 50 to be safe and thought it would be slightly under it atleast, didn't want the password to be 100 characters to be honest.

  • I had initially set my db md5 to 32 - as alex had initially - though it caused same error as him...

    However, when i set to 100 like shown - it worked - - could you please explain more about what is behind this - ty

  • can we have an extra stage?

    when the user register,

    the admin need to approve it before the login can be use.

  • There is a email verification tutorial by him. I am sure you can edit it so that it will do what you want.