Building an entire membership system can be a tedious, and time-consuming task. Tim Cooper is going to show us how to build the ENTIRE thing in roughly thirty minutes. Rather than using MYSQL as our database, Tim will instead demonstrate an alternate approach: using an XML file. We’ll be reviewing PHP, .htaccess files, sessions, and more!
- Subscribe to the NETTUTS RSS Feed for more daily web development tuts and articles.


PHP developers – stop making the world worse with your terrible language. Stop reinventing the wheel by making yet another user registration system. Stop catering to newbie developers who don’t know any better because they don’t have enough experience to know to stay well clear of PHP. Stop using MD5; it’s been shown to be cryptographically weak. Stop trying to be clever by not using a database.
I bet the average age of the readers here is about 20 and 98% of them use Windows, and have no formal training in computer science.
This is like some weird developer honeypot.
wtf? r u maybe an oldie who remembers the fortran and stuff? Like lets code assembler on comodorre 64? U have issues with yourself. Dont just say your opinion, this tut is totally different from your view and opinion. U dont have to comment anyways.
Haha i am 15 years old :)
and me too read this :D
I am 20, If you don’t like this tutorial then don’t read it. The web is a playground. We build what we want. Its people like you pushing for SOPA.
@Reader: The only cookie PHP sets is one to hold the session id. It alone does not hold any data that you can edit, such as the username being used.
How ever, I did not go into how to prevent session hijacking, which is a whole lesson altogether.
Bravooooo! MORE! MORE!
i have problem to watch your video
Though MySQL is obviously more secure, this would work well for a user system with data of little importance. That being said, this is quite a useful tutorial. Thanks. :)
Are you testing this locally on your machine? if so, what are you using?
when my test try to run the asXML function i see the following error:
“SimpleXMLElement::asXML(users/new.xml) [simplexmlelement.asxml]: failed to open stream: Permission denied”
Dan
You will need to set permissions to 777.
Could someone please tell me how to make line brakes after each user registration ?
Atm it writes all in one line xxxxxx
So after each new xxxx need a new line brake!
Thanks
@Dan:
You’ll have to chmod your users folder to something that will allow your web server access to it.
What a great video.. Keep them coming!
What a nice article, thank’s very much!
@Tim Cooper:
How do you chmod [whatever]?
I had these errors:
Warning: SimpleXMLElement::asXML(users/juddcarlos.xml) [simplexmlelement.asxml]: failed to open stream: Permission denied in /Library/WebServer/Documents/register.php on line 28
Warning: Cannot modify header information – headers already sent by (output started at /Library/WebServer/Documents/register.php:28) in /Library/WebServer/Documents/register.php on line 29
Thanks! (And thanks to the OP!)
Your Message…
please visit my site for demo
http://www.yougroup.in/manish/site_3
I agree this wouldn’t be the best for users and passwords, but everyone please understand that in simpler terms this is a great jump for beginners into XML using PHP, someone could use this to sort their CD collection or movies. Besides, why get an entire mySQL db for something that can be done with a single file? Nice quick tutorial Tim, people should think of the other applications of this tutorial before bashing on it.
Good job. Easy to follow and very organized source.
Thanks for the help.
Awesome tut Tim!
Interesting variant on the regular use of MySQL for login/register systems :)
Thanks!
Gonna remake it to MySQL :)
HI i’m alex.
First i want to say that ….man! y are fast and VERRY PRO.
Now i would like to ask something.
i add this mootools slide llogin tool in my website 2 screenshots, avablle.
Screen Shot1 – http://img14.imageshack.us/img14/1371/screengcm.jpg
–
ScreenShot 2 – http://img14.imageshack.us/img14/9411/18492524.jpg
__________________________________
Now how cann i make it work?….i saw this tutorial is realy good and its the first that i rally founded. but i would like to make this to work …..how?
PLEASE if someone whos a good codeing…designer…..,please help it’s my first template …and i;m using Dreamwaver cs4.
PLease take a moment from y;re live and help me.
i dont what tolet this unfinished cuz i payd alots of mony on Adobe Master.
TNX
My emails and Messanger.
jamaika_rnb@yahoo.com
18alx@live.com
—
THIS IS THE BEST designing and helping on the hole google zone that i found.
Tim,
This TUT was outstanding. I am sure you meant for this to be only demonstration for XML interactivity and not for real world production use. Heck, you could have even mentioned it but we missed it you were so fast ; )
Anyway you have a long prosperous career ahead of you. Good Job
Your Message…
Great tut, but I would worry about security. Anybody could see your XML files and thus see username/passwords.
Hey, I had the same thought when he first did that, but, as u could see in the video he added a .htaccess file saying deny from all, and he showed it could not be seen. But I still think that it can be breached though. I’ll try to figure out a way, and try to get back on that.
How do u post it on a website?
this is great…thank you!
Wow! Great tutorial. Lots of stuff to learn in this. Great for simple scripts like a news script where you only expect you or two people to use it.
@Tim
Works on my local machine, when I login and test it on a live server I receive this fatal error:
“Fatal error: Cannot instantiate non-existent class: simplexmlelement in login.php on line 7″
Line 7 is :
“$xml = new SimpleXMLElement(‘users/’ . $username . ‘.xml’, 0, true);”
Thanks!
Interesting screencast. Thanks.
i am getting problem while registration
Fatal error: Call to undefined method SimpleXMLElement::addChild() in E:\demoprojects\xml_user_system\register.php on line 26
Hey ! your too fast man ! I love that !
Bookmarked this website ! will always come here
keep going people ! love that
Very Very Nice!!!
Very well explained, I understood so much in your video, and you speed is amazing.
Tim, you are the man. PHP is the way to go and this was a very nice, fast, “and detailed” tutorial. I think everyone who’s talking about security and other things should thank him for his time and effort into this instead of trying to make this sound incomplete. He obviously could’ve done this in many better ways (including using a database) but wanted to show everyone another solution.
Great Job Tim! Thank you
Your Message…
Your Message…
Firstly. let me say thanks.
I just used this for a client.
The client wants me to make it so that more fields (name, company name, telephone number) are added to the registration page and then he wants this info to be emailed to the client and to himself.
Could you please show me how I would do this?
Thanks again. Great website. Great tutorials.
Ooohhhh very nice. I will definitely use this. Maybe not for user management but for user content like profiles, etc… Excellent, thank you.
Hi,
How secure is it 2 use xml logIn in place of ASP.net logIn process.
what would prefer.
hi man..thanks for the ttutorial, but have a problem.
Fatal error: Call to undefined function file_exist() in C:\wamp\www\login_test\login3.php on line 6
the code:
thanks !
Works on my local machine, when I login and test it on a live server I receive this fatal error:
“Fatal error: Cannot instantiate non-existent class: simplexmlelement in login.php on line 7″
Line 7 is :
“$xml = new SimpleXMLElement(‘users/’ . $username . ‘.xml’, 0, true);”
Thanks!
14826
http://www.livetv.pk
Hi Tim,
Thank you very much for this. I love it!
I am having one tiny problem t hough.
The registration works (I think), but everytime I try to login, even with the test details provided, or just after registering, it always says “Invaid username or password.” and I can’t figure it out. Can you please help me with this?
Thank you very much!
Jason.
Awesome work! I’ve used this on a site and it works beautifully! However, the client has now requested a basic CMS system so I’m moving it over to a WordPress base. I’m wondering how this could integrate into WordPress 3? I’m new to WP and this non-profit organization has a members section that’s only a page or two with member info and file downloads. Obviously I need these pages protected and not available to the public. Any ideas on how I could incorporate this method into a WordPress site, if at all?
Any suggestions or guidance would be greatly appreciated.
Thanks in advance!
i copied your source after trying myself to recreate your login system
when i use the registration system it does not make a new file to log in
in the iis server i have enabled writing files
any help please?
mertz3hack@live.com
@Jon Lisbon, thanks men for this great info.. even though the i’ve seen the video was great. But I’m still a newbie here i cannot judge whats right about your comment and the video.. But I will read some notes of what you just said…. Your great and the video as well. Thanks for the post!
I really liked this enjoy thanks.
This is a brilliant tutorial and was extremely useful as a crash course into both PHP and XML. Thankyou and keep up the work
Found it really useful. Is there any way to get hold of the single user file variation? The link posted earlier in the comments is dead!
Thanks!
This is great stuff…be great to see what you can do when you’ve grown up ;-)
Hi guys
when ive logged in once as a test user i can see my page which is good then if i click logout it takes me back to the login page but if i just refresh the main url then it goes back to the logged in page? ive got login page set as index.php which links to elearnmenu.php
is it storing a cookie as it doesnt do this when i delete all the cookie son my system. How can i prevent this from happening?
thanks