Foros del Web » Creando para Internet » Diseño web »

como hacer un login en el index

Estas en el tema de como hacer un login en el index en el foro de Diseño web en Foros del Web. hola buenas bueno lo que quiero es hacer un login que se vea a un costado de la pagina y que cuando no introdusca el ...
  #1 (permalink)  
Antiguo 07/01/2013, 16:13
 
Fecha de Ingreso: enero-2013
Mensajes: 8
Antigüedad: 11 años, 3 meses
Puntos: 1
Pregunta como hacer un login en el index

hola buenas bueno lo que quiero es hacer un login que se vea a un costado de la pagina y que cuando no introdusca el usuario y contraseña apareca los datos del usuario en ves del login he utilizado Dreamweaver Para crear el login


les agradeceria su ayuda
  #2 (permalink)  
Antiguo 07/01/2013, 18:49
 
Fecha de Ingreso: marzo-2011
Mensajes: 342
Antigüedad: 13 años, 1 mes
Puntos: 97
Respuesta: como hacer un login en el index

Hola, para eso se precisa lenguaje de servidor, java, c#, php, etc., los usuarios van contra un repositorio de datos (en general una base) y se chequea que el logueo haya sido correcto, si buscás en el foro vas a encontrar mucho del tema, salvo que quieras algo muy básico como por ejemplo usar javascript y user/pass por defecto, saludos
  #3 (permalink)  
Antiguo 07/01/2013, 20:55
 
Fecha de Ingreso: enero-2013
Mensajes: 8
Antigüedad: 11 años, 3 meses
Puntos: 1
Respuesta: como hacer un login en el index

hola sebastopols muchas gracias por tu respuesta pero noes exactamente lo que busco yo busca mas algo como el login de estas paginas
[URL="http://zonablackberry.com.ve"]zonablackberry[/URL]
[URL="http://wowlatinoamerica.com"]wowlatinoamerica[/URL]
un login en el que te puedes mover entre paginas y va a salir tus datos
  #4 (permalink)  
Antiguo 07/01/2013, 21:34
Avatar de pitufoweb  
Fecha de Ingreso: enero-2008
Ubicación: Un Mundo Raro
Mensajes: 1.148
Antigüedad: 16 años, 3 meses
Puntos: 181
Respuesta: como hacer un login en el index

y como has hecho el login?




Saludos
__________________
------------- " La felicidad no llega de afuera, nace desde dentro. " -------------
  #5 (permalink)  
Antiguo 08/01/2013, 00:45
 
Fecha de Ingreso: enero-2013
Mensajes: 8
Antigüedad: 11 años, 3 meses
Puntos: 1
Pregunta Respuesta: como hacer un login en el index

Cita:
Iniciado por pitufoweb Ver Mensaje
y como has hecho el login?




Saludos
bueno el codigo del login es este


Código PHP:
<?php require_once('Connections/sitiolg.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['user'])) {
  
$loginUsername=$_POST['user'];
  
$password=$_POST['pass'];
  
$MM_fldUserAuthorization "nAdmin";
  
$MM_redirectLoginSuccess "inicio.php";
  
$MM_redirectLoginFailed "index.php";
  
$MM_redirecttoReferrer false;
  
mysql_select_db($database_sitiolg$sitiolg);
      
  
$LoginRS__query=sprintf("SELECT strUser, strPass, nAdmin FROM login WHERE strUser=%s AND strPass=%s",
  
GetSQLValueString($loginUsername"text"), GetSQLValueString($password"text")); 
   
  
$LoginRS mysql_query($LoginRS__query$sitiolg) or die(mysql_error());
  
$loginFoundUser mysql_num_rows($LoginRS);
  if (
$loginFoundUser) {
    
    
$loginStrGroup  mysql_result($LoginRS,0,'nAdmin');
    
    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 );
  }
}
?>
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction?>">
  <p>
    <label for="user">user</label>
    <input type="text" name="user" id="user" />
  </p>
  <p>
    <label for="pass">pass</label>
    <input type="text" name="pass" id="pass" />
  </p>
  <p>
    <input type="submit" name="button" id="button" value="Enviar" />
  </p>
</form>
ese es el del login
este el que use para que me devolviera los datos

