LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Pick up data from database via web-interface (https://www.linuxquestions.org/questions/programming-9/pick-up-data-from-database-via-web-interface-933360/)

Lexus45 03-08-2012 12:46 AM

Pick up data from database via web-interface
 
Hello all.
I need an advice how to combine all these knowledge into one useful resource.

I'd like to create a simple form which will allow to select soma data from the database via web-interface.

I can create the database (let it be MySQL).
I can create a HTML page with input forms/select fields/radio buttons and so on.

I do not know PHP but try to consult a very nice website http://w3schools.com/php/php_mysql_select.asp

So, I'm sure I will be able to write a simple PHP code, but it will be "static" - the query itself will be written inside the PHP code, with my hand.

But I want the page be interactive - the user must be able to input some query or select some values from the list. So, I can't understand how to "connect" user's input with the query to the database.

Maybe someone will give me a push to the right direction? :) Thanks.

kbp 03-08-2012 06:09 PM

Not a direct answer to your question but please read up on sql injection before you start coding. I believe the preferred method to prevent injection is to use parameterised queries.

adixon 03-14-2012 07:47 AM

myschools is excellent ref, you'll end up coding sql chunks like "select " + $_POST['f1'] + "FROM " + $_POST['f2'] ..
Basically the easiest way is for your form/page to post to itself and have the php validate and run the post data.
good luck

dugan 03-14-2012 08:44 AM

Quote:

Originally Posted by adixon (Post 4626522)
you'll end up coding sql chunks like "select " + $_POST['f1'] + "FROM " + $_POST['f2'] ..

* ahem

Kbp's point about being aware of SQL injection vulnerabilities clearly applies to you too.

adixon 03-14-2012 08:53 AM

I agree, though i did mention
Quote:

php validate and run the post data


All times are GMT -5. The time now is 07:04 PM.