• 0

How would I store this information?


Question

Hey all,

I recently started learning some PHP and MySQL and I need a guide for good database setups, I suppose.

What I want to do is add the ability to have users register on my site, and have them save links on my website. They could save thousands of links.

I could make a database with their usernames, passwords and salts, then I was thinking I could have another database with their usernames and possibly another area in the database that could save the links, but how would they be saved?

Link to comment
https://www.neowin.net/forum/topic/1139258-how-would-i-store-this-information/
Share on other sites

10 answers to this question

Recommended Posts

  • 0
  • 0

So each link is in the table. So it could be like (User1 - Link1) -> (User2 - Link 1) -> (User1 - Link 2) -> (User1 - Link 3) -> (UserX - Link Y)?

Then when a user loaded their link page, it would go through the table and list all the links have match with the user?

Thanks for the database tip! :D

  • 0

Yeah, so example data:

Login

--

1,articuno1au,password,[email protected]

2,thatguyandrew,lolcats,[email protected]

Links

--

1,1,http://www.hotmail.com

2,1,http://www.wocserver.org

3,2,http://www.shayconcepts.com

4,1,http://www.forums.wocserver.org

5,2,http://www.facebook.com

Then:


SELECT Link
FROM Links
WHERE UserID in (SELECT UserID
FROM Login
WHERE Username = "articuno1au")
[/CODE]

Would return:

Hotmail, wocserver, forums.wocserver

Putting your username in would return:

shayconcepts, facebook

In the links table, the information is collected by UserID not GUID (Which is there just to serve as a Primary Key :))

Sound good?

Just as a side note, for performance reasons, you are better off using JOIN to link the tables when querying. MySQL doesn't like embedded/subquery queries >.<

  • Like 1
  • 0

FYI stackoverflow is a good resource :)

When you start getting more comfortable you will start finding ways to make the tables optimal for each application use

Practice always helps!

actually looking at others applications/programs/scripts or however you wish to pass it on as helps tons!

http://en.tekstenuitleg.net/articles/software/database-design-tutorial/intro.html

http://www.deeptraining.com/litwin/dbdesign/FundamentalsOfRelationalDatabaseDesign.aspx

Those seem like decent articles

Good luck!

  • 0

FYI stackoverflow is a good resource :)

When you start getting more comfortable you will start finding ways to make the tables optimal for each application use

Practice always helps!

actually looking at others applications/programs/scripts or however you wish to pass it on as helps tons!

http://en.tekstenuit...rial/intro.html

http://www.deeptrain...baseDesign.aspx

Those seem like decent articles

Good luck!

Thanks!

  • 0

The bit that requires special attention is securing the scripts that are running.

Having logins and submitting new links equals web forms and the use of GET and POST so you'll be wanting to do a bit of work to make sure your DB queries and inserts are secured from iffy SQL injection or other dodgy user inputs. Don't just think mysqli_real_escape_string will do the job...it'll likely not even work unless you've covered the configuration of the host in advance.

Working for a web design/development company I've seen a few rather farcical examples of "content management systems" that so called developers (created by others outside our company) have written in PHP that miss or just ignore these risks.

I'm in the middle of writing my own (super simple) blog and even though it's literally bare-bones (has no comments system yet and probably wont) and a few pages to list the articles/archive it's something I have to pay attention to as well.

  • Like 2
  • 0

The bit that requires special attention is securing the scripts that are running.

Having logins and submitting new links equals web forms and the use of GET and POST so you'll be wanting to do a bit of work to make sure your DB queries and inserts are secured from iffy SQL injection or other dodgy user inputs. Don't just think mysqli_real_escape_string will do the job...it'll likely not even work unless you've covered the configuration of the host in advance.

Working for a web design/development company I've seen a few rather farcical examples of "content management systems" that so called developers (created by others outside our company) have written in PHP that miss or just ignore these risks.

I'm in the middle of writing my own (super simple) blog and even though it's literally bare-bones (has no comments system yet and probably wont) and a few pages to list the articles/archive it's something I have to pay attention to as well.

