PHP - Warning: Cannot modify header information - headers already sent by...

 
Vista:

Warning: Cannot modify header information - headers already sent by...

Publicado por rodrigo (4 intervenciones) el 24/05/2020 05:20:32
hola tengo el siguente error Carrito

Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd5/912/13816912/public_html/partes/cabezerabostrap.php:3) in /storage/ssd5/912/13816912/public_html/controller/usuariocontroller.php on line 124


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
 
include_once 'config/helpers.php';
include_once 'modelo/usuario.php';
class usuariocontroller extends usuario{
    function iniciosesion(){
 
        include_once 'view1/usuario/iniciarsession.php';
    }
 
    function registro (){
        include_once 'view1/usuario/registrarse.php';
 
    }
 
 
    function save(){
        if(isset($_POST)){
           $nombre= isset($_POST["nombre"])? $_POST["nombre"]:FALSE;
           $apellido= isset($_POST["apellido"])?$_POST["apellido"]:FALSE;
           $email= isset($_POST["email"])?$_POST["email"]:FALSE;
           $pasword= isset($_POST["pasword"])?$_POST["pasword"]:FALSE;
           $telefono=isset($_POST["pasword"])?$_POST["pasword"]:FALSE;
           $error=array();
 
           if(empty($nombre)|| is_numeric($nombre) || preg_match("/[0-9]/",$nombre)  ){
 
               $error["nombre"]="nombre invalido";
 
 
           }
 
             if(empty($apellido)|| is_numeric($apellido) || preg_match("/[0-9]/",$apellido)  ){
 
               $error["apellido"]="apellido invalido";
 
 
        }
          if(empty($email)  ){
 
               $error["email"]="email invalido";
 
    }
 
      if(empty($pasword)){
 
               $error["pasword"]="pasword invalido";
 
}
 
if(count($error)==0){
    $we=new usuario();
    $we->setApellidos($apellido);
    $we->setNombre($nombre);
    $we->setEmail($email);
    $we->setPasword($pasword);
    $re=$we->guardar();
 
    if($re){
        $_SESSION["completo"]="registro guardado";
 
    }
 
    else{$_SESSION["error"]["general"]="error en el registro";}
 
}
 
 else {
    $_SESSION["error"]=$error;
}
}
 
header("location:".base_url."usuario/registro");
}
 
 
function iniciar(){
 
    if(isset($_POST)){
           $email= isset($_POST["email"])? $_POST["email"]:FALSE;
           $pasword= isset($_POST["pasword"])?$_POST["pasword"]:FALSE;
 
           $error=array();
        if(empty($email)){
 
            $error["email"]="inserte un email";
 
        }
 
        if(empty($pasword)){
 
            $error["pasword"]="inserte un pasword ";
 
        }
 
 
 
        if(count($error)==0){
 
            $ye=new usuario();
            $ye->setEmail($email);
            $ye->setPasword($pasword);
 
            $oe=$ye->comprobar();
 
        if(is_object($oe) ){
 
            $wer=$oe->rol;
            if($wer=="admin"){
            $_SESSION["admin"]=$oe;}
 
            else{
                $_SESSION["user"]=$oe;
 
            }
           header("Location:".base_url."producto/medio");
    }
    else{$_SESSION["error"]["general"]="error al conectarse";
    header("Location:".base_url."usuario/iniciosesion");}
 
            }
 
    else{$_SESSION["error"]=$error;
    header("Location:https://royalramos.000webhostapp.com/usuario/iniciosesion");}
 
        }
}
 
function cerrar(){
 
    session_destroy() ;
    header("Location:".base_url."usuario/iniciosesion");
 
 
}
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de joel
Val: 3.828
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Warning: Cannot modify header information - headers already sent by...

Publicado por joel (1269 intervenciones) el 24/05/2020 10:29:05
Hola Rodrigo, hay varios posts con este mismo error...

Se debe a que intentar hacer una dirección cuando ya has enviado contenido al navegador!!

En tu caso, puedes ser los include... habría que verlo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar