PHP - Porfavor Ayuda es importante !! Contraseñas invalidas

 
Vista:

Porfavor Ayuda es importante !! Contraseñas invalidas

Publicado por eddinson (1 intervención) el 15/11/2014 12:21:29
tengo un codigo que necesito que me diga : SUS CONTRASEÑAS NO SON IGUALES en mi formalario , e intentado de todo pero nada quien podria ayudarme aqui esta el codigo ! tengo un codigo en java scrip pero no quiere hacer su funcion esta a mi mitad del ejercicio alli se ve claramente donde dice AQUI ESTA EL CODIGO AGREGADO

mi codigo
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<?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>
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
Imágen de perfil de Alejandro
Val: 1.634
Plata
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Porfavor Ayuda es importante !! Contraseñas invalidas

Publicado por Alejandro (839 intervenciones) el 15/11/2014 18:35:11
  • Alejandro se encuentra ahora conectado en el
  • chat de PHP
Lo que yo alcanso a percibir es que usas "document.getElementById("clave1")" pero tus inputs no tiene la etiqueta de ID usa "document.getElementsByName('clave1')" o agrega las etiqueta ID="clave#" a tus inputs
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar