XML Login System
videos

Build a Login and Registration System with XML

Share

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.


Related Posts

Add Comment

Discussion 90 Comments

Comment Page 3 of 3 1 2 3
  1. Jon Lisbon says:

    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.

  2. Tim Cooper says:

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

  3. Marko says:

    Bravooooo! MORE! MORE!

  4. Yiannis says:

    i have problem to watch your video

  5. Jam says:

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

  6. Dan says:

    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

  7. Andrew says:

    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

  8. Tim Cooper says:

    @Dan:

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

  9. What a great video.. Keep them coming!

  10. bestamius says:

    What a nice article, thank’s very much!

  11. Carlos L says:

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

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

  13. Justin says:

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

  14. Benji Barash says:

    Awesome tut Tim!

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

    Thanks!

  15. Ramon says:

    Gonna remake it to MySQL :)

  16. ALEX18 says:

    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.

  17. organicIT says:

    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

  18. Zvonko says:

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

    • David says:

      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.

  19. Harman says:

    How do u post it on a website?

  20. kantslowdown says:

    this is great…thank you!

  21. DekuLink says:

    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.

  22. Travis says:

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

  23. Interesting screencast. Thanks.

  24. bhawani says:

    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

  25. ahmad says:

    Hey ! your too fast man ! I love that !

    Bookmarked this website ! will always come here

    keep going people ! love that

  26. David says:

    Very Very Nice!!!

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

  27. e11world says:

    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

  28. AnnaMarie says:

    Your Message…

  29. John says:

    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.

  30. Rob says:

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

  31. Deepak says:

    Hi,

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

  32. wildo says:

    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 !

  33. imran14826 says:

    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

  34. Jason says:

    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.

  35. bluehaus says:

    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!

Comment Page 2 of 2 1 2

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.