Autor Tema: Repetir Contraseña Urgente  (Leído 357 veces)

Desconectado eddinson

  • PHPerit@
  • *
  • Mensajes: 1
  • Karma: 0
  • Nuev@ PHPer@
    • Ver Perfil
Repetir Contraseña Urgente
« en: 11 de Noviembre de 2014, 19:58:55 pm »
Buenas tardes disculpen la molestia he estado buscando mucho en la red de como repetir la contraseña en un formulario, encontre un tema aqui y todo pero al darle enviar no sucede nada el tema es este.

http://www.phperos.net/foro/index.php?topic=1113.0

cambie el valor de submit a button y no envia ni nada , pero al dejarlo el submit si envia mas no hace la funcion de verificar la contraseña , quien me podria ayudar de verdad le agradeceria mucho .

mi codigo
<?php require_once('../Connections/local.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;
}
}

$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 representantes (Nombre, Apellido, Edad, Sexo, Cedula, Telefono, Nacionalidad, Direccion, Correo, Contrasena, `Repetir Contraseña`, Usuario) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['Nombre'], "text"),
                       GetSQLValueString($_POST['Apellido'], "text"),
                       GetSQLValueString($_POST['Edad'], "int"),
                       GetSQLValueString($_POST['Sexo'], "text"),
                       GetSQLValueString($_POST['Cedula'], "text"),
                       GetSQLValueString($_POST['Telefono'], "int"),
                       GetSQLValueString($_POST['Nacionalidad'], "text"),
                       GetSQLValueString($_POST['Direccion'], "text"),
                       GetSQLValueString($_POST['Correo'], "text"),
                       GetSQLValueString($_POST['clave1'], "text"),
                       GetSQLValueString($_POST['clave2'], "text"),
                       GetSQLValueString($_POST['Usuario'], "text"));

  mysql_select_db($database_local, $local);
  $Result1 = mysql_query($insertSQL, $local) or die(mysql_error());

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

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO representantes (Nombre, Apellido, Edad, Sexo, Cedula, Telefono, Nacionalidad, Direccion, Correo, Contrasena, `Repetir Contraseña`, Usuario) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['Nombre'], "text"),
                       GetSQLValueString($_POST['Apellido'], "text"),
                       GetSQLValueString($_POST['Edad'], "int"),
                       GetSQLValueString($_POST['Sexo'], "text"),
                       GetSQLValueString($_POST['Cedula'], "text"),
                       GetSQLValueString($_POST['Telefono'], "int"),
                       GetSQLValueString($_POST['Nacionalidad'], "text"),
                       GetSQLValueString($_POST['Direccion'], "text"),
                       GetSQLValueString($_POST['Correo'], "text"),
                       GetSQLValueString($_POST['clave1'], "text"),
                       GetSQLValueString($_POST['clave2'], "text"),
                       GetSQLValueString($_POST['Usuario'], "text"));

  mysql_select_db($database_local, $local);
  $Result1 = mysql_query($insertSQL, $local) or die(mysql_error());

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

?>
<meta charset="utf-8">
<meta name="description" content="Custom Login Form Styling with CSS3" />
        <meta name="keywords" content="css3, login, form, custom, input, submit, button, html5, placeholder" />
        <meta name="author" content="Codrops" />
        <link rel="shortcut icon" href="../favicon.ico">
        <link rel="stylesheet" type="text/css" href="css/style.css" />
        <script src="js/modernizr.custom.63321.js"></script>
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script><!--[if lte IE 7]><style>.main{display:none;} .support-note .note-ie{display:block;}</style><![endif]-->
      <style>
         body {
   background: #e1c192 url(images/wood_pattern.jpg);
   background-image: url(images/formato.jpg);
         }
      .NEGRO {
   color: #000;
}
        .NEGRO center a h3 {
   color: #000;
}
        .centro {
   text-align: center;
}
        </style>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
<style type="text/css">
body,td,th {
   font-family: Lato, Calibri, Arial, sans-serif;
}
a:visited {
   color: #F00;
}
a:link {
   color: #F00;
}
</style>

<center>
<h1>&nbsp;</h1>
<h1>Registro de Representantes</h1>
<p>&nbsp;</p>
<p>&nbsp;</p>


//AQUI ESTA EL CODIGO QUE AGREGE


