I am trying to run two queries together and seperating them by a semicolon.
$query2 = "UPDATE users SET locked = '1' WHERE id = '13';
UPDATE users SET reset_key = '".$resetKey."' WHERE id = '13';";
Here is my complete code. I am trying to create a kind of brute force protection for a login form. If there are 5 incorrect attempts to login, the account should lock up and a random reset key gets created. Then the key gets stored in the database and that is where the query isn't getting executed.
<?php
$mysqli = new mysqli('localhost', 'x', 'x', 'x');
if ($mysqli->connect_error) {
die('Connect Error (' . $mysqli->connect_errno . ') '
. $mysqli->connect_error);
}
$result = $mysqli->query("SELECT * FROM `users` WHERE `email` = 'abc@abc.abc'");
$result = $result->fetch_row();
$locked = $result[5];
$resetKey = $result[6];
$attempts = $result[4];
if ($attempts == NULL) {
$attempts = 1;
} elseif ($attempts == '5') {
/* let's create a random string */
$letters='abcdefghijklmnopqrstuvwxyz'; // selection of a-z
for($x=0; $x<3; ++$x){ // loop three times
$resetKey.=$letters[rand(0,25)].rand(0,9); // concatenate one letter then one number
}
$query2 = "UPDATE users SET locked = '1' WHERE id = '13';
UPDATE users SET reset_key = '".$resetKey."' WHERE id = '13';";
echo "<p>".$query2."</p>";
$result2 = $mysqli->query($query2);
} else {
$attempts++;
$query3 = "UPDATE users SET attempts = '".$attempts."' WHERE id = '13'";
$result3 = $mysqli->query($query3);
}
?>