Foros del Web » Programando para Internet » PHP »

Nombre de Usuario

Estas en el tema de Nombre de Usuario en el foro de PHP en Foros del Web. Hola soy nuevo en esto del php... bueno pienso hacer una web donde tengan que registrarse...eso no es problema pero quiero que despues de registrarse ...
  #1 (permalink)  
Antiguo 21/08/2004, 20:37
Avatar de Rebel001  
Fecha de Ingreso: enero-2004
Mensajes: 140
Antigüedad: 20 años, 3 meses
Puntos: 0
Nombre de Usuario

Hola soy nuevo en esto del php... bueno pienso hacer una web donde tengan que registrarse...eso no es problema pero quiero que despues de registrarse en una tabla o una layer diga "bienbenido (nombre de usuario)"... aparte tengo otro problema nesecito que por decir los usuarios no registrados no puedan ver la pagina index2.php (por ejemplo) que seria la que contiene todo el contenido








.::GRACIAS::.
  #2 (permalink)  
Antiguo 21/08/2004, 20:50
 
Fecha de Ingreso: agosto-2004
Mensajes: 4
Antigüedad: 19 años, 8 meses
Puntos: 0
Hola:

Yo tampoco soy experto en la programacion, pero a ver si te sirve mi granito de arena. Yo utilizaría Sesiones. Una sesion se inicializa de la siguiente forma:

Código PHP:
<?php 
session_start
(); 
echo 
'he inicializado la sesión'
?>
y se cierra si mal no recuerdo con "session_close()";

De todas formas, como querras tener unos cuantos usuarios, (como es mi caso), aqui tienes una base que te puede ir muy bien.

Con lo siguiente vinculas MySQL para meter multitud de usuarios.


Código PHP:
<?php
//conecto con la base de datos 
$conn mysql_connect("servidor","usuario","password"); 
//selecciono la BBDD 
mysql_select_db("nombre_bbdd",$conn); 

//Sentencia SQL para buscar un usuario con esos datos 
$ssql "SELECT * FROM usuario WHERE nombre_usuario='$usuario' and clave_usuario='$contrasena'"

//Ejecuto la sentencia 
$rs mysql_query($ssql,$conn); 

//vemos si el usuario y contraseña es váildo 
//si la ejecución de la sentencia SQL nos da algún resultado 
//es que si que existe esa conbinación usuario/contraseña 
if (mysql_num_rows($rs)!=0){ 
    
//usuario y contraseña válidos 
    //defino una sesion y guardo datos 
    
session_start(); 
    
session_register("autentificado"); 
    
$autentificado "SI"
    
header ("Location: aplicacion.php"); 
}else { 
    
//si no existe le mando otra vez a la portada 
    
header("Location: index.php?errorusuario=si"); 

mysql_free_result($rs); 
mysql_close($conn); 
?>
Espero haberte ayudado....

Un saludo

Slimer
  #3 (permalink)  
Antiguo 23/08/2004, 21:48
Avatar de Rebel001  
Fecha de Ingreso: enero-2004
Mensajes: 140
Antigüedad: 20 años, 3 meses
Puntos: 0
mmm

Gracias pero quizá no me entiendas lo que nesecito esque despues de logearse en un texto diga "bienvenido (nombre de usuario) " osea que en donde dice "nombre de user" me detecte automaticamente cual es el nick o el nombre.







Gracias
  #4 (permalink)  
Antiguo 23/08/2004, 21:55
Avatar de Rebel001  
Fecha de Ingreso: enero-2004
Mensajes: 140
Antigüedad: 20 años, 3 meses
Puntos: 0
mas menos así

no mientras se esta conectando si no cuando esta en la pagina index2.php:

<?php
//initialize the 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_unregister('MM_Username');
session_unregister('MM_UserGroup');

$logoutGoTo = "/indexx.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
session_start();
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** 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 == "") && true) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "/indexx.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($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<style type="text/css">
<!--
a:link, a:active, a:visited {
color: #4A265A;
text-decoration: underline}

a:hover {
color: #4A265A;
text-decoration: none}

