phpnoobie9 Posted February 24, 2008 Share Posted February 24, 2008 If I have a get from that produced something like mysitedotcom/mypage.php?id=1 Is there a way of getting to my server through the url? Quote Link to comment Share on other sites More sharing options...
drisate Posted February 24, 2008 Share Posted February 24, 2008 yes you can use vars from your url Let say you have mysitedotcom/mypage.php?id=1 To get the var id you would use $_GET[id] PHP auto produces it when you open mypage.php so if you make <?php echo $_GET[id]; ?> at the bigining of your page you would have the value 1 printed on the page. You can also use that var in your sql statment SELECT * FROM table WHERE id='$_GET[id]' but of couse don't forget to clean the var to protect you self aganst hackers that could change the the value 1 to malicious codes and manipulate the querry. Quote Link to comment Share on other sites More sharing options...
phpnoobie9 Posted February 24, 2008 Author Share Posted February 24, 2008 What do you mean clean the variable? How do I do that? So if all I have is a SELECT statement they can change that into some kind of INSERT and insert codes into my database? Quote Link to comment Share on other sites More sharing options...
nethnet Posted February 24, 2008 Share Posted February 24, 2008 Use addslashes() on all content taken from the URL and put directly into an SQL query. It will project your site from SQL injections. Quote Link to comment Share on other sites More sharing options...
drisate Posted February 24, 2008 Share Posted February 24, 2008 You should make a google search on "xss" or also called "cross site scrypting" Quote Link to comment Share on other sites More sharing options...
drisate Posted February 24, 2008 Share Posted February 24, 2008 Please note that addslashes is not the correct function to protect you from SQL injections. For example, the following line: $short_desc = addslashes($_POST['short_desc']); Should look like this: $short_desc = mysql_real_escape_string($_POST['short_desc']); addslashes() should be deprecated - it does not protect against SQL injections Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.