Well i have a problem. I have a registration for for legal users and natural users, but i need to write a validation in each php file for username checking, i have no idea how to combine two table checking.
one table is called users_legal, 2nd one is users_natural. In both forms name for input field is "username".
So far i have a code that checks passwords :
if ($password == $password_re)
{
    // insert into table
    $sql = $db->prepare("INSERT INTO users_legal(name, reg_number, address, phone, email, username, password) VALUES(?, ?, ?, ?, ?, ?, ?);");
    $sql->bind_param("sssssss", $name, $reg_number, $address, $phone, $email, $username, $password);        
    $sql->execute();
    $sql->close();
}
After makeing a validation in register forms, i also need it in login page. I figured out how to check if there is only and only one user with that username and that password, but i have no idea how to search them between tables.
login.php code :
if($_SERVER["REQUEST_METHOD"] == "POST") {
  // username and password sent from form 
  $myusername = mysqli_real_escape_string($db,$_POST['username']);
  $mypassword = mysqli_real_escape_string($db,$_POST['password']); 
  $sql = "SELECT id FROM login WHERE username = '$myusername' and password = '$mypassword'";
  $result = mysqli_query($db,$sql);
  $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  $active = $row['active'];
  $_SESSION['username'] = $myusername;
  $count = mysqli_num_rows($result);
  if($count == 1) {
     session_register("myusername");
     $_SESSION['username'] = $myusername;
     $_SESSION['loggedin'] = true;
     header("location: www.goole.lv");
  }else {
     $error = "Your Login Name or Password is invalid";
  }
}
One more thing : i set my mysql to utf format, var_dump says that input is allright, but in mysql it saves in unbelievuble forms, like Ķegums or Skrīvelis.
Thnx for any examples, tips or whateva u got.
 
     
     
    