Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/11/2010, 11:03
daneco1720
 
Fecha de Ingreso: noviembre-2010
Mensajes: 105
Antigüedad: 13 años, 5 meses
Puntos: 0
Exclamación error de session

tengo un problema con el start session() me crea el siguiente error
warning: cannot modify headers already sent by (output started at C:\xampp\php\PEAR\adodb\adodb.inc.php:483\)in C:\xampp\htdocs\prograwe\practica\valid.php on line 16
userpass.php
<html>
<head>
<title>Autentificación PHP</title>
</head>
<body>
<h1>Autentificación De Usuario</h1>
<form action="valid.php" method="POST">
<table align="center" width="225" cellspacing="2" cellpadding="2" border="0">
<tr>
<td colspan="2" align="center"
<?php if ($_GET["errorusuario"]=="si"){?>
bgcolor=red><span style="color:ffffff"><b>Datos incorrectos</b></span>
<?php }else{?>
bgcolor=#cccccc>Introduce tu clave de acceso
<?php }?></td>
</tr>
<tr>
<td align="right">USER:</td>
<td><input type="Text" name="usuario" size="8" maxlength="50"></td>
</tr>
<tr>
<td align="right">PASSWD:</td>
<td><input type="password" name="contrasena" size="8" maxlength="50"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="Submit" value="ENTRAR"></td>
</tr>
</table>
</form>
</body>
</html>
---------------------------------
<?php
include_once "bd/base_anotador.php";//inicializa la base de datos
include_once 'bd/table.php';//funciones para una tabla
$usuario=$_POST['usuario'];
$contrasena=$_POST['contrasena'];
$base->debug_on(true);
$tbl=new table('cliente',$base);
global $tbl;
$x = $tbl->select('*',"usuario='$usuario' and contrasena='$contrasena'","' '");
if ($x->numrows()!=0){
session_start();
session_register("autentificado");
$autentificado = "SI";
header("Location:servicios.php");
}else {
header("Location:userpass.php?errorusuario=si");
}
?>
------------------------------------------
<?php

include_once 'base.php';

class table
{
public $table_name;

private $base=null;
private $campos = array();
public $rs=null;

//************************************************** ******
public function __construct($table='', $base=null)
{
$this->table_name = $table;
$this->base = &$base;
}
//************************************************** ******
public function __set($name, $value)
{
$this->campos[$name] = $value;
}
//************************************************** *******
public function __get($name)
{
$ret = null;

if (array_key_exists($name, $this->campos))
$ret = $this->campos[$name];

if ($name == 'RecordCount')
{if ($this->rs)
$ret = $this->rs->RecordCount();
else
$ret = -1;
}

if ($name == 'Registro')
$ret = $this->campos;
return $ret;
}
//************************************************** ******
private function GetFields() // doesn´t work with empty table
{
$sql = "select * from {$this->table_name}";
$rs = $this->base->dosql_limit($sql, 1);
return $rs->fields;
}
//************************************************** ******
public function AutoLoadFields()
{
$this->campos = $this->GetFields();
}
//************************************************** ******
function Save()
{
$this->base->Insert($this->table_name, $this->campos);
}

//************************************************** ******
function AssignFields($valores) // Asigna un arreglo de campos
{
$campos = $this->GetFields();
foreach($valores as $key => $val)
{
if (array_key_exists($key, $campos))
$registro[$key]=$val;
}
// var_dump($registro);
$this->campos = $registro;
}
//************************************************** ******
function SaveArray($valores) // recibe arregelo de campos y los almacena en la tabla
{
$this->AssignFields($valores);
$this->Save();
}
//************************************************** ******
function Update($where=false)
{
$this->base->Update($this->table_name, $this->campos,'UPDATE', $where);
}
//************************************************** ******
function InsUpd($key='', $autoquote=false)
{
if ($key == '') $key = $campos[0]; // primer campo id por defecto
$this->base->InsUpd($this->table_name, $this->campos, $key, $autoquote);
}
//************************************************** ******
function Select($campos, $where='', $orderfield='')
{
if ($where != '') $where = " where $where";
if ($orderfield != '') $orderfield = " order by $orderfield";
$sql = "select $campos from {$this->table_name} $where $orderfield";
$this->rs = $this->base->dosql($sql);
if ($this->rs)
$this->campos = $this->rs->fields;
return($this->rs);
}
//************************************************** ******
function Find($valor, $campo_where='') // por defecto busca por la llave primaria
{
if ($campo_where == '') $campo_where = $this->base->GetPK($this->table_name);
return $this->Select('*', "$campo_where = '$valor' ");
}
//************************************************** ******
function Delete($valor, $campo_where='') // por defecto borra por la llave primaria
{
$res = false;
if ($this->Find($valor, $campo_where))
{$res = true;
if ($campo_where == '') $campo_where = $this->base->GetPK($this->table_name);
while(!$this->rs->EOF)
{
$val_campo = $this->rs->fields[$campo_where];
$sql = "delete from {$this->table_name} where $campo_where = $val_campo";
$this->base->dosql($sql);
$this->rs->MoveNext();
}
}
return($res);
}
//************************************************** ******
function GetCombo($name, $id='', $valor='', $defa='')
{$cam = $this->campos;
reset($cam); // echo '-->'.key($cam);
if ($id == '')
{$id = key($cam); next($cam);}
if ($valor == '') $valor = key($cam);
// var_dump($id); var_dump($valor);
while(!$this->rs->EOF)
{ $key = $this->rs->fields[$id];
$val = $this->rs->fields[$valor];
$opt .= "<option value = \"$key\">$val</option>\n";
$this->rs->MoveNext();
}
$res = "<select name=\"$name\">\n$opt\n</select>";
return($res);
}
//************************************************** ******
function ShowRecord()
{
echo "<pre>";
var_dump($this->campos);
echo "</pre>";
}
//************************************************** ******
function GetRows($field='')
{$res = '';
if (($this->rs == null) || (!is_array($this->campos))) return('');
if ($field == '') $field = key(($this->campos));
while(!$this->rs->EOF)
{ $res .= $this->rs->fields[$field]."<br/>\n";
$this->rs->MoveNext();
}
return($res);
}
//************************************************** ******
function Error()
{
return($this->base->ErrorNo() != 0);
}
//************************************************** ******

}
?>