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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.