Contoh: Membuat program database sederhana dengan Microsoft Access. Bahasa generasi ke-4 disebut juga dengan Very High Level Language atau Problem Oriented Language (bahasa yang berorientasi pada masalah) karena memungkinkan pemakai menyelesaikan masalah dengan sedikit penulisan kode pemrograman dibandingkan dengan bahasa prosedural. Dec 29, 2012 - we're going to learn how to create a login & registration user system using OOP PHP. Login and Registration Using OOP with MySQLi.
Already covered quite a lot, so just a couple of points from me: Security: Login as any user Right now, an attacker does not need to know the password of a user to login, just the username. This is because of the precedence of and over. Your query is executed as: $sql='SELECT uid FROM users WHERE username='$emailusername' or (email = '$emailusername' and password='$password')'; But what you want is: $sql='SELECT uid FROM users WHERE (username='$emailusername' or email = '$emailusername') and password='$password'; Creating Database and Table Creating the database and tables should not be part of the database connection/configuration class.
You don't want this to execute on every connection, but just once when you set up your website. Create a separate setup script. This has the additional advantage of simplifying your dbConfig class. Right now, it stores the database configuration, connects to the database, and sets up tables (in addition to echoing and dying, which no class should do).
That's too much responsibility for one class, so it's good to extract code from it. Misc. try to use correct indentation, it makes your code a lot easier to read.
![]()
be consistent with your formatting (eg spacing before and after =, etc). use prepared statements instead of mysqlirealescapestring, as it's a lot easier to use correctly (no forgotten single quotes for numerical values, etc).
Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |