r/webdev•
tyrellrummage

Question about PHP, MYSQL, PDO and databases

Hello, so I'm fairly experienced with front-end web development, and I want to get into back-end.

I tried Node and I liked it a lot, especially using MongoDB and using Javascript for databases seemed so easy for me but I had a few problems:

  • there is a lot to learn and I don't have too much free time rn
  • the setup is more complicated than simply uploading some files via FTP (with filezilla for example)
  • a lot of the websites I'm asked to "tweak" or fix on my job are made with PHP

So I decided to learn PHP instead. I've been watching videos of PHP 7 and it's looking better than the previous versions.

I want to create a simple "webapp" from scratch, like a blog, with this requisites:

  • It has to have a login page (just for admins, that are created by me in the code , ie. I don't need admin register).
  • When you login you are able to post to the blog (just text by now), and then edit the post, remove it, etc.

So I have a fair understanding of sessions in PHP, but I don't get how to connect it with the login. For example, I login and after it checks the username and password it creates a session with what? the username? the id of the user? should this session variable be hashed or salted or whatever?

I've read in stack overflow that even if you use HTTPS you should be aware of security concerns like that someone in the same wifi could be able to infiltrate and intercept the session and then do whatever he wants. So you must do: IP checking, compare the browser version, operating system, etc.

My question is, how to do this things? I googled 'IP CHECKING PHP' and got nothing. Ignoring this, should I do something like

if(isset($_SESSION['user'])){
    //show admin page
}else{
    header('login.php')
}

for example? So many questions that I don't know where to start. Thanks in advance and sorry if this sound pretentious, but I genuinely want to know how or where to start.

Posted Aug 17, 2017, 8:00 PM UTC

18
Loading comments…