boneXXX Posted April 26, 2008 Share Posted April 26, 2008 Hi all, I want to use $_POST[something] value in a MYSQL statement. For Example: SELECT * FROM Table WHERE TableName = $_POST[something] Could you give me some advise please? Thanks Link to comment https://forums.phpfreaks.com/topic/102990-solved-using-post-value-in-a-sql-statement/ Share on other sites More sharing options...
zenag Posted April 26, 2008 Share Posted April 26, 2008 "SELECT * FROM Table WHERE TableName ='$_POST[something]'" Link to comment https://forums.phpfreaks.com/topic/102990-solved-using-post-value-in-a-sql-statement/#findComment-527594 Share on other sites More sharing options...
boneXXX Posted April 26, 2008 Author Share Posted April 26, 2008 Thanks a lot it is worked Link to comment https://forums.phpfreaks.com/topic/102990-solved-using-post-value-in-a-sql-statement/#findComment-527596 Share on other sites More sharing options...
haku Posted April 26, 2008 Share Posted April 26, 2008 You should be careful with that though - putting the value into your database without checking it first is very dangerous. People can inject code into your database that does nasty things. You should never put post data directly into the database. Link to comment https://forums.phpfreaks.com/topic/102990-solved-using-post-value-in-a-sql-statement/#findComment-527597 Share on other sites More sharing options...
Xurion Posted April 26, 2008 Share Posted April 26, 2008 Could you give some examples of what a user would be able to do by injecting in this method? Link to comment https://forums.phpfreaks.com/topic/102990-solved-using-post-value-in-a-sql-statement/#findComment-527613 Share on other sites More sharing options...
boneXXX Posted April 26, 2008 Author Share Posted April 26, 2008 Thank you for the advise Haku. Actually I didn't think about that, but the way I am using it is safe because I get the $_POST value from a drop down menu so there is no way to inject code into the system. You should be careful with that though - putting the value into your database without checking it first is very dangerous. People can inject code into your database that does nasty things. You should never put post data directly into the database. Link to comment https://forums.phpfreaks.com/topic/102990-solved-using-post-value-in-a-sql-statement/#findComment-527625 Share on other sites More sharing options...
haku Posted April 26, 2008 Share Posted April 26, 2008 You would be mistaken in that assumption. Link to comment https://forums.phpfreaks.com/topic/102990-solved-using-post-value-in-a-sql-statement/#findComment-527687 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.