Jump to content
Larry Ullman's Book Forums

Larry

Administrators
  • Content Count

    5285
  • Joined

  • Last visited

  • Days Won

    143

Larry last won the day on July 9 2019

Larry had the most liked content!

Community Reputation

423 Excellent

About Larry

  • Rank
    Administrator/Writer

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. For starters I definitely wouldn't put this into the users table. That table represents an entity: the user. What you're describing is representing activity, so I'd create a logins table for that. As for the goal itself, as I'm sure Netflix can attest, this is tricky and may not be worth the effort. You can't assume people will log out, as you noted. But that also includes situations like I start using the site on one device but then go to switch devices. I definitely access some sites on multiple devices in a single day. In any case, the best thing I can think of would be to rely upon sessions here. Store the session ID in the database, along with the user ID. Sessions will automatically expire after inactivity, based upon your site/server settings. When someone logs in, you could check if there's an active session already. But I wouldn't bother, personally. You'll have to create a lot of work to hopefully catch a few cheaters while occasionally annoying legitimate users. I'd rather put my effort into making a product so great people would gladly pay for it.
  2. That's an excellent question! Depending upon what it means to be an "admin" user, I'd be inclined to not allow admin users to reset their password at all. If a password is forgotten, the admin should personally contact the site--who presumably knows the admin--who would manually help with the reset. Such an arrangement, while inconvenient, would prevent a hack attempt.
  3. It looks like this is most commonly caused by InnoDB settings: https://stackoverflow.com/questions/22637733/mysql-error-code-1118-row-size-too-large-8126-changing-some-columns-to-te/33655143 If you'd like to keep the current approach and aren't going to add like double the current number of columns, you can try that. If this is going to continue to balloon in size, you'll need to dramatically rethink how translated text is stored. An option would be to switch the rows and columns. You won't have the row size issue anymore but you'll need to select the one column for every row and then use that query to populate a PHP array, which is laborious. Alternatively you could store all the translations in one string, like in JSON format. Retrieval and usage shouldn't be too bad but updating the values will be effortful. There's a number of ways you could approach this but those are the first two that come to mind. Everything has its tradeoffs!
  4. So I believe the page gives that result if that "SELECT a.user_id, u.email, LEFT(u.first_name,1) AS icon, ..." query doesn't return exactly one row. There wasn't anything obviously amiss there upon first inspection. I would run the query manually using the mysql client to see why it's not returning a row. (You'll need to insert the token value into the query, of course.) Try removing various conditionals to see which is the problem.
  5. So you need to clarify which date_expires you're referring to by prefacing "date_expires" with the table name or alias. As you're probably referring to the access_tokens table, which has been aliased to "a", you'd change the conditional to "AND a.date_expires > NOW()". What you tried was close but a query only has one "FROM" clause and you added a second one as part of the "WHERE" conditionals.
  6. The code you have looks okay to me. If it's not working, I'd start by looking at the HTML source of the output to see if there's something useful there. Also, should you be using POST or GET?
  7. Ah, good question! There are two options: A. Use the current code but before the current session is destroyed, copy the lang ID to a new variable and then after the current session and cookie are destroyed, start a new session and store the lang ID in that using the variable. or B. Don't clear and destroy the session in this script, only remove those session elements that represent "being logged in".
  8. Hey! If you're talking about Script 10.3, it doesn't require that the email be updated. It uses the form values to "update" the email address in the database, but the form value could very well be the same as the current value.
  9. Sure thing! I answer what I was thinking in this thread: But if you want another hint before you see the answer, there's an outer conditional--isset()--and then an inner conditional--on gender. To make this one conditional instead of two nested ones, each condition must represent both of those tests (the original outer condition plus an original inner condition).
  10. I think what you're looking for is explained here: https://dev.mysql.com/doc/refman/8.0/en/time-zone-support.html#time-zone-installation Where you want to execute this command: mysql -u root -p mysql < file_name replacing "file_name" with a full path to the timezone SQL file.
  11. Thanks for your question! You could consider my "Effortless E-commerce" book, which goes through two fairly complete applications. Unfortunately I'm not too familiar with other books that do a similar thing but they may be out there. Good luck with your further studies!
×
×
  • Create New...