I am learning sql injections and very interested how to cause this.
I have written script to see how it is going. so here is my code =>
if (isset($_POST['act'])){
if ($connection = mysqli_connect($var['host'],$var['user'],$var['password'],$var['database'])){
if (mysqli_connect_errno()==0){
$username = $_POST['username'];
$password = $_POST['pswd'];
if ($result = mysqli_query($connection,"SELECT username,password FROM login WHERE username='" . $username . "' AND password='" . $password . "'")){
if (mysqli_num_rows($result)){
header("Location: http://localhost/default.php");
} else {
$res = "Invalid Credentials ...";
}
}
}
}
}
<form name="action" method="post" action="index.php">
Username:<input type="text" name="username" size="12"><br>
Password:<input type="password" name="pswd" size=12><br>
<input type="submit" name="act" value="Login">
</form>
I’m writing like this in forms, but nothing happening
in username and in password form => some’ OR ‘1’=’1′
I’m very interested how to cause sql injection to break this script and without valid credentials redirect to default.php (of course within from marked script)
Thanks …
Try entering
' OR 1 --as usernameAlso, just in case, chack if you have
magic_quotes_gpcdisabled 🙂