Código PHP:
<?php session_start();
include 'conexion.php';
if ($_POST['username']) {
//Comprobacion del envio del nombre de usuario y password
$username=$_POST['username'];
$password=$_POST['password'];
if ($password==NULL) {
echo ("<script language='javascript'>
alert('Intrudusca la contraseña')
var pagina='index.php'
location.href=pagina</script>");
}else{
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['password'] != $password) {
echo ("<script language='javascript'>
alert('Datos incorrectos verifique!!!')
var pagina='index.php'
location.href=pagina</script>");
}else{
$query = mysql_query("SELECT username,password,nombre,cedula FROM users WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);
$_SESSION["s_username"] = $row['username'];
$_SESSION["s_cedula"] = $row['cedula'];
mysql_query ("UPDATE users SET conect = 1 WHERE username = '$user'")or die(mysql_error());
echo ("<script language='javascript'>
alert('Bienvenido!!!')
var pagina='priv/index.php'
location.href=pagina</script>");
}
}
}
?>
Código PHP:
<?php
session_start();?>
<?php
if (isset($_SESSION["s_username"])) { ?>
Código PHP:
<?php }else{
echo ("<script language='javascript'>
alert('Esta pagina es privada, no tiene los permisos necesarios post')
var pagina='../index.php'
location.href=pagina</script>");
} ?>
algen sabe que pasara?