Search is showing all the products

前端 未结 1 398
花落未央
花落未央 2021-01-29 15:55

Hello when i am searching a product from its keywords that i inserted in MYSQL all the products are appearing please help me this is the code of the search i corrected as in the

1条回答
  •  -上瘾入骨i
    2021-01-29 16:36

    Your form is not properly structured - the "user_query" field is outside of the form so $_GET['user_query'] would never be set. Try changing this:

    To something like this:

    Also, as several others have noted, this is susceptible to SQL injection. This post discusses a scenario very similar to yours: How can I prevent SQL injection in PHP?

    I strongly suggest you run your generated code through a validation service in order to catch errors in your html. Be sure to use the generated html (copy from "view source" in browser), not just the code from your php file because the validator won't understand the PHP. The WWW Consortium has a good tool: http://validator.w3.org/#validate_by_input

    0 讨论(0)
提交回复
热议问题