I'm programming a simple login system. It runs very good in local, but when i run in my hosting i'm getting troubles with the header function.
Heres my login form:
<form method="post" action="auth.php">
User:<br />
<input type="text" name="name" required><br /><br />
Password:<br />
<input type="password" name="pass" class="input" required><br /><br />
<button>LOGIN</button>
</form>
And the "auth.php":
include '../conection.php';
$user = $mysqli->real_escape_string($_POST['name']);
$pass = sha1($mysqli->real_escape_string($_POST['pass']));
if(isset($user)){
$users = $mysqli->query("select * from admins where admin_user='".$user."' and admin_pass='".$pass."' ");
if($users->fetch_object()){
session_start();
$_SESSION['user'] = $user;
//Im having troubles with this function
header('Location:control.php');
exit;
}else{
echo 'Sorry no access<br /><br />';
//if i remove the "//" to the next header function works in local and hosting
//header('Location:index.php');
}
}else{
echo 'Sorry no access<br /><br />';
}
$mysqli->close();
WARNINGS: 1st: session_start(): Cannot send session cache limiter. 2nd: Cannot modify header information.
Whats wrong in the code? Or what i'm not considering? Also if you have any advice to improve this code, I really appreciate.
For your help, thanks.