Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
Not sure if this answers your question, but here is something:
A common thing that people do with a GET is this http://www.example.com?id=1234
Then, this may be used in an SQL statement as such:
PHP Code:
$sql = "SELECT * FROM table WHERE id=".$_GET["id"]; $result = mysql_query($sql);
The problem with this, is that it opens the door for SQL injection, which can compromise your database. You must be very careful with any GET, because anyone may enter anything they want into the browser, and see it reflected in your code.
in the above example, you could filter the GET variable like this:
PHP Code:
$sanitized_input = inval($_GET["id"]); $sql = "SELECT * FROM table WHERE id=".$sanitized_input;
In this example, since the id field in the database must always be an integer, we convert the GET to an integer, to ensure nothing bad is being passed along in it. This is a very simple example of security. This is, unfortunately, a very complex issue, and one that must be handled with care. Lately I have been experimenting with URL encryption, so that anything that is entered there gets jumbled up when it gets passed back to the page.
|