I would like to get some clear information or reply how to solve the next issue.
Currently i used MySQL connection, but now i want to move onto MySQLi. I dont want to use PDO, so please do not prefer it.
The new mysqli code is this, but its not working also i think i used a bit too much else, which is not needed.
<?php
include('includes/functions.php');
session_start();
if(isset($_POST['login'])) {
if(isset($_POST['username'])) {
if(isset($_POST['password'])) {
$username = $_POST['username'];
mysqli_query($query, "SELECT * FROM cm_users WHERE Username = '$username'") or die(mysql_error());
foreach ($query as $user)
if(sha3($_POST['password'],256) == $user['Password']) {
$_SESSION['user'] = $user['Username'];
if(isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
header("Location: login.php");
echo "<button class='btn btn-block btn-warning btn-sm'>Please check your login details.</button>";
exit;
}
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=******&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
if($response.success==false)
{
echo '<h2>You are spammer ! Get the @$%K out</h2>';
} else {
echo '<h2>Thanks for posting comment.</h2>';
}
header("Location: redirect.php");
} else {
echo "<button class='btn btn-block btn-warning btn-sm'>Please check your login details.</button>";
include('login.php');
}
} else {
echo "<button class='btn btn-block btn-warning btn-sm'>Please check that you filled out the login form!</button>";
include('login.php');
}
}
}
?>
Any idea how to fix the issue to get work?