Error al intentar ingresar me explico en localhost funciona bien pero al momento de subirlo a algun servidor marca este error
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /storage/ssd3/893/822893/public_html/index.php:33) in /storage/ssd3/893/822893/public_html/php/login.php on line 11
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /storage/ssd3/893/822893/public_html/index.php:33) in /storage/ssd3/893/822893/public_html/php/login.php on line 11
Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd3/893/822893/public_html/index.php:33) in /storage/ssd3/893/822893/public_html/php/login.php on line 15
mire por hay que session_start deberia estar en el inicio despues de la etiqueta <?php
<?php
session_start();
pero sigue igual tambien mire que era por los espacios en blanco bueno junte las lineas sin dejar renglones y sigue igual
aca esta mi codigo original
<?php
$correo=$_POST['correo'];
$clave=md5($_POST['clave']);
require_once('Conexion.php');
$conn = Conectar();
$stmt = $conn->prepare("SELECT id_usuario, nombre, apellido, correo, p.id_perfil, perfil FROM usuario u INNER JOIN perfil p ON p.id_perfil=u.id_perfil WHERE u.correo=:correo AND u.clave=:clave");
$stmt->bindParam(':correo',$correo);
$stmt->bindParam(':clave',$clave);
$stmt->execute();
if($stmt->rowCount()==1){
session_start();
$fila=$stmt->fetch();
$_SESSION['idperfil']=$fila['id_perfil'];
if($fila['id_perfil']==1)
{header("Location: administrador/index.php");}
if($fila['id_perfil']==2)
{header("Location: aprendiz/index.php");}
if($fila['id_perfil']==3)
{header("Location: root/index.php");}
}
else{
echo "<font color='red'>Datos No Validos</font>";
}
?>
espero que me puedan ayudar y gracias
session_start();
debe estar al principio del código, no dentro delif
como lo tienes ahora y no debe haber ningún tipo de salida o código HTML antes.headers
ya fueron enviados en cualquier parte de tu código con:if (headers_sent()) { echo "Oh no!"; }