MySQL Database - Basic PHP Login System Part 2

preview_player
Показать описание
This short tutorial series shows you how to create a very basic login functionality, that you can add to your websites. In this second video I show you how to create a MySQL database, connect to it and how to retrieve information from it. Over the series I will add more to the system including password security and will probably finishing up by using it to create a simple blog.

Комментарии
Автор

Finally a tutorial that isn't missing parts and skipping things. I have been looking for ages for a good tut like this
Nice job.

unicycle
Автор

Hey man, really awesome tutorials. You're very clear and go through things at a good speed. Please do put the next tutorial up about security, if you get the chance.

johnstanley
Автор

Great tutorial, very in depth, thank you very much. Just one thing, it might be useful to do a tutorial for populating the database as you would first have to sign up and have that information stored before it could be queried, this tutorial assumes you will have a value in the database to be queried. Also very much looking forward to your next tutorial :)

jasonrobinson
Автор

This was a big help Peter.  It got me off to a good start!  One criticism though:  There are some who have not done much coding.  It would have been a good idea to explain that they have to compare what the user entered against what comes back from the db.  I noticed the if/then/else statement in your video,
if ($usname == $dbusename && $paswd == $dbpassword)
but you didn't really explain it.  It seems like a "common sense" thing, but I noticed the comment below from a user who said "...regardless if i insert credentials or not it proceeds to the user webpage...." and that's probably what lost him.  Otherwise, good video!  Works great and I REALLY needed the logic and principles on how to write this code!  THANKS AGAIN! "No", I've never touched php before 3 weeks ago!  :-)

EDPhoto
Автор

For plain simple php and html I find Notepad ++ is brilliant for coding. It may not read the code the same but hey its free!

BurningchatTkhome
Автор

I found out what the problem is for most people! make sure you change 'members' to what your table name is!
$sql = "SELECT id, username, password FROM members WHERE username = '$usname' AND activated = '1' LIMIT 1";

waffleboi
Автор

I followed this tutorial exactly, and copied and pasted the code correctly too, and whenever i try login using the login information i created in the table in the database it keeps coming up that the username or password combination was wrong?

kTwinsk
Автор

lol i play your videos on 1.25 speed because you talk a bit slow

DerkJanSpeelman
Автор

thanks for this nice tutorial..i want to create a page like example: 1st page login..there will be an option to sign up..without sign up..you cant login..cause there is no database inputed..ok first im gonna click sign up then register the info to database...so my usname and pswd are included in database..then im gonna login..after that a new session generated in which i will create an student form..the fields are name, fname, Roll, Sub ..english, math, science etc...now if the user input those info and the number then the i can see the results in web page also the name subject number are inserted by mysqli_con in the database..i think i need to join and create multiple databases...please give a tutorial in this?

solaymanpritom
Автор

I'm pretty sure I do exactly as you do in the tutorial, but when I try to test it in the Simple Php Login, it doesn't tell me either if the login was right or wrong, it just transfers me to the page where it says XXAMP was succesfully installed on the pc. Can you contact me?

nikolajdeichmann
Автор

Hey, Guys! I narrowed down the problem.

The reason why this isnt working is because the OP (owner of vid) is reading the tables correctly, and finding the username/passwords successfully but isn't comparing them correctly to the user input. Basically this is what is going on.


what you are doing :

Your Table =  (User - Test), (Pass - TestPass).

User Input = (User - Test), (Pass - TestPass).

whats actually happeneing :

Your Table = (User - Test), (Pass - TestPass).

User Input = (User - Gibberish!), (Pass - Gibberish).

so when trying to compare the two in this line of code : 

if ($usname == $dbUsname && $paswd == $dbPassword) {

this is what the code is really saying : 

acronym GPBS = GibberishProducedByScript

if(GPBS == UserNameInTable && GPBS == PasswordInTable) {

Than continue your script

}

For some reason, the script is messing up the string that you type in, in the boxes. I don't know why. :L OP Please fix this now. 

nickkunes
Автор

I followed the code exactly, and my server had problems with mysqli_fetch_row. The PHP server said that that it kept getting a string but was expecting a query. What could be the problem?

frejumuh
Автор

How I fixed my problem :
1. check if the database table names have been all spelled right,
2. check if the MD5 password in database is in lowercase

shupu
Автор

im a starter
and i heard u say u will put database on a server
how to do that

pavlelakicevic
Автор

Is local host replaceable with an ip instead of a domain?

levibazen
Автор

hi. I get an error like this when I go to index.PHP. Parse error: syntax error, unexpected '$usname' (T_VARIABLE) in

gigabytebear
Автор

OKAY, apologies for the long post below, this is the fix to this code.

Remove This Line From Index.PHP -

$paswd = md5($paswd); // using md5 just for testing purposes

nickkunes
Автор

What program are you using to edit the code?

hstRydr
Автор

It works on my localserver but any idea why it wont work on my hosted server? 
it wont redirect to the user.php when i submit the login form? 

ahano
visit shbcf.ru