1

First of all i am testing it on my server for learning purpose. The condition here is i want to insert a entry in test table in database and

SELECT * FROM `student` WHERE `name` LIKE '% ".$name." %';

here $name is coming from a input box which is created by me. And another most important thing is nothing will be printed on frontend if query execute correctly. That's why i am trying to insert the data.

I am trying it by using union query but it is not working at all. Please let me know if it is possible or not.

Here is the query that is working in phpmyadmin but same query is not working on frontend

SELECT * FROM `student` WHERE `name` LIKE '%mike%' OR 1=1 UNION INSERT INTO test (`id`,`value`) VALUES (36,'testdata')
  • No, that usually will not work (on commond DBMS etc.) – deviantfan Jul 8 '18 at 11:55
  • but it is working in phpmyadmin here is the query i am checking SELECT * FROM student WHERE name LIKE '%mike%' OR 1=1 UNION INSERT INTO test (id,value) VALUES (36,'testdata') – Ganesh Jul 8 '18 at 12:30
  • After implementing your query, you can test for possible sql injection vulnerabilities by using some automated tools, such as Sqlmap – Pilfility Jul 9 '18 at 6:35
  • Can you explain what you mean by not working on the front end? Is it giving an error message/exception? If so, please edit your question to include that information. – Mr. Llama Jul 9 '18 at 15:00
  • What is the backend DB? You normally can't union in an insert like that, but there are ways to concatenate multiple SQL statements or functions that are available with different DBs that can be used to perform DML within a SELECT. – Egret Jul 10 '18 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.