PHP Query from a FORM -


Then I have a form that I am posting on a page and in this form I post some variables I am asking whom I will ask my questions and then call them on my page. How can I post data and also prepare a question and show the answer on a call?

Maybe I am not saying this right and I am learning this, but I do not know. Should I post on an intermediate page first?

Example: From Form (variable A and B) -> Page (used in A and B queries) and then the result is on the same page.

Can this be done and what is the law?

Thank you!

This is the basic principle, but you must protect the input data from the form, for example Mysql_real_escape_string () . Using .

But in a page you can get the code like this (it has not been tested, I am not capable on this computer):

  & lt; ? Php if (isset ($ _ POST ['name'])) {$ query = "SELECT * from table WHERE firstname = '" + mysql_real_escape_string ($ _ POST [' name ']) + "'"; While ($ node = mysql_fetch_rows ()) {echo "Result:". $ Node ['id']; }}? & Gt; & Lt; Form method = "post" action = "& lt ;? php echo $ _SERVER ['PHP_SELF'] ;? & gt;" & Gt; & Lt; Input type = "text" name = "name" /> & Lt; / Form & gt;  

It will post itself, run the query and resonate the result, and show the form again.

For small tools and likes, this is okay, but for big websites, I would not suggest requesting HTML code together with HTML code to use a framework for doing MVC pattern or something like that. Look


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -