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

Ayuda con validacion textfield

Estas en el tema de Ayuda con validacion textfield en el foro de Diseño web en Foros del Web. Hola soy nuevo en esto de la programacion web, estoy haciendo una pagina en php, ya tengo algunas nociones son muy basicas pero mi duda ...
  #1 (permalink)  
Antiguo 17/12/2008, 16:34
 
Fecha de Ingreso: diciembre-2008
Mensajes: 7
Antigüedad: 15 años, 3 meses
Puntos: 0
Pregunta Ayuda con validacion textfield

Hola soy nuevo en esto de la programacion web, estoy haciendo una pagina en php, ya tengo algunas nociones son muy basicas pero mi duda es las siguiente
quiero validar a un usuario nuevo dentro de una base de datos

tiene que validarse los campos
contraseña y
verificar contraseña
Como puedo hacer para que compare las 2 contraseñas y me diga que son iguales
POR FAVOR NECESITO SU AYUDA
  #2 (permalink)  
Antiguo 17/12/2008, 16:58
Avatar de K-Yezaad  
Fecha de Ingreso: octubre-2005
Mensajes: 140
Antigüedad: 18 años, 5 meses
Puntos: 3
Respuesta: Ayuda con validacion textfield

Basta con que cheques con un if:
Código:
if($_POST['password1'] == $_POST['password2']){
//codigo que se ejecuta al pasar la validación.
}
  #3 (permalink)  
Antiguo 18/12/2008, 14:05
 
Fecha de Ingreso: diciembre-2008
Mensajes: 7
Antigüedad: 15 años, 3 meses
Puntos: 0
Respuesta: Ayuda con validacion textfield

ammm ps medio entendi el codigo q tengo esta asi, lo estoy haciendo en dreamweaver y no se donde meterlo
si la validacion es correcta pues enviara el formulario para que sea ingresado a la base de d datos pero si no es asi
pues no se q mande un mensaje q las contraseñas no coinciden
agradeceria mucho si me pudieras explicar como se hace gracias
ESTE ES EL CODIGO Q SE GENERA:


<?php require_once('Connections/Tienda.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}

// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="registroduplicado.php";
$loginUsername = $_POST['usuario'];
$LoginRS__query = sprintf("SELECT usuario FROM clientes WHERE usuario=%s", GetSQLValueString($loginUsername, "text"));
mysql_select_db($database_Tienda, $Tienda);
$LoginRS=mysql_query($LoginRS__query, $Tienda) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);

//if there is a row in the database, the username was found - can not add the requested username
if($loginFoundUser){
$MM_qsChar = "?";
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
header ("Location: $MM_dupKeyRedirect");
exit;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO clientes (usuario, passwd, nombre_clte, direccion_clte, delegacion_clte, estado_clte, cp_clte, tel1_clte, tel2_clte, email_clte) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['usuario'], "text"),
GetSQLValueString($_POST['passwd'], "text"),
GetSQLValueString($_POST['nombre_clte'], "text"),
GetSQLValueString($_POST['direccion_clte'], "text"),
GetSQLValueString($_POST['delegacion_clte'], "text"),
GetSQLValueString($_POST['estado_clte'], "text"),
GetSQLValueString($_POST['cp_clte'], "int"),
GetSQLValueString($_POST['tel1_clte'], "int"),
GetSQLValueString($_POST['tel2_clte'], "int"),
GetSQLValueString($_POST['email_clte'], "text"));

mysql_select_db($database_Tienda, $Tienda);
$Result1 = mysql_query($insertSQL, $Tienda) or die(mysql_error());

$insertGoTo = "completarregistro.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

?>
<?php require_once('../../Connections/Tienda_prueba.php'); ?>
<!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>AllMobileFashion ---- Tienda Virtual ----</title>
<style type="text/css">
<!--
body {
background-image: url();
background-repeat: no-repeat;
}
.Estilo4 {font-size: 36px}
.Estilo5 {color: #FDE000}
.Estilo6 {color: #000000}
.Estilo7 {color: #FFFF00}
.Estilo8 {font-size: 24px}
.Estilo9 {color: #9ABF19}
-->
</style>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="895" height="804" border="0" align="center">
<tr>
<td width="229" rowspan="4"><div align="left"><img src="Imagenes/logo Allmovilefashion copia.jpg" width="228" height="171" /></div></td>
<td width="656" height="21">&nbsp;</td>
</tr>
<tr>
<td height="69" bgcolor="#9ABF19"><p><span class="Estilo4">Inicio <span class="Estilo9">... </span><span class="Estilo8">Mi pagina personal</span><span class="Estilo9">... </span>Tienda<span class="Estilo9">... </span> <span class="Estilo8">Contacto</span></span></p></td>
</tr>
<tr>
<td height="40" bgcolor="#FDE000">
<p>
<strong>Iniciar Sesion <span class="Estilo5">............<span class="Estilo6">Registrar</span></span></strong><strong>se<span class="Estilo5"> ............ </span><span class="Estilo7"><span class="Estilo6">Olvide mi contraseña<span class="Estilo5">........... <span class="Estilo6">Preguntas Frecuentes</span></span></span> </span></strong></p>
</p></td>
</tr>
<tr>
<td height="21">&nbsp;</td>
</tr>
<tr>
<td height="21">&nbsp;</td>
<td height="21">&nbsp;</td>
</tr>
<tr>
<td height="21" colspan="2"><div align="justify">Para hacer uso de AllMobileFashion debes ser usuario registrado. Introduce el nombre de ususario y la contraseña con el que entraras a nuestros </div></td>
</tr>
<tr>
<td height="21" colspan="2"><div align="justify">servicios. tambien la informacion complementaria para continuar con tu registro. La informacion proporcionada sera tratada con privadad</div></td>
</tr>
<tr>
<td height="21" colspan="2"> <div align="justify">(ver las politicas de privacidad).</div></td>
</tr>
<tr>
<td height="21">&nbsp;</td>
<td height="21"><table width="430" border="0">
<tr>
<td width="424" height="21" bgcolor="#FDE000"><strong>Registrarse</strong></td>
</tr>
<tr>
<td height="412"><form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
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 09:58.