Jump to content

[SOLVED] how to fix these problems...??


clown[NOR]

Recommended Posts

i added my test site to the beta test forum, and one of the replies i got was:

 

Well, your login is very easy to bypass, and you're open to XSS in your entries. You'll notice that I entered a test movie with some javascript in the review that pops up in the first screen. Also, you're open to SQL injection in your ORDER BY clause when you sort by something.

 

how can i fix this?

 

Link to comment
https://forums.phpfreaks.com/topic/46611-solved-how-to-fix-these-problems/
Share on other sites

well... this was for my "My Favorite Movie" script =) hehe.... but anyway...

 

could something like this done the trick agains the SQL injection? done some google searches on that and on wikipedia.org

 

they used this exact code (only change is the variable and table name)

 

$result = mysql_query
(
	"select * from mfm_users where username = '"
.
	mysql_real_escape_string($mfm_USER)
.
	"'"
);

you didnt read my post did you gluck?

well... this was for my "My Favorite Movie" script =) hehe.... but anyway...

 

could something like this done the trick agains the SQL injection? done some google searches on that and on wikipedia.org

 

they used this exact code (only change is the variable and table name)

 

Clown, to make sure that someone has something valid in there, all you really have to do is something like this:

<?php
if (isset($_POST['username']) && isset($_POST['password'])) {
  $user = trim($_POST['username']);
  $pass = trim($_POST['password']);
  if (empty($user) || empty($pass)) {
    // error out - empty strings being submitted
  } else {
    $q = "SELECT * FROM userTable WHERE username = '" . mysql_real_escape_string($user) . "' AND password = MD5('" . mysql_real_escape_string($pass) . "')";
    // Check your results here
  }
}
?>

 

Hope this helps.

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.