richardmilne Posted January 7, 2011 Share Posted January 7, 2011 Hello all, I hope someone can help me with my rather limited knowledge of SQL. Lets say I have a folder on a server populated by JPGs. The file naming convention in this folder is "XXXXX_XXXX.jpg" (5 digit number followed by 4 digit number). I need to create a list of usernames and passwords based on this file naming convention, where the username is the 5 digit number, and the password is the 4 digit number. Further to this; new users need to be added as more JPGs are added. I really don't know where to start with this. As a general guide I'm using this tutorial: http://www.phpeasystep.com/workshopview.php?id=6 I suppose the bit I'm interested in is the "INSERT INTO" line. I hope someone can give me a little nudge in the right direction, I've never had to play around with SQL before, at least no more than setting up a database for wordpress installations. Ultimately when a user logs in with said username and password they will be able to view the corresponding image. TIA, hope someone can help me! Quote Link to comment https://forums.phpfreaks.com/topic/223730-creating-usernames-and-passwords-based-on-filenames/ Share on other sites More sharing options...
requinix Posted January 7, 2011 Share Posted January 7, 2011 Are you only using these usernames/passwords for when people log in to view the one image? There's no need for a database. Or more accurately, you already have one: the file system. If someone logs in as 12345:9876 then look for "12345_9876.jpg". If it exists then great, and if it doesn't then the login isn't valid. Be sure to make sure that the username is a five-digit string and the password is a four-digit string before doing anything else with them. Quote Link to comment https://forums.phpfreaks.com/topic/223730-creating-usernames-and-passwords-based-on-filenames/#findComment-1156469 Share on other sites More sharing options...
Pikachu2000 Posted January 8, 2011 Share Posted January 8, 2011 The tutorials on that website are mostly obsolete. I'd find another source for tutorials if I were you. Quote Link to comment https://forums.phpfreaks.com/topic/223730-creating-usernames-and-passwords-based-on-filenames/#findComment-1156489 Share on other sites More sharing options...
QuickOldCar Posted January 8, 2011 Share Posted January 8, 2011 Yeah they are old, just as an example they use these. session_is_registered() session_register() Quote Link to comment https://forums.phpfreaks.com/topic/223730-creating-usernames-and-passwords-based-on-filenames/#findComment-1156577 Share on other sites More sharing options...
richardmilne Posted January 11, 2011 Author Share Posted January 11, 2011 Awesome, thanks for the tips. I've come to the conclusion that a database is absolutely necessary, for the purpose of authentication via email (and will also come in handy for data capture for our clients). No information enters the database however until a user requests a photo. My new overall flow for this is: [*]User enters ID (5 digit number), PIN (4 digit number), email address, first and last name [*]ID, PIN and reference to the file on the server (This is the bit I'm having difficulty with) go to the table "Photo" in their respective fields. [*]Email, first and last name goes to the table "Customers" in their respective fields [*]Now I believe a cross reference table is needed in case one user has multiple photos, which combines the records from "Photo" with each email address (Also having difficulty here!) [*]Customer is emailed with a link to view their photo. The content of said link is updated as new photos are requested by the customer in step 1 My colleague is trying to help with this too, as he has some experience in databasing, just not with MySQL, and not for web. So far I've created a super simple form that adds ID, PIN, email and names to the correct tables, but just can't figure out how to make the jump to use this data to find a file in the filesystem. Forgive my noobish cry for help, I'm just trying to learn! Quote Link to comment https://forums.phpfreaks.com/topic/223730-creating-usernames-and-passwords-based-on-filenames/#findComment-1157832 Share on other sites More sharing options...
jdavidbakr Posted January 11, 2011 Share Posted January 11, 2011 You have the ID/PIN/etc by selecting them from the database; just use those values to construct the filename. <? $filename = $id.'.'.$pin; ?> <img src="[image directory]/<?=$filename?>" alt="Profile Picture"> Quote Link to comment https://forums.phpfreaks.com/topic/223730-creating-usernames-and-passwords-based-on-filenames/#findComment-1157948 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.