Every time I think I’ve found a forms/database tutorial that’s going to actually teach me something, it breaks my heart. Just one that explains it, that’s all I need. Just one single tutorial that works.
Am I just stupid? Maybe it’s just me.
Here’s one of the latest I’m trying:
Immediately, I have two questions:
- How does this code execute? There’s no step explaining what this file should be called or where it should be placed. There’s no step or code declaring an event that triggers this code or accesses this file (whatever and wherever it is).
- How is that secure? Having your username, password, and database name right there can’t possibly be secure. The most specific answer I’ve gotten to that question was to put it outside the public folder which, honestly, doesn’t mean much to me.
Is there no course, no tutorial that explains where stuff goes and how you access it? If there was a file that linked to this PHP file I’d know two things:
- I’d know the relative location — where this PHP code lives and, hopefully, as a result, how it’s secure and even what it’s called.
- I’d know what executes the code in this file. Probably.
Everything I find explains how to do a given task or program a given task in some fictional, hypothetical environment but not on an actual server. At best, it explains how to do it on a home/local server but never explains how to get it all up onto a real host.
Every time I think I’ve learned something, I find out it’s useless because, for example, most hosts don’t provide nodejs so you have to, simply, find one that does. That would have been nice to know before I bought my hosting months ago.
The last paragraph in the previous screenshot gave me some hope (but still frustrated me because I hate learning things out of order–couldn’t “how to connect to a database” have been the first step?
Totally makes sense but I still don’t understand how it executes. I know enough to know that code just sitting there in a file doesn’t do anything by itself. Following this “connecting” code is a line inserting a row of information into the database table. Theoretically. I guess. But how? Why? No form is completed. No button is clicked.
The following screenshots below are the other tutorial I was hoping would kickstart my geeky heart today. It explains and shows everything I’d want to know. I love it but to me, at this point, it’s still useless because I don’t know how to put those four rows into the table. Yes, I know I can use SQL commands in the Terminal or use PHPmyAdmin and I love doing both of those but I want to make sites and/or apps for users other than myself. I want a few files on my web server (my host–not just local at home on my Mac or laptop) for the following:
- User completes a form that adds rows to a data base
- User completes a form that retrieves rows from a database
Like, say, updating a contact list.
The PHP file below, however, seems to be in the same directory as the HTML file which means, unless I’m completely mistaken, the user can type the URL and see.
Another example of what frustrates me is why in the previous tutorial, the “command” (“function”? or, in the second, “variable”) mysql_connect is used but the example below uses $con = mysqli_connect. Someone answered me on reddit saying mysqli was newer (or something … I can’t even remember) and I recently read something else mentioning it but those explanations get lost amidst all my other questions because who gives a s**t if I can’t even get that far because of all my other unanswered questions?
And, I’d like to be able to this simple thing in a secure manner because if the data and/or site aren’t safe then who gives a f**k what I make the site do?