Skip to main content
Topic: Okay, really off topic, but need some help on coding... (Read 3224 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Okay, really off topic, but need some help on coding...

How to Transfer Data in Web Form to a MySQL Database?

Okay, I've tried this, and failed at getting it to work. Database work, is not my strong point. I have a script, that counts the links for my downloads. I'd like a simple form, to submit them, instead of going into phpMyAdmin.

The original download system, I got from a site, PHPJabbers. One of their unsupported free scripts.
But, it does the job for counting the downloads.

Re: Okay, really off topic, but need some help on coding...

Reply #1

Found the solution.

Re: Okay, really off topic, but need some help on coding...

Reply #2

Do note: insert data from "users" directly in a query is BadTM.
Doing this you are open to SQL-injection of any kind.

So you have to either clean anything coming from $_POST (mysqli_real_escape_string), or even better if you are "new" to this kind of things, use PDO or other database abstraction layers and let them handle the sanitization/security for you. ;)
Bugs creator.
Features destroyer.
Template killer.

Re: Okay, really off topic, but need some help on coding...

Reply #3

@emanuele, only I can get to the file to submit.
The file is restricted to my IP only.
Even got it where the files can't be indexed, too.

Re: Okay, really off topic, but need some help on coding...

Reply #4

This is usually not a limit to the exploiting of similar unsafe code, but if you feel safe, good for you. ;)
For all those looking at the code above: be aware it's unsafe.
Bugs creator.
Features destroyer.
Template killer.

Re: Okay, really off topic, but need some help on coding...

Reply #5

@emanuele just an aside...
W3Schools, is where I had gotten that fix from. XD

Also, like said, this form is just for me, no one else can access the submission form.

If you could tell me how to do the $_POST (mysqli_real_escape_string), into that code, I'd be happy to do it. But I can't go the other way, as the way I got it, was the only way it would work.

Re: Okay, really off topic, but need some help on coding...

Reply #6

May I ask what do you need that for Burke? Is it part of any known software? If that so, why don't you use that software framework to add that data? I think it should be like using SimpleAds in ElkArte forum as it is more safer.

Re: Okay, really off topic, but need some help on coding...

Reply #7

This is for a simple downloads page for my main site.
So I can just add the links to my downloads.
What it does, is keeps a count of the times the download links are used.

The counter script was a free script, so they choose not to offer much more to it.
The submission page, is not for anyone other than me, and I rename the file to where it can't be used, when I'm done.
It's just a lot easier, than going into phpMyAdmin all the time, to add files to the database.

Re: Okay, really off topic, but need some help on coding...

Reply #8

Ok. It is simply a download page then but you wish to keep a count of  download (or click) for each item. I am not so sure you need to use database jut for that. I somehow believe you can also use a free service like https://github.com/mmilidoni/github-downloads-count. May be @Spuds can answer that github thingy.

Re: Okay, really off topic, but need some help on coding...

Reply #9


That would help, if all my downloads were on GitHub, but they are not.
In fact, the majority are not.

But, like said, there's many ideas I wish could do for this, but there's no actual downloads system, free, with an admin panel to add the files into the database, so had to go with this.