That's great advice, thanks!

  • 0

Teknikal you plan on open sourcing it?

well it's nothing fancy. literally 1 db table. just suits my own needs. i don't like using things like wordpress as they are too bloated with all sorts of features i don't need. with my own approach I can keep it minimal, fast and I can focus on the content and SEO for titles, descriptions etc. more of a learning exercise really. i find when you use other tools people tend to neglect the important stuff.

all i need is a list of recent articles on the index, a full archive of all my articles and a page that displays each individual article when you click on it and not much else.

i might get round to doing a basic commenting system but it might be easier just to paste in something like "disqus" and let it do it. still have to do a web form to allow me to make posts but I might not even bother with that as it's just me...I can just do it directly in phpmyadmin and achieve the same result. i don't imagine a very basic search function will be difficult but I'm not really sure how best to do that yet.

also have to figure out some URL rewriting as entry.php?id=1 isn't much use. i decided to include a "slug" column in my database so I might use "my-super-cool-blog-post-title" or something to that effect and use it in the URL rather than the ID.

when it's done I can explain how i made it and what it does I guess.

This topic is now closed to further replies.
  • Posts

    • I think you meant the "ntfs3" driver, but yes there have been a lot of fixes for it in this release and previous releases, not 100% sure if the issue you mentioned is fixed though. In any case, the new "ntfs" driver in 7.1 doesn't have that issue (at least, no reports of such have come thru), but your kernel needs to explicitly enable support for the new driver first (like how CachyOS kernel has it), and you need to edit your mount points in /etc/fstab to use "ntfs" instead of the other drivers.
    • Epic Games says Unreal Engine 6 will help developers "build content faster" using AI models by Pulasthi Ariyasinghe Epic Games is rolling out the latest major update to Unreal Engine 5 today, and at the same time, the company also dropped some information on the next-generation version of the product, Unreal Engine 6. This was already revealed a few weeks ago alongside the new Rocket League upgrade reveal. The company says it is combining the features of Unreal Engine and Unreal Editor for Fortnite to create this new version of its popular media creation tool. On top of creating entire games, the new engine will also focus on letting developers operate large-scale live service titles more easily, whether by shipping content into their own ecosystems or into Fortnite. The use of large language models is also mentioned here, with Epic saying it will be a core part of the engine. "We see LLMs, generative AI models, and tools like Claude and Codex playing a central role in helping you build content faster while maintaining the creative control you need," adds the company. Here is the rundown of what's new about version 6 of Unreal Engine: With all these changes to the programming model, portability upgrades, and generative AI integration, Epic says the new version of the engine will "change a lot about how games are made." The company aims to ship Unreal Engine 6 into early access in late 2027, with a full release planned for 12-18 months later. Epic Games also dropped a lengthy blog post about the new Unreal Engine 5.8 update for game developers over here. The release is focused on delivering better performance, customization, and streamlined workflows for development teams. This will be the final major update for this version of the engine before Epic switches to focus fully on Unreal Engine 6's early access launch.
    • Watch Louis Rossmann's recent experience on YouTube about trying to get a warranty replacement from Samsung. It's crazy.
    • That is the thing, how many of these people don't realise they are using AI? If they use Google Search they have no choice but to use AI. So yes, maybe half of American adults do use and I expect a lot of Uk adults do to, but I bet most of them don't realise it. Myself, i avoid the rubbish.
    • They use FREE AI. They aren't paying for this meme-generating slopware...
  • Recent Achievements

    • One Month Later
      Vincian earned a badge
      One Month Later
    • First Post
      Jocimo earned a badge
      First Post
    • Week One Done
      suprememobiles48 earned a badge
      Week One Done
    • One Month Later
      Windows Guy earned a badge
      One Month Later
    • One Month Later
      Prasann earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      500
    2. 2
      +Edouard
      163
    3. 3
      PsYcHoKiLLa
      88
    4. 4
      Steven P.
      68
    5. 5
      neufuse
      65
  • Tell a friend

    Love Neowin? Tell a friend!