PHP - registro de usuario con control

 
Vista:
sin imagen de perfil

registro de usuario con control

Publicado por julian (16 intervenciones) el 25/04/2013 20:28:50
hola bueno tengo aca todo andando pero tengo un problema quiero q me verifique el tema de ambas contraseñas si son iguales y q alli si q pueda entrar sino son iguales q me muestre un msj de error , asi como tengo por ams q sean diferentes lo registra. tambien me gustaria ponerle un minimo de x caracteres a la contraseña y tambien si el usuario ya tiene ese nick q le salga un aviso y bno pueda registrarse igual v, aqu8i van los codigos oijala me puedan ayudar saludos:
registroUsuario.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<html>
<head>
 
<script>
function cargarModo(){
	modo=formCli.txtmodo.value;
	validoForm();
}
 
function validoForm(){
	if (validoCamposOblig()== 1 ){
	        alert ("Se ha registrado correctamente");
		document.formCli.submit();
	}else{
 
	}
}
 
function validoCamposOblig(){
	if (formCli.usuario.value == "" || formCli.mail.value == "" || formCli.pass.value == "" || formCli.txtpasswConfirm.value == ""){
	     alert ("Debe completar todos los datos");
		return 0;
	 }else{
		return 1;
	}
}
 
function validarEmail(){
   	var valor = formCli.mail.value;
	if( !(/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(valor)) ) {
 		alert ("El mail debe contener @ y . (punto), y el formato debe ser ejemplo usuario@gmail.com");
		formCli.mail.focus();
		return 0;
	} else {
		return 1;
 
	}
 
}
 
 
function validarPassword(){
	var res=0;
	var largo= formCli.pass.value.length;
	var largo2= formCli.txtpasswConfirm.value.length;
 
 
	if ((largo>=6) && (largo2>=6)){
		if (formCli.pass.value==formCli.txtpasswConfirm.value){
			res=1;
		}else{
			alert("la passw no coincide con la verificacion");
			formCli.pass.focus();
		}
	}else{
		alert("el largo de la passw debe ser minimo 6");
		formCli.pass.focus();
 
	}
 
	return res;
}
 
 
</script>
 
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
<!--
body,td,th {
	color: #FFFFFF;
}
body {
	background-color: #000066;
}
a:link {
	color: #FFFFFF;
	text-decoration: none;
}
a:visited {
	color: #FFFFFF;
	text-decoration: none;
}
a:hover {
	color: #FF0000;
	text-decoration: none;
}
a:active {
	color: #FF0000;
	text-decoration: none;
}
.Estilo1 {color: #FFFF00}
a {
	font-size: 24px;
}
-->
</style>
</head>
<body >
<h1 class="Estilo1">Registro de usuario </h1>
<p class="Estilo1">* DATOS OBLIGATORIOS</p>
</head>
 
<body>
<td align="center" valign="top" class="subir Estilo1"><div align="center"><span class="Estilo7">Ir a  :<a href="../../index.php"> Home </a></span></div></td>
<form name="formCli" method="post" action="../usuariosInsertar.php">
	<table width="352" border="0">
 
  <tr>
    <td height="48" colspan="8"><div align="center" class="Estilo1"></div></td>
    </tr>
 
  <td>Nick::
    <td><input name="usuario" type="text" id="usuario" />
    *</td>
 
	</tr>
 
  <td>	Password:<td><input name="password" type="password" id="pass" value="" >
  *</td>
 
	</tr>
 
 
 
    <td>	Repita password:<td><input type="password" name="txtpasswConfirm" value="" >
    *</td>
 
 
 
	</tr>
 
	 <td>	Mail:<td><input type="mail" name="text" id="mail">
    *</td>
 
 
 
	</tr>
 
  <tr>
    <td colspan="3"><label>
	  <input type="button" value="Enviar" onClick="cargarModo()" >
	  <input type="hidden" size="2" name="txtmodo" value="">
 
    </label></td>
    </tr>
</table>
</form>
</body>
</html>


usuariosInsertaqr.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
	session_start();
 
	if(!isset($_SESSION["accion"]))
		header("location:../index.php");
	else
		session_unregister("accion");
 
	include("Conexion.php");
	$cant_usuarios=" SELECT count( * ) AS autorizado
FROM usuarios ";
	if($autorizado==0){
	$tipo=2;
	}
	else {
	$tipo=1;
	}
	$idUsuarios=$_POST["idUsuarios"];
	$nick=$_POST["usuario"];
	$pass=$_POST["password"];
 
 
	$sql="insert into usuarios(idUsuarios,nick,pass) values('$idUsuarios','$usuario','$pass')";
	$conn=new Conexion();
	$nro=$conn->actualizacion($sql);
	if($nro==-1){
		$_SESSION["msj"]="El nombre ya se encuentra registrado en el sistema";
		header("location:registro.php");
		}
	else{
		mkdir("../usuario/$usuario");
		$_SESSION["msj"]="Bienvenido $usuario";
		//$_SESSION["logueado"]=$usuario;
		$_SESSION["sess_perfil"]=$usuario;
		header("location:../index.php");
		}
 
 
	$conn->cerrar();
	header("location:../index.php");
 
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder