Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can I be hacked with this code?

I purchased a script that has some weird code in it. I'm a PHP beginner but know a little about things like sanitizing input data.

This is the code:

<form action="sendpass.php" method="post" id="sendpassform">
<input type="text" name="email" />
<input type="submit" name="sendpass" value="Send" />
</form>
?>

...
if($_REQUEST['email'] != ''){
  $email = $_REQUEST['email'];
  $k = mysql_query("SELECT * FROM users WHERE email='".$email."'") or die(mysql_error());
  $result= mysql_fetch_array($k);
  ....
}

What I'm curious of, is if someone can hack the site using this form, because the email field is just passed directly to SQL with any escaping...

like image 686
RebeccaBlack Avatar asked Apr 04 '11 16:04

RebeccaBlack


1 Answers

Yes. This is called SQL injection. Anywhere user supplied values are directly included in a SQL statement, this is a possibility.

like image 137
Daniel A. White Avatar answered Sep 19 '22 20:09

Daniel A. White