Jump to content

Some general questions regarding the use of databases


NoUser2U

Recommended Posts

Hi,I have some general questions which i stumbled up on while learning and practicing php and delving into MySQL. I thought the 'General'-subforum was the best place to place this topic in since i have 3 general questions (although the first question might lean more to PHP). I'm not asking specifically for the exact pieces of code for each question, but more of principles/ways of doing things (although simple and short examples wouldn't hurt :)).Question #1: Register/login system (this question is PHP-oriented) UPDATE: THIS QUESTION HAS BEEN SOLVED :)I created a basic register/login system, where firstname & lastname of the users gets stored in a .txt-file. With help, I managed to create the login-part, where the user-inputted data is compared to the values stored in the .txt-file and if matches are found, then login is succesfull (by simply echo-ing “Login complete”).Let’s say I have a site, consisting of 4 pages:Home.phpRegister.phpLogin.phpUserpage.php => (which is supposed to be restricted, unless a user is logged in)After setting the condition for a successful login, what is the next step to let the user gain and kéép access (until logged off) to the Userpage where he can see his/her registered information? Am I supposed to use cookies and/or sessions here?Question #2: Database & large blocks of text UPDATE: THIS ONE TOO :)I’m slowly stepping into the world of databases, and my current shortterm goal is to incorporate a MySQL-database in the above described login-system. I’ve already followed the w3schools tutorial regarding PHP/MySQL and that I understood.Now I was asking myself, let’s say (as I get better in PHP) I want to create a simple guestbook or forum or so. The text entered in those systems is usually much longer than a simple username, password, email etc. etc. which are stored in seperate cells of a table (in a database).When using large blocks of user-inputted text, should that ALSO go in a table which consists of rows/columns, the same way as simples usersnames, passwords and emails are stored in tables? Or is there a separate way for handling large blocks of text?Question #3: Server/Database and data other than textAfter reading the w3schools tutorial, I can manage to create a simple login-system with database and let PHP interact with that. But what about images, video-files, sound-files and other types of data or files? Should that be stored in a table (that is in a database) too? Or are data other then text supposed to be stored elsewhere?Much thnx in advance!

Link to comment
Share on other sites

1) session should use. St0ring access credintial in c0okie is n0t g0od idea. C0okie can be manipulated. It shoud n0t used for st0ring sesnitive data2) all query techniuqe are same. But you have to cho0se c0rrect data type f0r st0ring data. If you need l0ng tex there is TEXT, TINY TEXT,char, varchar depending on ur needs. You may search data type in mysql 0fficial site f0r m0re inf0. . .and limitati0ns f all data type.3) y0u cn st0re it in db or filesystem. If u st0re it in db y0u need to set data type as bl0b. Its depends on you which st0rage is suiting best for your situation.

Link to comment
Share on other sites

  • 2 weeks later...

Thank you for your reply. I've read some about the database data types and that makes sense now. But about the sessions i have one question:If i use sessions in order to let a user stay logged in during his stay on my site. What if he leaves from the site (goes to another site, or closes the browsers / shuts down the computer) ? Are sessions then still working when he returns to the computer?

Link to comment
Share on other sites

Sessions use temporary cookies, so they (should) get deleted when the browser gets closed. Sessions will also expire after a time if they aren't used, the default is 24 minutes. There's a short tutorial here about creating a register/login system using a database and sessions:http://w3schools.invisionzone.com/index.php?showtopic=12509

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...