Jump to content

Is it possible to insert codes through url to control database?


phpnoobie9

Recommended Posts

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.

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.