Minimeallolla Posted November 7, 2010 Share Posted November 7, 2010 '[$username]' is using a variable from a cookie varifying that you are logged in, this code works except i need to put real escape strings and protection from mysql injection and dont really know where to put them. if (isset($_POST['submit'])) { // now we insert it into the database $insert = "INSERT INTO gamecomments (username, comment) VALUES ('[$username]', '$_POST[comment]')"; $add_comment = mysql_query($insert); { echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=games.php\">"; } } [code] Link to comment https://forums.phpfreaks.com/topic/217984-comment-protection-sql-injection-real-escape-strings-help/ Share on other sites More sharing options...
Minimeallolla Posted November 7, 2010 Author Share Posted November 7, 2010 would something like this work? if (isset($_POST['submit'])) { $username = real_escape_string($username); $_POST['comment'] = real_escape_String($comment); // now we insert it into the database $insert = "INSERT INTO gamecomments (username, comment) VALUES ('[$username]', '$_POST[comment]')"; $add_comment = mysql_query($insert); { echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=games.php\">"; } } Link to comment https://forums.phpfreaks.com/topic/217984-comment-protection-sql-injection-real-escape-strings-help/#findComment-1131297 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.