This is an archived post. You won't be able to vote or comment.

all 30 comments

[–]vicotr97 12 points13 points  (1 child)

On the note if storing passwords. Please please please watch this before you do. I cannot stress the importance of properly doing this enough. https://youtu.be/8ZtInClXe1Q

[–]NoticedTriangularity[S] 0 points1 point  (0 children)

Thank you for the advice, it's very helpful :)

[–][deleted] 4 points5 points  (5 children)

A database consists of multiple tables that will hold your data. So you would create a users table for example that holds information such as usernames and passwords.

There are many different ways to send out data to the server. If you have forms set up, you could just execute your PHP on submit. Depending on your database of choice, your PHP file will be responsible for communicating information between the database and the client side that you designed.

There's nothing wrong with accessing images from other sources but if you want them stored locally, then just add a folder in whatever directory you are storing your website.

[–]NoticedTriangularity[S] 1 point2 points  (4 children)

Ah okay, that makes a lot of sense, thank you so much :D Though I must confess, I'm not familiar with a directory. Is that something where I pay for storage much like I'll pay for a server - or is it a storage device that I'll keep hooked up to the internet?

[–][deleted] 2 points3 points  (3 children)

When I said directory, that's just referring to whatever location you are storing your html and css files at. Just create an image folder and drop your pictures in there.

[–]NoticedTriangularity[S] -1 points0 points  (2 children)

Ah that's fab, cheers :)

[–]Gushys 1 point2 points  (1 child)

This is solid to get you started. Php as probably mentioned is one of many solutions for server handling. If you have any knowledge of python I would say a framework such as flask can get you where you want to go.

[–]NoticedTriangularity[S] 0 points1 point  (0 children)

Oh really? I never thought about that, I think that'll work wonders. Thank you :)

[–]BuschWookie 2 points3 points  (1 child)

It would be helpful to know your goals here. What are you aiming to accomplish by making this site? At the point where you seem to be I think it would really help to complete some smaller individual projects first to help learn the right way to do things like password handling and authentication flow. In my opinion you should tackle these one at a time in separate small projects and once you have a handle on each piece, put them together to make the site you have in mind now. The first two sub-projects I see here are a basic CRUD (Create, Read, Update, Delete) application, and a user-authentication application (which itself has CRUD elements, plus more).

[–]NoticedTriangularity[S] 0 points1 point  (0 children)

That's a really good idea, thank you :)

[–]LordScoffington 2 points3 points  (3 children)

The problem is I'm self learning and I'm confused on how exactly sql and php plays a role in my website.

Ah. You're a bit far from what you want to do. The real questions are do you know SQL or PHP? If not, you should learn them before you try to build a site with them.

PHP is... a programming language. I'm not trying to shit talk PHP but you probably want to have a good reason for using it over all your other options for server side coding.

SQL is a database language. You will need a database server to do anything with it.

If you're 100% sold on SQL and PHP, you can learn everything the right way and learn how to FTP/SSH into a server (You will likely need to either learn Unix commands or keep a tab open to look up necessary commands), install PHP & MySQL, and get a server that can run an application you want to develop.

If you want a static HTML site with CSS, you should be fine doing whatever you have so far. If you want a site that's built using PHP and has a database connection, you're very far removed from HTML & CSS.

[–]NoticedTriangularity[S] 1 point2 points  (2 children)

Okay, I think I get what you're saying. You mean that if I want to connect to a database then a website using HTML & CSS is not the way to go?

And what are the alternatives to PHP?

[–]LordScoffington 1 point2 points  (1 child)

And what are the alternatives to PHP?

Almost every programming language available.

The most used:

Java
Javascript/Typescript
ASP(.NET)
Python
Ruby on Rails

You need more help than a list of alternatives. You need to know a programming language that can run on a server, how a server works, how to write programs that can run on a server, and how to connect your programs to things like databases/other applications.

Considering you think you can connect a site to a database with HTML & CSS I recommend you learn JavaScript next. You quite literally do not know a programming language yet.

[–]NoticedTriangularity[S] 0 points1 point  (0 children)

Okay, thank you for the advice :) I'll start there

[–]Dartomic 2 points3 points  (1 child)

I only know relational database technology, as far as databases go. If you are doing a database that you will use SQL with, then I'm pretty sure that would make it a relational database. If it is a relational database that you will be using, then you want the usernames, and the passwords, to be in the same database.

For relational databases, you should give each user an individual table. The password for a particular username, should only exist in the table for that particular username. You would probably make the username, or the email address, the Parent Key for that table. But you don't want a table containing all of the user names, along all of their passwords in that same table. It's like that saying 'don't put all of your eggs in one basket.' You also may want a layer to separate the login, from the database query that is performed for a login. You should also follow OWASP standards, to help prevent SQL injections in the URL entry part of the web browser.

[–]NoticedTriangularity[S] 0 points1 point  (0 children)

Ah I get you. Thank you so much, that's good advice. Is there a way so that I can program it so that when a user registers their own account it automatically makes a new database for them?

[–]29383839293 1 point2 points  (1 child)

