buenos dias necesito ayuda con el inicio de sesion.
tengo el siguiente codigo en la pagina del formulario.
Código HTML:
Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link type="text/css" rel="stylesheet" href="estilos/estilos.css" />
<script type="text/ecmascript" language="javascript">
var cursor;
if (document.all) {
cursor='hand';
} else {
cursor='pointer';
}
function valida(){
var mensaj="";
if(document.getElementById("usu").value=="") mensaj += " Debes de escribir tu nombre de usuario\n ";
if(document.getElementById("pass").value=="") mensaj += "Debes de escribir tu contraseña ";
if(mensaj != ""){
alert("" + mensaj);
}else{
document.getElementById("frm1").submit();
}
}
<body topmargin="0" leftmargin="0">
<form action="login.php" class="aCentro" method="post" name="frm1" id="frm1"> <table width="327" height="159" border="0" align="center" cellpadding="0" cellspacing="0" style="border-top-color:#CCC"> <tr class="cabeceraTabla"> <td colspan="2">inicio de sesi
Ón
</td> <td width="165">Usuario
</td> <input name="usu" type="text" class="cajaMedia" id="usu" /> <input name="pass" type="text" class="comboMedio" id="pass" /> <td colspan="2"> <div align="center"><img src="img/Aceptar.gif" width="100" height="24" onmouseover="style.cursor=cursor" onclick="valida()" /></div></td>
y en la de loging el siguiente
Código PHP:
Ver original<?php
include("conec.php");
$usu=$_POST['usu'];
$pass=$_POST['pass'];
$sql="SELECT * FROM usuarios WHERE usuario = '$usu'";
echo "<script>";
echo "alert('No existe el usuario introducido')";
echo "</script>";
echo "<head><meta http-equiv='refresh' content='0; url=index.php?error=15638'></ head>";
}else{
if($array["pass"]== $pass){
if($array["tipo"] == "Administrador"){
$_SESSION["Usuario"]=$usu;
$_SESSION["Passw"]=$pass;
$_SESSION["pass"]=$array["nombre"];
$_SESSION["Empresa"]=$array["empresa"];
echo "<head><meta http-equiv='refresh' content='0; url=/proyecto/ADMIN/index.php?session=true'></head>";
}else{
if($array["tipo"] == "Mtto"){
$_SESSION["Usuario"]=$usu;
$_SESSION["Passw"]=$pass;
$_SESSION["pass"]=$array["nombre"];
$_SESSION["Empresa"]=$array["empresa"];
echo "<head><meta http-equiv='refresh' content='0; url=/proyecto/MTTO/index.php?session=true'></head>";
}else{
if($array["tipo"] == "Visual"){
$_SESSION["Usuario"]=$usu;
$_SESSION["Passw"]=$pass;
$_SESSION["pass"]=$array["nombre"];
$_SESSION["Empresa"]=$array["empresa"];
echo "<head><meta http-equiv='refresh' content='0; url=/proyecto/VSL/index.php?session=true'></head>";
}
}
}
}else{
echo "<script>";
echo "alert('La contraseña es incorrecta')";
echo "</script>";
echo "<head><meta http-equiv='refresh' content='0; url=index.php?error=15838'></head>";
}
}
?>
y al momento en el que conprueba los datos me da acceso a la pagina la cual deseo pero el probleme es que al comprobar me da el siguiente error:
Notice: A session had already been started - ignoring session_start() in C:\wamp\www\proyecto\login.php on line 4
Call Stack
# Time Memory Function Location
1 0.0008 378808 {main}( ) ..\login.php:0
2 0.0046 385960 session_start ( ) ..\login.php:4
Ademas por otra parte al cerrar sesion e insertar la url de la pagina da acceso sin tener iniciada la sesion aqui les dejo el codigo para que los chequen
pagina de aceptacion de usuario:
Código PHP:
Ver original<?php
echo "error";
header("location:../index.php"); }else{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pagina Princiapal</title>
</head>
<link href="../estilos/estilos.css" type="text/css" rel="stylesheet" />
<body>
pagina del administrador
<?php
echo "<font size=8> Bienvenido: ".$_SESSION["Usuario"]. "</font>";
?>
<a href="../logout.php">cerrar sesion </a>
</body>
</html>
<?php
}
?>
y pagina de cerrar sesion :
Código PHP:
Ver original<?
echo "no hay sesion";
} else {
echo "<head><meta http-equiv='refresh' content='0; url=index.php?sesion=exit'></head>";
}
?>