1

I am making a login system, and I have used similar code to this on other sites, but it just doesn't seem to be submitting for me? No errors, the page just stays exactly the same. Anyone got any ideas

<?php

    if(isset($_POST['submit'])){

    $user = $_POST["user"];
    $raw = $_POST["password"]; 
    $hash = md5($raw);


    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
        $ip = $_SERVER['HTTP_CLIENT_IP'];
    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } else {
        $ip = $_SERVER['REMOTE_ADDR'];
}


        $con=mysqli_connect("localhost","bans","(My Password Here)","bans");
if (mysqli_connect_errno()) {
  echo "Error ";

}

    $check = mysqli_query("$con, SELECT hash FROM panel WHERE user = '$user'");

    if ($hash == $check) {
      $insert = mysqli_query("$con, INSERT INTO panel (online, ip)
      VALUES ('1', '$ip')");

  } else {

    echo '<div class="alert alert-danger">You are not staff/have entered incorrect information!</div>';

  }
}

?>

2 Answers2

0

if(isset($_POST['submit'])) Maybe it was a button that you dont have now. Try if(isset($_POST["user"])) :)

miguel-svq
  • 2,136
  • 9
  • 11
-1

Your

$check = mysqli_query("$con, SELECT hash FROM panel WHERE user = '$user'");

should be more like

$check = mysqli_query($con, "SELECT hash FROM panel WHERE user = '$user'");

BTW you're wide open into SQL injection

Community
  • 1
  • 1
Bartek
  • 1,349
  • 7
  • 13