Código PHP:
<?php require_once('Connections/sitiolg.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 "Untitled-8.php";
  if (
$logoutGoTo) {
    
header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  
session_start();
}
$MM_authorizedUsers "s,n";
$MM_donotCheckaccess "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers$strGroups$UserName$UserGroup) { 
  
// For security, start by assuming the visitor is NOT authorized. 
  
$isValid False

  
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  
if (!empty($UserName)) { 
    
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    
$arrUsers Explode(","$strUsers); 
    
$arrGroups Explode(","$strGroups); 
    if (
in_array($UserName$arrUsers)) { 
      
$isValid true
    } 
    
// Or, you may restrict access to only certain users based on their username. 
    
if (in_array($UserGroup$arrGroups)) { 
      
$isValid true
    } 
    if ((
$strUsers == "") && false) { 
      
$isValid true
    } 
  } 
  return 
$isValid
}

$MM_restrictGoTo "index.php";
if (!((isset(
$_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers$_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  
$MM_qsChar "?";
  
$MM_referrer $_SERVER['PHP_SELF'];
  if (
strpos($MM_restrictGoTo"?")) $MM_qsChar "&";
  if (isset(
$_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0
  
$MM_referrer .= "?" $_SERVER['QUERY_STRING'];
  
$MM_restrictGoTo $MM_restrictGoTo$MM_qsChar "accesscheck=" urlencode($MM_referrer);
  
header("Location: "$MM_restrictGoTo); 
  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;
}
}

$colname_Recordset1 "-1";
if (isset(
$_SESSION['MM_Username'])) {
  
$colname_Recordset1 $_SESSION['MM_Username'];
}
mysql_select_db($database_sitiolg$sitiolg);
$query_Recordset1 sprintf("SELECT * FROM login WHERE strUser = %s"GetSQLValueString($colname_Recordset1"text"));
$Recordset1 mysql_query($query_Recordset1$sitiolg) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
mysql_free_result($Recordset1); 
?>
<p><?php echo $row_Recordset1['strUser']; ?></p>
<p><?php echo $row_Recordset1['strEmail']; ?></p>
<p><?php echo $row_Recordset1['strCreditos']; ?></p>

<?php if($_SESSION['MM_UserGroup'] == 's'){ ?>

<p>&nbsp;</p>
<p><a href="zerkc.comze.com">hola mundo</a></p>
<p>
  <?php } else{ ?>
  <?php ?>
  
  

<a href="<?php echo $logoutAction ?>">desconectar</a>

</p>
ahora lo que quiero es lograr algo como esto

mas o menos







pero noc como utilizar los dos codigos en una misma pagina que si el usuario no se a logeado salga ingresar user y contraseña y si se logueo salgan sus datos en cada una de las paginas
  #6 (permalink)  
Antiguo 08/01/2013, 15:45
 
Fecha de Ingreso: enero-2013
Mensajes: 8
Antigüedad: 11 años, 3 meses
Puntos: 1
De acuerdo Respuesta: como hacer un login en el index

buenas muchas gracias a los que me intentaron ayudar se los agradesco porfin logre solucionar mi problema solo tube que poner un if que contubiera mi variable de inicio de seccion y listo y hacer que en todos los casos se diriguiera a la misma pagina


Código PHP:
<?php require_once('Connections/sitiolg.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['user'])) {
  
$loginUsername=$_POST['user'];
  
$password=$_POST['pass'];
  
$MM_fldUserAuthorization "nAdmin";
  
$MM_redirectLoginSuccess "index2.php";
  
$MM_redirectLoginFailed "index2.php";
  
$MM_redirecttoReferrer false;
  
mysql_select_db($database_sitiolg$sitiolg);
      
  
$LoginRS__query=sprintf("SELECT strUser, strPass, nAdmin FROM login WHERE strUser=%s AND strPass=%s",
  
GetSQLValueString($loginUsername"text"), GetSQLValueString($password"text")); 
   
  
$LoginRS mysql_query($LoginRS__query$sitiolg) or die(mysql_error());
  
$loginFoundUser mysql_num_rows($LoginRS);
  if (
$loginFoundUser) {
    
    
$loginStrGroup  mysql_result($LoginRS,0,'nAdmin');
    
    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 );
  }
}
  
  if (isset(
$_SESSION['MM_Username'])) {
      include(
"inicio.php");
  }
    else {
?>
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction?>">
  <p>
    <label for="user">user</label>
    <input type="text" name="user" id="user" />
  </p>
  <p>
    <label for="pass">pass</label>
    <input type="text" name="pass" id="pass" />
  </p>
  <p>
    <input type="submit" name="button" id="button" value="Enviar" />
  </p>
</form>
<?php }?>

Etiquetas: dreamweaver
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 19:46.