Foros del Web » Creando para Internet » HTML »

[SOLUCIONADO] Usuario y contraseña

Estas en el tema de Usuario y contraseña en el foro de HTML en Foros del Web. Bueno ya tengo mi usuario y con clave, pero no se como hacer que cuando el usuario ya ingreso muestre en la pagina que a ...
  #1 (permalink)  
Antiguo 24/02/2015, 02:03
 
Fecha de Ingreso: febrero-2015
Mensajes: 3
Antigüedad: 9 años, 2 meses
Puntos: 0
Pregunta Usuario y contraseña

Bueno ya tengo mi usuario y con clave, pero no se como hacer que cuando el usuario ya ingreso muestre en la pagina que a ingresado, y de ahí poder salir (Cerrar Sesión)

PD: apenas soy una aprendis en esto D:

[HTML]
<title>Usuario</title>
<body>
<script>
function usrpas(){
if (document.form1.txt.value=="admin1" && document.form1.num.value=="1234" || document.form1.txt.value=="admin2" && document.form1.num.value=="1234"){window.location= "Index.html"}

else {alert("Error en Usuario o Contraseña. Intenta de nuevo.")}
}
document.oncontextmenu=new Function("return false");
</script>
<form method="post" enctype="application/x-www-form-urlencoded" name="form1">

<p><span class="Estilo4">Usuario</span>
<input name="txt" type="text" size="10" maxlength="10" />
</p>
<p> <span class="Estilo4">Contraseña</span>
<input name="num" type="password" size="8" maxlength="8" />
<label for="imageField"></label>
.</p>
<p>
<input name="button" type="reset" onclick="usrpas()" value="Entrar" />
<label for="Submit"></label>
</p>
</form>
</body>
</hml>
  #2 (permalink)  
Antiguo 24/02/2015, 09:27
Colaborador
 
Fecha de Ingreso: septiembre-2013
Ubicación: España
Mensajes: 3.648
Antigüedad: 10 años, 7 meses
Puntos: 578
Respuesta: Usuario y contraseña

Los formularios de autentificación se comprueban desde el servidor, no con JS.
  #3 (permalink)  
Antiguo 24/02/2015, 10:05
 
Fecha de Ingreso: febrero-2015
Ubicación: colobmia
Mensajes: 5
Antigüedad: 9 años, 2 meses
Puntos: 0
Respuesta: Usuario y contraseña

buenos días

dmnt tendrías que hacer algo asi:

inicio.php

