XML Login System
videos

Build a Login and Registration System with XML

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.


Tags: Videos
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://arnolem.developpez.com Arnaud LEMERCIER

    It’s a very good vidéo but two user with the same name was not possible

  • http://www.mykoala.com Andres F

    Tim, that was very impressive. Thanks!

  • Pingback: AndySowards.com :: Web Development Nerdy Daily Links For 2/13/2009 | AndySowards.com :: Professional Web Design, Development, Programming, Hacks, Downloads, Math and being a Web 2.0 Hipster?

  • Jon Lisbon

    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.

    • http://www.tajfa.com Iki

      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.

    • duli

      Haha i am 15 years old :)
      and me too read this :D

    • http://vivalavisca.tk Jose

      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.

  • http://techietim.ca/ Tim Cooper
    Author

    @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.

  • Marko

    Bravooooo! MORE! MORE!

  • Yiannis

    i have problem to watch your video

  • Pingback: NETTUTS.com: Build a Login and Registration System with XML | pcsourcenetwork.com

  • Jam

    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. :)

  • Dan

    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

    • Dartz

      You will need to set permissions to 777.

  • Andrew

    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

  • http://techietim.ca/ Tim Cooper
    Author

    @Dan:

    You’ll have to chmod your users folder to something that will allow your web server access to it.

  • Pingback: Login-Script mit Session - Probleme nach Logout mit der Browser-History - Seite 2 - php.de

  • Pingback: PHP and XML

  • http://idt.karalekian.com/ iDevelopThings

    What a great video.. Keep them coming!

  • bestamius

    What a nice article, thank’s very much!

  • http://carlosloeza.com Carlos L

    @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!)

  • http://onlineovernightpharmacy.com/ opnlnvrn

    Your Message…

  • UGr

    please visit my site for demo
    http://www.yougroup.in/manish/site_3

  • http://www.webtwosolutions.com Brian Barnett

    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.

  • http://justinledelson.com Justin

    Good job. Easy to follow and very organized source.
    Thanks for the help.

  • http://www.bbarash.co.uk Benji Barash

    Awesome tut Tim!

    Interesting variant on the regular use of MySQL for login/register systems :)

    Thanks!

  • http://ramon.com.ua Ramon

    Gonna remake it to MySQL :)

  • Pingback: Blah! » Blog Archive » Build a Login and Registration System with XML - NETTUTS

  • ALEX18

    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.

  • Pingback: A Better Login System - Nettuts+

  • http://www.spionsystems.com organicIT

    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

  • http://wmvtoavi.net convertman

    Your Message…

  • http://www.it-sense.net Zvonko

    Great tut, but I would worry about security. Anybody could see your XML files and thus see username/passwords.

    • David

      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.

  • Harman

    How do u post it on a website?

  • kantslowdown

    this is great…thank you!

  • http://www.portaltohyrule.com DekuLink

    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.

  • http://www.skydesignsolutions.com Travis

    @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!

  • http://sackclothstudios.com Alex Mansfield

    Interesting screencast. Thanks.

  • bhawani

    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

  • http://www.pikacho.com ahmad

    Hey ! your too fast man ! I love that !

    Bookmarked this website ! will always come here

    keep going people ! love that

  • David

    Very Very Nice!!!

    Very well explained, I understood so much in your video, and you speed is amazing.

  • http://www.e11world.com e11world

    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

  • AnnaMarie

    Your Message…

  • http://www.citizensasset.com/sitemap SophiaNirsam

    Your Message…

  • John

    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.

  • http://www.blueicestudios.com Rob

    Ooohhhh very nice. I will definitely use this. Maybe not for user management but for user content like profiles, etc… Excellent, thank you.

  • Pingback: How to create logon forms to websites?? - x10Hosting Community

  • Deepak

    Hi,

    How secure is it 2 use xml logIn in place of ASP.net logIn process.
    what would prefer.

  • Pingback: links for 2010-01-17 | James A. Arconati

  • Pingback: Just an ordinary blog

  • wildo

    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 !

  • http://www.livetv.pk imran14826

    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

  • http://coming_soon_hopefully/ Jason

    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.

  • http://ryanmayer.ca bluehaus

    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!