<script type="text/javascript">
function checkval() {
if (document.getElementById("clave1").value != document.getElementById("clave2").value) {
   alert("Las contraseñas que has introducido no son iguales");
   return false;
} else {
document.form2.submit();
}
}
</script>
<form action="<?php echo $editFormAction; ?>" method="POST" name="form1" id="form1">
  <p>&nbsp;</p>
  <table align="center">
    <tr valign="baseline">
      <td width="100" align="left" nowrap="nowrap"><h1><strong>Nombre :*</strong></h1></td>
      <td width="144"><span id="sprytextfield1">
        <input type="text" name="Nombre" value="" size="25" />
        <span class="textfieldRequiredMsg">Nombre?</span></span></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="left"><h1><strong>Apellido :*</strong></h1></td>
      <td><span id="sprytextfield2">
        <input type="text" name="Apellido" value="" size="25" />
        <span class="textfieldRequiredMsg">Apellido?</span></span></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="left"><h1><strong>Edad :*</strong></h1></td>
      <td><span id="sprytextfield6">
        <input type="text" name="Edad" value="" size="3" />
        <span class="textfieldRequiredMsg">Edad?</span></span></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="left"><h1><strong>Sexo:</strong></h1></td>
      <td><input type="text" name="Sexo" value="" size="25" placeholder="Masculino/Femenino"/></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="left"><h1><strong>Cedula :*</strong></h1></td>
      <td><span id="sprytextfield7">
        <input type="text" name="Cedula" value="" size="7" />
        <span class="textfieldRequiredMsg">Complete</span></span></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="left"><h1><strong>Telefono:</strong></h1></td>
      <td><input type="text" name="Telefono" value="" size="10" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="left"><h1><strong>Nacionalidad:</strong></h1></td>
      <td><input type="text" name="Nacionalidad" value="" size="25" placeholder="Venezolano / Extranjero"/></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="left"><h1><strong>Direccion :*</strong></h1></td>
      <td><span id="sprytextfield3">
        <input type="text" name="Direccion" value="" size="25" />
        <span class="textfieldRequiredMsg">Direccion?</span></span></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="left"><h1><strong>Correo:</strong></h1></td>
      <td><input type="text" name="Correo" value="@" size="25" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="left"><h1><strong>Usuario :*</strong></h1></td>
      <td><span id="sprytextfield4">
        <input type="text" name="Usuario" value="" size="25" />
        <span class="textfieldRequiredMsg">Usuario?</span></span></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="left"><h1><strong>Contraseña :*</strong></h1></td>
      <td><span id="sprytextfield5">
        <input type="password" name="clave1" value="" size="25" />
        <span class="textfieldRequiredMsg">Contraseña?</span></span></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="left"><h1>Repetir:*</h1></td>
      <td><span id="sprytextfield8"><span id="sprytextfield9">
        <input type="password" name="clave2" value="" size="25" />
        <span class="textfieldRequiredMsg">Verificar!!</span></span><span class="textfieldRequiredMsg">Contraseña?</span></span></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="left"><h1>&nbsp;</h1></td>
      <td><p>&nbsp;</p>
        <p>
          <input type="button" name="button" id="send" value="Enviar" onClick="checkval();"/>
        </p></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
</center>
<p class="mid">&nbsp;</p>
<center>
  <h2 class="NEGRO"><strong>Regresar a la pagina principal </strong></h2>
<h2><strong><a href="../indexvisitante.php">AQUI</a></strong><a href="../indexvisitante.php"></a></h2>
<h2>&nbsp;</h2></center>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4");
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5");
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6");
var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7");
var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9");
</script>
<script>
« Última modificación: 11 de Noviembre de 2014, 20:00:57 pm por eddinson »

Comunidad PHPeros

Repetir Contraseña Urgente
« en: 11 de Noviembre de 2014, 19:58:55 pm »

Desconectado Juance

  • PHPerit@
  • *
  • Mensajes: 1
  • Karma: 0
  • Nuev@ PHPer@
    • Ver Perfil
Re:Repetir Contraseña Urgente
« Respuesta #1 en: 10 de Diciembre de 2014, 02:13:05 am »
Muy buenas. Lo que debes hacer es crear dos input, y a cada uno de ellos asignarle un nombre. En los if de MM_insert es decír abajo de este crearas un if que diga que sí la variable clave1 es igual a la variable clave2 que prosiga con el insert y debajo de de la llave que cierra dicho if colocas un else e indicas que queres que haga sí las dos variables son distintas, regresar a la página indicando el error o cualquier otra cosa.

Sí no has entendido puedo ayudarte más profundo por otro medio. Saludos