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
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)
.
	"'"
);

Link to comment
Share on other sites

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)

 

Link to comment
Share on other sites

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.

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.