body {
background-image: URL(images/bg.jpg);
background-repeat: repeat-x}
a:link {
color: #FFFFFF;
}
a:visited {
color: #0066FF;
}
.Estilo1 {color: #FFFFFF}

-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>

<body bgcolor="#000000" marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">

<layer src="phptagcool/phptagcool.php" div id="Layer1" style="position:absolute; left:18px; top:258px; width:103px; height:122px; z-index:1; visibility: inherit;"></div>
<table width="780" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="images/mec_temp4_01.jpg" width="120" height="77"></td>
<td colspan="7"><img src="images/your_logo.jpg" width="540" height="77"></td>
<td><img src="images/mec_temp4_03.jpg" width="120" height="77"></td>
</tr>

<tr>
<td><img src="images/mec_temp4_04.jpg" width="120" height="23"></td>
<td><img src="images/mec_temp4_05.jpg" width="105" height="23"></td>
<td><img src="images/mec_temp4_06.jpg" width="40" height="23"></td>
<td><img src="images/mec_temp4_07.jpg" width="105" height="23"></td>
<td><img src="images/mec_temp4_08.jpg" width="40" height="23"></td>
<td><img src="images/mec_temp4_09.jpg" width="105" height="23"></td>
<td><img src="images/mec_temp4_10.jpg" width="40" height="23"></td>
<td><img src="images/mec_temp4_11.jpg" width="105" height="23"></td>
<td><img src="images/mec_temp4_12.jpg" width="120" height="23"></td>
</tr>

<tr>
<td><img src="images/mec_temp4_13.jpg" width="120" height="25"></td>
<td><a href=""><img src="images/link_1.jpg" width="105" height="25" border="0" alt="link_1"></a></td>
<td><img src="images/mec_temp4_15.jpg" width="40" height="25"></td>
<td><a href=""><img src="images/link_2.jpg" width="105" height="25" border="0" alt="link_2"></a></td>
<td><img src="images/mec_temp4_17.jpg" width="40" height="25"></td>
<td><a href=""><img src="images/link_3.jpg" width="105" height="25" border="0" alt="link_3"></a></td>
<td><img src="images/mec_temp4_19.jpg" width="40" height="25"></td>
<td><a href=""><img src="images/link_4.jpg" width="105" height="25" border="0" alt="link_4"></a></td>
<td><img src="images/mec_temp4_21.jpg" width="120" height="25"></td>
</tr>

<tr>
<td><img src="images/mec_temp4_22.jpg" width="120" height="67"></td>
<td><img src="images/mec_temp4_23.jpg" width="105" height="67"></td>
<td><img src="images/mec_temp4_24.jpg" width="40" height="67"></td>
<td><img src="images/mec_temp4_25.jpg" width="105" height="67"></td>
<td><img src="images/mec_temp4_26.jpg" width="40" height="67"></td>
<td><img src="images/mec_temp4_27.jpg" width="105" height="67"></td>
<td><img src="images/mec_temp4_28.jpg" width="40" height="67"></td>
<td><img src="images/mec_temp4_29.jpg" width="105" height="67"></td>
<td><img src="images/mec_temp4_30.jpg" width="120" height="67"></td>
</tr>

</table>

<table width="780" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="5" height="205"><img src="images/spacer.gif" width="5" height="205"></td>
<td valign="top">

<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" valign="top"><img src="images/content_02.jpg" width="135" height="18"></td>
</tr>

<tr>
<td background="images/bg_panl.jpg" valign="top"><img src="images/content_12.jpg" width="11" height="164"></td>
<td width="114" height="166" rowspan="2" valign="top">
<span class="Estilo1"></span><br>
<!-- Side Panel -->

<font face="Arial" size="2" color="#ffffff"><strong>
IlTAG-BOARDll</strong></font>
<!-- Side Panel -->
</h3>
<p><iframe src="phptagcool/phptagcool.php" width="113" align="left" scrolling="yes" heigth="115"></iframe>
</p>
</p>
<p><a href="<?php echo $logoutAction ?>">Salir</a></p>
<p>&nbsp;</p></td>
<td background="images/bg_panr.jpg" valign="top"><img src="images/content_13.jpg" width="10" height="164"></td>
</tr>

<tr>
<td colspan="3" valign="top"><img src="images/content_16.jpg" width="135" height="21"></td>
</tr>
</table>

</td>
<td width="60" height="205"><img src="images/spacer.gif" width="60" height="205"></td>
<td valign="top">

<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" valign="top"><img src="images/content_04.jpg" width="520" height="18"></td>
</tr>

<tr>
<td background="images/bg_conl.jpg" valign="top" ><img src="images/content_14.jpg" width="10" height="164"></td>
<td width="500" height="166" rowspan="2" align="center" valign="top">
<br>
<!-- Content -->

<blockquote><font face="Arial" size="2" color="#ffffff"><strong>
Primera Prueba
</strong></font></blockquote>

<!-- Content -->

</td>
<td background="images/bg_conr.jpg" valign="top"><img src="images/content_15.jpg" width="10" height="164"></td>
</tr>

<tr>
<td colspan="3" valign="top"><img src="images/content_17.jpg" width="520" height="21"></td>
</tr>
</table>

</td>
</tr>
</table>

</body>
</html>
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 10:11.