timtam88 Posted September 30, 2014 Share Posted September 30, 2014 Can anyone explain how i can create a registration and login page using PHP that doesnt use databases, sessions, or cookies? Is there a tutorial someone can point me to or could anyone tell me the method. Thanks first time php coder Quote Link to comment Share on other sites More sharing options...
Frank_b Posted September 30, 2014 Share Posted September 30, 2014 a login without sessions is not really posible. Unless you want to use it for only one page. You don't have to use cookies yourself but sessions will store a cookie on the clients computer. a registration page means that you will have to deal with a dynamic number of users with all different names an emailaddresses etc.. You will need to store that data somewhere. A database is most common but store your data into a file is also possible. Quote Link to comment Share on other sites More sharing options...
timtam88 Posted September 30, 2014 Author Share Posted September 30, 2014 a login without sessions is not really posible. Unless you want to use it for only one page. You don't have to use cookies yourself but sessions will store a cookie on the clients computer. a registration page means that you will have to deal with a dynamic number of users with all different names an emailaddresses etc.. You will need to store that data somewhere. A database is most common but store your data into a file is also possible. you see thats the problem im running into im trying to do it for my class but i have to follow certain guidelines. Would you mind looking at the assignment for me? im not asking you to do it i just want to know if you could understand fully what my professor is asking us to do and what method i should go about doing it( i would ask him to explain but its an online course and its been 12 hours since i asked) its a google presentation https://docs.google.com/presentation/d/1_vjLMhxMPToGR8E937ZHIF7X9YmU680AK5IZcR4B9J0/pub?start=false&loop=false&delayms=3000#slide=id.p Quote Link to comment Share on other sites More sharing options...
ginerjm Posted October 1, 2014 Share Posted October 1, 2014 (edited) Your first time coding php and your professor wants you to do this kind of thing with those restrictions? Interesting. What was the topic of the day when he made that assignment? In order to have a login your app has to have some 'continuity' to it and we know that the web doesn't provide that kind of conversational activity without using one of the 3 things you have been instructed not to use. Sounds like an impossible assignment to me. I suppose you could use a text file stored in a folder outside the web tree, but that is just silly from a teaching standpoint. Maybe he is teaching in 'baby steps' ? The only way I see to accomplish this lesson is to use a text file which you write a function to open it, read thru it, and look for the user-supplied credentials from your form. If found then they are logged in; if not then no. And for new registrations, you have to add the ability to add a line at the end of the file. Edited October 1, 2014 by ginerjm Quote Link to comment Share on other sites More sharing options...
LeJack Posted October 1, 2014 Share Posted October 1, 2014 Yeah I would have to go with Frank_b and ginerjm on this. It is nearly impossible to have a login system without any type of database to it. Although it does say no cookies or database, you can always use sessions if they didn't say you can't use it. Like Frank_b and ginerjm said, you could use a text file to store these user datas. Normally, I'd suggest .csv files. .txt files aren't normally used for these things. .csv files are more easier when it comes to editing them via a file editor. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted October 1, 2014 Share Posted October 1, 2014 LeJack - re-read the OP opening statement. It's pretty clear on what is taboo. As for my suggestion to use a 'text' file - a text file is just that - text. Whether it has commas, pipes, tabs or whatever in it doesn't change what it is - a poor-man's db and should only be used as a last resort. Quote Link to comment Share on other sites More sharing options...
Frank_b Posted October 1, 2014 Share Posted October 1, 2014 (edited) Ok, "No database or cookies are required". "All data should be passed from form to form" Tells me that it is not forbidden to use a database OR cookies :-) What hurts me is that they want us to pass all data from form to form which is a very big security hole. It means that we have to include a query string on every link that we write to help us remember who is logged in. To make it a bit more secure we use the password and username scrambled into the query string. eg: http://mysite.org/profile.php?sid=hfqe0weyr40faqew0runqrvfda I think i should make a login WITH database OR file storage. And i should use all the guidlines for the sign-up and profile pages. I asume that you know how to maken a form in HTML. Start with that part: I think this is what you have to make first: - an index page with links to the other pages like the profile page - a login form - a profile page (later it will be after the login) -a edit-your-profile page (later it will be after the login) - a add-user page (later it will be after the login) i ll send you a private message later. Edited October 1, 2014 by Frank_b Quote Link to comment Share on other sites More sharing options...
ginerjm Posted October 1, 2014 Share Posted October 1, 2014 Has this topic been hijacked by Frank_b or are things transpiring that the rest of the forum are not privy to? Quote Link to comment Share on other sites More sharing options...
Frank_b Posted October 1, 2014 Share Posted October 1, 2014 Hi mr 'Advanced Member', i am just willing to help somebody and i am sorry if you don't like it. And maybe the topic starter will still like to communicate on this forum. :-) Quote Link to comment Share on other sites More sharing options...
Frank_b Posted October 1, 2014 Share Posted October 1, 2014 (edited) I made a begin on a manner how you could do this. You should only use it for learning. Write your own code! Dig everything out until you understand how it works! unpack the zip in the document root or a higher directory on your webserver. Then browse to the setup.php file if you don't get errors then setup ended successfully. You have two users: Frank with password 1234 Newbee with password 0000 No sessions, cookies or database is used. Users are stored in a file in a directory with the name private which will not be accessible from the web. The file format is JSON plaintext. I've added comments in the code. For any questions you can leave a message here. Success. login.zip Edited October 1, 2014 by Frank_b Quote Link to comment Share on other sites More sharing options...
timtam88 Posted October 1, 2014 Author Share Posted October 1, 2014 I made a begin on a manner how you could do this. You should only use it for learning. Write your own code! Dig everything out until you understand how it works! unpack the zip in the document root or a higher directory on your webserver. Then browse to the setup.php file if you don't get errors then setup ended successfully. You have two users: Frank with password 1234 Newbee with password 0000 No sessions, cookies or database is used. Users are stored in a file in a directory with the name private which will not be accessible from the web. The file format is JSON plaintext. I've added comments in the code. For any questions you can leave a message here. Success. thanks i greatly appreciate this....now i can actually understand the basic steps of how to approach this project.....thanks a tonne 1 Quote Link to comment Share on other sites More sharing options...
timtam88 Posted October 2, 2014 Author Share Posted October 2, 2014 (edited) I made a begin on a manner how you could do this. You should only use it for learning. Write your own code! Dig everything out until you understand how it works! unpack the zip in the document root or a higher directory on your webserver. Then browse to the setup.php file if you don't get errors then setup ended successfully. You have two users: Frank with password 1234 Newbee with password 0000 No sessions, cookies or database is used. Users are stored in a file in a directory with the name private which will not be accessible from the web. The file format is JSON plaintext. I've added comments in the code. For any questions you can leave a message here. Success. thanks so far, Im trying to follow the directs but i think you had left the .json file out of the zip or am i missing something.......with that said im not sure i really understand how you are saying to arrange the files for them to work Edited October 2, 2014 by timtam88 Quote Link to comment Share on other sites More sharing options...
Frank_b Posted October 2, 2014 Share Posted October 2, 2014 (edited) Hi timtam, When you run setup.php it will create the the json file in the /private directory. after setup you should have this: |----[private] | | | |---- .htaccess | |---- users.json | |---- users.php | | |---- index.php |---- login.php |---- logout.php |---- members.php |---- setup.php Edited October 2, 2014 by Frank_b Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.