$buy could never be equal with: .... =='yes'
$buy has set as "'yes'" , or \'yes\' in some cases, depending on server settings.
on servers where the magic-quotes-gpc has enabled all the values from special globals $GET $POST converted such as:
' into \' \ into \ " converted into \". If you don't know this setting on another servers your program will be bad designed. If you re-write the url's variables into the html code , these converts could cause doubled escaped code =>> can mess your html forms...
this is the worst technique how you kill the database by a hacker attach... directly inserting untrusted codes makes this example unsecure.
<?php
$query = "SELECT * FROM item WHERE ProductId='$id'";
if i were you, i were make like this:
if(isset($_GET["buy"]) AND $_GET["buy"]=="'yes'" AND isset($_POST["id"]))
{
$query = sprintf("SELECT * FROM item WHERE ProductId=%d" , $_POST["id"]);
//...
}
?>
Why can't "buy" be in the url?It's not a passing any important data it's just to check if a user got to that page to buy a specific item or not.
an embedded hidden element could make this track. In the one hand, If you make more then one products order page, your statistic log will be untidy...
, in the second hand, Search Engines don't really like urls with questionmarks, 4 example google 'hates' un-SEO Friendly urls. google + SEO friendly urls
Several times I gave full codes since I am on this forum.
But I realised it that I may cause things that i did not know 🙂
4 example a harmful code may ruin a live system. A beginner may learn a bad technique from me.
And I was told many times that "a full code again, but these are the problems with it.."
In that case you are sure that your mentioned codes reliable publish them, and this is just a suggestion, only.
hello, jjozsi.