473,383 Members | 1,837 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Making Login Library... Want some opinions

Samishii23
246 100+
I know this isn't REALLY a question, but I also don't want to go to the PM area of the website and start sending random messages to members marked "Experts"...

I have been developing a Login Class library that i'll mostly use for my own projects, and because I want the experience. I haven't quite tested it out yet, though at the moment there are no run time errors. :P

But what I really would like is opinions of my code, insights about it. Maybe something should be done another way. Or w/e. Or features that could / should be added.

I'm eager to learn, and I would love some feedback on whether or not the code is good / bad.
Attached Files
File Type: txt Lib.Login.php.txt (19.9 KB, 535 views)
Aug 10 '10 #1
8 1375
dlite922
1,584 Expert 1GB
In my opinion, in your attempt to make this robust, you have forgotten the true meaning of OOP (classes and object). For example in a true OOP application logging would be assigned to a class of its own.

Also, with MVC architectures, you never, never...ever!...have HTML in your classes.

This looks like a class that really unique to your application. It's not generalized enough for use as the "free license" declaration in the header implies.

You should use mysqli prepare statements.

Final note: you should try using phpdoc-style comments/documentation. It's more standard and thus easier for a lot of other developers to read.

I didn't really review your logic or try to parse your code and look for security holes/hacks, so don't know if it's bullet proof.

Good first attempt! You'll only get better and better over time.

Cheers,

Dan
Aug 11 '10 #2
Samishii23
246 100+
Thanks for the opinion!

I would hope I get better over time, seeing as I've been doing PHP / MySQL / HTML in my spare time for almost 7 years now. lol.

I recently got into the whole OOP when I was teaching myself C#, though as you said, I don't seem to know what I'm doing for that.

As for MVC Architectures. Never heard of them.

Guess its back to the drawing board, and doing some research.

Thanks again
Aug 12 '10 #3
TheServant
1,168 Expert 1GB
MVC is simply Model View Controller. It's one of the most accepted ways to separate your display and business logic.

I don't think it's back to the drawing board if it works. But in a revision you can rewrite it in a different structure (like MVC) which will make it easier to maintain, read, edit, share etc...

It is very difficult to make any code which can be used by anyone for a host of applications and is not too specific in the need/problem it addresses.

Best thing (as you said you were going to do) is use it for your applications at first and document any features you would like it to do and update it. Then if you ever put it online for others to use, you can field their suggestions in the same way.
Aug 12 '10 #4
Dormilich
8,658 Expert Mod 8TB
You should use mysqli prepare statements.
… or PDO prepared statements (which IMO have the advantage that you can use all fetch modes (while MySQLi prepared statements only support one fetch mode))
Aug 12 '10 #5
Samishii23
246 100+
@Dormilich, as I have only today begun looking into this type of queries, I think MySQLi would be a good starting point, and once I am accustomed with preparing statements, then I can move on to PDO.
Thank you for the reference. :)
Aug 13 '10 #6
Dormilich
8,658 Expert Mod 8TB
one more appetizer for PDO: you can use the prepared statement directly in foreach().
Expand|Select|Wrap|Line Numbers
  1. $ps = $pdo->prepare(…);
  2. $ps->bindValue(…);
  3. $ps->execute();
  4.  
  5. foreach ($ps as $row)
  6. {
  7. // do something with $row
  8. }
Aug 13 '10 #7
Samishii23
246 100+
@Dormilich, could I do the same thing with MySQLi? or is that PDO alone? I was wondering cause I've seen mysql->bind_results(); come up alot in my readings.
If I did not have to do the bind call, could I just do that foreach statement? Or is that only after something like a fetch_assoc() call or something?
Aug 14 '10 #8
Dormilich
8,658 Expert Mod 8TB
you cannot directly use the MySQLi_Result or MySQLi_STMT classes in foreach() (compare it to DOMDocument (MySQLi) vs. SimpleXML (PDO)). however, if you do fetch_all() (not usable with prepared statements) you can loop over the resulting array. bind_result() only assigns variables to the (individual) results of the fetch operation (you still have to explicitly call fetch()* in a while() loop) so that you don’t have to work with a result/row array. what you cannot achieve is fetching results from a prepared statement into a class, as is possible in PDO.

in short, MySQLi requires explicit fetching. PDO not.

the only way around that is a custom DB class implementing either the Iterator or IteratorAggregate interface.

* - fetch() is the only method to get the results of a mysqli prepared statement!
Aug 15 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tlo | last post by:
hello, i would like to develop a simple but (quite) secure auth/login library in php, just to know about users on a website (no use for http or ..htaccess). i'm wondering if this is best done...
1
by: John Davis | last post by:
I put a little login (username and password textfields) in a web page, and once the user able to login, I want the username and password textfields will disappear, and replace with text " has...
2
by: Jim Corey | last post by:
We're looking at logging on to SQLServer using Windows Authentication from an ASP app, and trying to figure out what will work. The following connection string works with Basic Authentication:...
11
by: Peter CCH | last post by:
I have a database with 2 users - 'dbo' and 'user1'. Currently: => 'dbo' is tied to login - 'login1' => 'user1' is not tied to any login. I want to change the login tied to the database users...
7
by: redneon | last post by:
Does anyone have any good links to information on how it's possible to make a library in C++? I can't seem to find anything.
7
by: sumi | last post by:
Hi, from my login i want to login as a other user , how can i do it using python.
7
by: savvy | last post by:
I able to redirect the user to the index.aspx page after every successful login, but I dont want certain pages outside the folder to have a access to general public. So if they click that...
1
by: Steve Le Monnier | last post by:
Using C# I've created a code library of useful functions I use regularly in ..NET projects. I know if you want to make a DLL available to COM clients, you have to include an interface and guid...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
1
Exile
by: Exile | last post by:
Can you help me in making my System? Can you send me a Step by Step data that will make my Library System! Thanks!!!
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.