<?php require_once('Connections/conex_usuarios.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['usuario'])) {
$loginUsername=$_POST['usuario'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "inicio.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_conex_usuarios, $conex_usuarios);

$LoginRS__query=sprintf("SELECT usuario, password FROM usuario WHERE usuario=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $conex_usuarios) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!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>Documento sin título</title>
</head>

<body>
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<table width="200" border="0" align="center">
<tr>
<td>Usuario</td>
<td><label for="usuario"></label>
<input type="text" name="usuario" id="usuario" /></td>
</tr>
<tr>
<td>Contraseña</td>
<td><label for="password"></label>
<input type="text" name="password" id="password" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="button" id="button" value="Ingresar" /></td>
</tr>
</table>
</form>
</body>
</html>


index.php

<?php require_once('Connections/conex_usuarios.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);

$logoutGoTo = "inicio.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_conex_usuarios, $conex_usuarios);
$query_usuario = "SELECT * FROM usuario";
$usuario = mysql_query($query_usuario, $conex_usuarios) or die(mysql_error());
$row_usuario = mysql_fetch_assoc($usuario);
$totalRows_usuario = mysql_num_rows($usuario);
?>
<!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>Documento sin título</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<table width="345" border="0" align="right">
<tr>
<td width="122">Usurio Conectado:</td>
<td width="105"><?php echo $row_usuario['usuario']; ?></td>
<td width="104"><a href="<?php echo $logoutAction ?>">Desconectar</a></td>
</tr>
</table>
</form>
<p>&nbsp;</p>
<h2>Bienvenido al index
</h2>
</body>
</html>
<?php
mysql_free_result($usuario);
?>

la conexión.

conex_usuarios.php

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conex_usuarios = "localhost";
$database_conex_usuarios = "usuarios";
$username_conex_usuarios = "root";
$password_conex_usuarios = "";
$conex_usuarios = mysql_pconnect($hostname_conex_usuarios, $username_conex_usuarios, $password_conex_usuarios) or trigger_error(mysql_error(),E_USER_ERROR);
?>

saludos
  #4 (permalink)  
Antiguo 27/02/2015, 15:55
 
Fecha de Ingreso: febrero-2015
Mensajes: 3
Antigüedad: 9 años, 2 meses
Puntos: 0
Respuesta: Usuario y contraseña

Pero yo solo lo ocupo para html O_O php no, esta muy bueno el programa gracias por la dedicacion

pero lo único que ocupo es el botón de cerrar sesión en index o inicio que es este que tengo,
Cita:
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Index</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml;charset=utf-8" />
<meta http-equiv="Cache-Control" content="max-age=3600"/>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
left:17px;
top:25px;
width:61px;
height:52px;
z-index:1;
}
#Layer2 {
position:absolute;
left:83px;
top:37px;
width:214px;
height:38px;
z-index:2;
}
#Layer3 {
position:absolute;
left:38px;
top:114px;
width:69px;
height:52px;
z-index:3;
}
#Layer4 {
position:absolute;
left:117px;
top:123px;
width:164px;
height:36px;
z-index:4;
background-color: #CCCC99;
}
.Estilo3 {
font-size: 18px;
font-family: "Times New Roman", Times, serif;
color: #003399;
}
#Layer5 {
position:absolute;
left:117px;
top:123px;
width:153px;
height:33px;
z-index:4;
}
#Layer6 {
position:absolute;
left:43px;
top:188px;
width:57px;
height:60px;
z-index:5;
}
#Layer7 {
position:absolute;
left:130px;
top:193px;
width:125px;
height:37px;
z-index:6;
}
.Estilo5 {color: #CC3300}
#Layer8 {
position:absolute;
left:461px;
top:44px;
width:135px;
height:57px;
z-index:7;
}
#Layer9 {
position:absolute;
left:47px;
top:263px;
width:55px;
height:49px;
z-index:8;
}
#Layer10 {
position:absolute;
left:128px;
top:273px;
width:132px;
height:25px;
z-index:9;
}
#Layer11 {
position:absolute;
left:46px;
top:338px;
width:55px;
height:52px;
z-index:10;
}
#Layer12 {
position:absolute;
left:119px;
top:345px;
width:136px;
height:24px;
z-index:11;
}
.Estilo6 {color: #006699; font-size: 24px; }
#Layer13 {
position:absolute;
left:47px;
top:409px;
width:54px;
height:50px;
z-index:12;
}
#Layer14 {
position:absolute;
left:129px;
top:416px;
width:129px;
height:38px;
z-index:13;
}
#Layer15 {
position:absolute;
left:160px;
top:515px;
width:34px;
height:40px;
z-index:14;
}
#Layer16 {
position:absolute;
left:27px;
top:505px;
width:241px;
height:41px;
z-index:14;
}
#Layer17 {
position:absolute;
left:20px;
top:503px;
width:111px;
height:25px;
z-index:14;
}
#Layer18 {
position:absolute;
left:227px;
top:499px;
width:67px;
height:32px;
z-index:15;
}
.Estilo7 {
font-size: 10px;
color: #0066CC;
}
.Estilo8 {color: #006699; }
-->
</style>
</head>

<body>
<div id="Layer1">
<div align="left">
<p align="center"><img src="http://www.forosdelweb.com/f4/inicio/logo2.jpg" alt="logo" width="60" height="60" /></p>
</div>
</div>
<div id="Layer2">
<div align="center">
<h1 class="Estilo3">Universidad Multitecnica Profesional </h1>
</div>
</div>
<div id="Layer3">
<div align="center"><img src="http://www.forosdelweb.com/Imagenes/1387072174_books.png" alt="logo" width="50" height="50" /></div>
</div>
<div id="Layer5">
<h1 class="Estilo8"><a href="http://www.forosdelweb.com/f4/Modulo materia/Mat-Cal.html">Calificacion</a></h1>
</div>
<div id="Layer6">
<div align="center"><img src="http://www.forosdelweb.com/Imagenes/la-seguridad-del-usuario--forma-la-mitad-del-cuerpo_318-32249.jpg" alt="alumno" width="50" height="50" /></div>
</div>
<div id="Layer7">
<h1 align="center" class="Estilo8">Alumno</h1>
</div>
<div id="Layer9"><img src="http://www.forosdelweb.com/Imagenes/icono_profesor.png" alt="informacion" width="50" height="50" /></div>
<div id="Layer10">
<center>
<h2 class="Estilo8"> Información </h2>
</center>
</div>
<div id="Layer11">
<div align="center"><img src="http://www.forosdelweb.com/Imagenes/usuario-escudo-simbolo-interfaz-para-la-seguridad_318-63497.jpg" alt="administracion" width="50" height="50" /></div>
</div>
<div id="Layer12">
<center>
<h1 class="Estilo6"> Admnistración </h1>
</center>
</div>
<div id="Layer13"><img src="http://2.bp.blogspot.com/-TFwGk-TiEB4/Ua-K70K3rcI/AAAAAAAAEdo/WYl9yIrfwdg/s1600/contacto.gif" alt="contacto" width="50" height="50"/></div>
<div id="Layer14">
<h1 class="Estilo5">
<center>
<span class="Estilo8"><a href="http://www.forosdelweb.com/f4/Contacto/Contacto.html">Contacto</a></span>
</center>
</h1>
</div>
<div id="Layer17">
<form id="form1" method="post" action="">
<p>
<label>
<input type="button" value="Cerrar Seccion" onclick="cerrar()" />
</label>
</p>
</form>
</div>
<div id="Layer18">(<span class="Estilo7">UMP</span>)&copy;</div>
<table width="296" border="0" cellpadding="0" cellspacing="1">
<!--DWLayoutTable-->
<tr>
<td width="294" height="466" valign="top"><p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p> <p>&nbsp;</p></td>
</tr>
<tr>
<td height="78">&nbsp;</td>
</tr>
</table>
</body>
</html>

en esta parte es donde me gustaria para cuando el usuario desea salir
  #5 (permalink)  
Antiguo 28/02/2015, 03:36
Colaborador
 
Fecha de Ingreso: septiembre-2013
Ubicación: España
Mensajes: 3.648
Antigüedad: 10 años, 7 meses
Puntos: 578
Respuesta: Usuario y contraseña

Debes contratar un plan de alojamiento que te proporcione un lenguaje para el back-end.

Etiquetas: html5, movil, usuario+contraseña
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:16.