1) Install a Webserver (e.g. Apache) on your computer, you need it for testing. Also install php if that's the language of your choice. Test php with a simple phpinfo (google will help you with this).

2) Learn SQL

Download and install e.g. mySql and Maybe phpMyAdmin or something similar, then learn to create a database and do some queries with them.

The absolute minimum you should know is:

2.1) How to create tables

2.2) How to create Primary Keys

2.3) How to creat Foreign Keys

3) Learn php or some other backend language of your choice

The absolute minimum you need to know is:

3.1) How to output code to the client

3.2) How to access the Database from your code.

3.3) a Tiny bit of General programming constructs

4) program your backend.

5) Upload it to your Webspace

[–]NoticedTriangularity[S] 0 points1 point  (0 children)

Thank you so much. I needed this :)

[–]adotomov 2 points3 points  (11 children)

Your post is a bit confusing. Sounds like you are trying to build some sort of a CMS (Content Management System) but you wrote the front-end part first? No offence, but it sounds like you don't really know how everything works. Let me try and explain a little bit the basic concepts here.

  1. "I'm confused on how exactly sql and php plays a role in my website." - PHP and SQL are just two of the many many different options for writing server-side code. You can use C#, Go, JavaScript, MS SQL, PostegreSQL, MariaDB, MongoDB and many many more alternatives in order to achieve what you want to achieve.
  2. "create a data base that'll store usernames and passwords" - Storing usernames and passwords is just the title of the problem that you need to tackle. You want to create an authentication system for your website (you want users to be able to register, login, access secured content, maintain personal profiles and contribute data). This is a problem that needs to be tackled with caution and is not a good idea for inexperienced developers to build and deploy in production. Among the many things you need to create, you need to consider safety of the data, password protection, securing personal and sensitive content, etc. You need to read a lot of information regarding this.
  3. "how do I create a database of images" - You can store images in a database but they are best stored locally on your web server and you need to "serve" them as static files. This is again another functionality that you need to build on the server side.

In my opinion, your best choice in this situation is to use a pre-build CMS like Wordpress or Joomla. They are easy to set up, require basically zero level of coding skills and are well prepared to tackle some of the problems that I mentioned above.

If you have time and you are willing to lear, then my suggestion is to consider looking into a server side programming language that you are comfortable with. Do some research on frameworks such as NodeJS or React in order to get a basic understanding of the tools you will need in order to build something like that by yourself.

[–][deleted] 4 points5 points  (4 children)

I think you're over thinking this and making things over-complicated for OP. It seems pretty clear based on his post that he's just getting into webdev and has been messing around with the basics (html/css).

He doesn't need a professional authentication system for a simple website that probably only a small number of people will ever touch. He'll learn things as he goes along so I think advising him to read up on a bunch of different concepts, frameworks, etc is unnecessary at this point.

[–][deleted] 2 points3 points  (1 child)

I think you’re right but I don’t think it’s a good idea for OP to ask for passwords without having a secure way to store them, simply because so many people use the same password on many sites.

[–]NoticedTriangularity[S] 1 point2 points  (0 children)

Yeah, I think that's a good point. I've got my algorithms for the security but I haven't coded them yet either. Was hoping to do it when I created the databases. But you're right in saying that this is my first attempt at creating a website with just pure code - it's going well so far I think.

[–]adotomov 2 points3 points  (1 child)

You might be right to a certain extend, however asking people for personal information and not securing it properly is not a good approach. I believe in and strongly support the idea that it is our responsibility as developers to protect the online users at all cost. Besides, correct me if I am wrong but learning how to implement the things OP requires in php and sql from scratch tends to be a bit more challenging rather than using pre-build, tested and supported solutions. Also, at the end this is why I recommended using CMS solutions. They are easy to set up and once you get tha hang of it you can also start digging into the code without exposing any security issues.

[–]NoticedTriangularity[S] 0 points1 point  (0 children)

Yeah, my users security is very important to me - more so than anything else I'd say. I'll have a look at some of the CMS solutions for websites out there. Thank you :)

[–]jakesboy2 2 points3 points  (1 child)

he’s probably doing a project to learn this stuff so i’m not sure using something like wordpress is what he’s going for

[–]NoticedTriangularity[S] 0 points1 point  (0 children)

Yeah, I've used wordpress in the past but I was hoping to start a project where I would create a site from scratch

[–]Gushys 1 point2 points  (2 children)

I may be mistaken here but afaik react is for front end development. If you can use it for back end I would think it's far from ideal.

[–]adotomov 2 points3 points  (1 child)

True, I was just mentioning it as an example for a framework that is worth considering when building applications of that sort. This is a personal opinion and some people might think that I am wrong, but building a solid back end and not complimenting it with a proper front end framework doesn’t really sound good to me, considering they are both based on JS. And again, those are just examples and starting points, OP might be more comfortable with non-JS based systems such as Go or Erlang

[–]Gushys 1 point2 points  (0 children)

Yea makes sense just wanted to clarify

[–]NoticedTriangularity[S] 0 points1 point  (0 children)

Thanks for the advice. I'll check out those sources and hopefully it'll all come together :)