Foros del Web » Programando para Internet » PHP »

contraseña y confirmar contraseña

Estas en el tema de contraseña y confirmar contraseña en el foro de PHP en Foros del Web. hola estoy haciendo una pagina y estoy en la parte, donde la gente se registrara pero quiero hacer un campo con contraseña y otro que ...
  #1 (permalink)  
Antiguo 30/03/2008, 14:21
 
Fecha de Ingreso: noviembre-2007
Mensajes: 49
Antigüedad: 16 años, 5 meses
Puntos: 0
contraseña y confirmar contraseña

hola estoy haciendo una pagina y estoy en la parte, donde la gente se registrara pero quiero hacer un campo con contraseña y otro que confirme la contraseña entonces si no coinsiden me diga que no coinsiden o que no son iguales y si estan iguales pues que se suban los datos a la base de datos.

mi codigo es el siguiente:

Código PHP:
<?php require_once('Connections/prosperidad.php'); ?>
<?php
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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"] == "formu")) {
  
$insertSQL sprintf("INSERT INTO usuarios (usuario, nombre, apellido, Pais, ciudad, Email, Sexo, pass) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['usuadio'], "text"),
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['apellido'], "text"),
                       
GetSQLValueString($_POST['pais'], "text"),
                       
GetSQLValueString($_POST['ciudad'], "text"),
                       
GetSQLValueString($_POST['email'], "text"),
                       
GetSQLValueString($_POST['sexo'], "text"),
                       
GetSQLValueString($_POST['contrasena1'], "text"));

  
mysql_select_db($database_prosperidad$prosperidad);
  
$Result1 mysql_query($insertSQL$prosperidad) or die(mysql_error());
}

mysql_select_db($database_prosperidad$prosperidad);
$query_Usuarios "SELECT * FROM usuarios";
$Usuarios mysql_query($query_Usuarios$prosperidad) or die(mysql_error());
$row_Usuarios mysql_fetch_assoc($Usuarios);
$totalRows_Usuarios mysql_num_rows($Usuarios);
?><!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=iso-8859-1" />
<title>Registrarse</title>
<style type="text/css">
<!--
#Layer1 {
    position:absolute;
    width:200px;
    height:115px;
    z-index:1;
    left: 262px;
    top: 14px;
}
#Layer2 {
    position:absolute;
    width:200px;
    height:115px;
    z-index:2;
    left: 261px;
    top: 393px;
}
#Layer3 {
    position:absolute;
    width:200px;
    height:115px;
    z-index:3;
    left: 261px;
    top: 225px;
}
#Layer4 {
    position:absolute;
    width:200px;
    height:115px;
    z-index:4;
}
#Layer5 {
    position:absolute;
    width:200px;
    height:115px;
    z-index:4;
    left: 6px;
    top: 3px;
}
#Layer6 {
    position:absolute;
    width:700px;
    height:166px;
    z-index:5;
    left: 261px;
    top: 398px;
}
#Layer7 {
    position:absolute;
    width:132px;
    height:82px;
    z-index:6;
    left: 20px;
    top: 287px;
}
body {
    background-image: url(imagenes/mainbox_bg.jpg);
}
#Layer8 {
    position:absolute;
    width:205px;
    height:208px;
    z-index:7;
    left: 260px;
    top: 4px;
}
#Layer9 {
    position:absolute;
    width:479px;
    height:400px;
    z-index:1;
    left: 7px;
    top: 7px;
}
#Layer10 {
    position:absolute;
    width:200px;
    height:115px;
    z-index:2;
}
#Layer11 {
    position:absolute;
    width:525px;
    height:115px;
    z-index:1;
    left: 9px;
    top: 5px;
}
.Estilo5 {color: #FFFFFF}
-->
</style></head>

<body>
<div id="Layer11">
  <form action = "<?php echo $editFormAction?>" method="POST" name="formu" id="formu">
    <table width="398" border="0" cellpadding="3" cellspacing="3">
      <tr>
        <td width="180"><div align="left" class="Estilo5">Usuario:</div></td>
        <td width="197"><label>
          <div align="left">
            <input name="usuadio" type="text" id="usuadio" size="30" />
          </div>
          </label></td>
      </tr>
      <tr>
        <td><div align="left" class="Estilo5">Contrase&ntilde;a</div></td>
        <td>
          <div align="left">
            <input name="contrasena1" type="password" size="30" />
          </div></td>
      </tr>
      <tr>
        <td><div align="left" class="Estilo5">Reconfirme contrase&ntilde;a </div></td>
        <td>
          <div align="left">
            <input name="contrasena2" type="password" size="30" />
          </div></td>
      </tr>
      <tr>
        <td><div align="left" class="Estilo5">Nombre:</div></td>
        <td>
          <div align="left">
            <input name="nombre" type="text" id="nombre" size="30" />
          </div></td>
      </tr>
      <tr>
        <td><div align="left" class="Estilo5">Apellido:</div></td>
        <td>
          <div align="left">
            <input name="apellido" type="text" id="apellido" size="30" />
          </div></td>
      </tr>
      <tr>
        <td height="49"><div align="left" class="Estilo5">Sexo</div></td>
        <td><label>
          <label></label>
</label>
          <p>
            <label>
              <input type="radio" name="sexo" value="masculino" />
              <span class="Estilo5">masculino</span></label>
            <span class="Estilo5"><br />
            <label>
              <input type="radio" name="sexo" value="femenino" />
              femenino</label>
            </span><br />
          </p></td>
      </tr>
      <tr>
        <td><div align="left" class="Estilo5">pais</div></td>
        <td>
          <div align="left">
            <input name="pais" type="text" id="pais" size="30" />
          </div></td>
      </tr>
      <tr>
        <td><div align="left" class="Estilo5">ciudad</div></td>
        <td>
          <div align="left">
            <input name="ciudad" type="text" id="ciudad" size="30" />
          </div></td>
      </tr>
      <tr>
        <td><div align="left" class="Estilo5">E-mail</div></td>
        <td>
          <div align="left">
            <input name="email" type="text" id="email" size="30" />
          </div></td>
      </tr>
      <tr>
        <td><div align="left" class="Estilo5">
          <input type="submit" name="submit" value="Ingresar datos" />
        </div></td>
        <td><div align="left"></div></td>
      </tr>
    </table>
    <p>&nbsp; </p>
      <input type="hidden" name="MM_insert" value="formu">
  </form> 
</div>
</body>
</html>
<?php
mysql_free_result
($Usuarios);
?>
ayudenme porfavor !!!!!!!
  #2 (permalink)  
Antiguo 30/03/2008, 14:29
 
Fecha de Ingreso: enero-2008
Mensajes: 381
Antigüedad: 16 años, 3 meses
Puntos: 19
Re: contraseña y confirmar contraseña

simplemente

if ($contrasena1 != $contrasena2) {
echo "las contraseñas no concuerdan";
exit();
}

pero claro, eso lo tienes que formatear mejor

Te recomiendo que tambien lo compruebes en javascript, pero eso no quieta que lo compruebes en php, ya que la proteccion javascript se puede saltar facilmente al ser de lado del cliente

http://www.desarrolloweb.com/articulos/1767.php

Saludos
  #3 (permalink)  
Antiguo 30/03/2008, 14:32
 
Fecha de Ingreso: noviembre-2007
Mensajes: 49
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: contraseña y confirmar contraseña

pero con ese codigo cuando las contraseñas no son iguales no registra nada en la base de datos o aunque sean diferentes igual guarda la informacion en la base de datos???? como quedaria el codigo?
  #4 (permalink)  
Antiguo 30/03/2008, 14:33
 
Fecha de Ingreso: enero-2008
Mensajes: 381
Antigüedad: 16 años, 3 meses
Puntos: 19
Re: contraseña y confirmar contraseña

no lo registra eso tiene que ir antes del insert, y con exit se para la ejecucion de php, pero eso es solo un ejemplo, el codigo es mejorable
  #5 (permalink)  
Antiguo 30/03/2008, 14:45
 
Fecha de Ingreso: noviembre-2007
Mensajes: 49
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: contraseña y confirmar contraseña

ok muchas Gracias are las pruebas correspondiente si me va bien les aviso !
  #6 (permalink)  
Antiguo 30/03/2008, 20:29
Avatar de korg1988  
Fecha de Ingreso: junio-2006
Ubicación: Santa Fe, Argentina
Mensajes: 825
Antigüedad: 17 años, 10 meses
Puntos: 19
De acuerdo Re: contraseña y confirmar contraseña

asi quedaria tu codigo
Código PHP:
 <?php require_once('Connections/prosperidad.php'); ?> 
<?php 
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue "")  

  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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"] == "formu")) { 
  if(
$_POST['contrasena1'] == $_POST['contrasena2']){
  
$insertSQL sprintf("INSERT INTO usuarios (usuario, nombre, apellido, Pais, ciudad, Email, Sexo, pass) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)"
                       
GetSQLValueString($_POST['usuadio'], "text"), 
                       
GetSQLValueString($_POST['nombre'], "text"), 
                       
GetSQLValueString($_POST['apellido'], "text"), 
                       
GetSQLValueString($_POST['pais'], "text"), 
                       
GetSQLValueString($_POST['ciudad'], "text"), 
                       
GetSQLValueString($_POST['email'], "text"), 
                       
GetSQLValueString($_POST['sexo'], "text"), 
                       
GetSQLValueString($_POST['contrasena1'], "text")); 

  
mysql_select_db($database_prosperidad$prosperidad); 
  
$Result1 mysql_query($insertSQL$prosperidad) or die(mysql_error()); 
  } else {
     echo 
"Las contraseñas no coinciden";
     exit();
  }


mysql_select_db($database_prosperidad$prosperidad); 
$query_Usuarios "SELECT * FROM usuarios"
$Usuarios mysql_query($query_Usuarios$prosperidad) or die(mysql_error()); 
$row_Usuarios mysql_fetch_assoc($Usuarios); 
$totalRows_Usuarios mysql_num_rows($Usuarios); 
?><!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=iso-8859-1" /> 
<title>Registrarse</title> 
<style type="text/css"> 
<!-- 
#Layer1 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:1; 
    left: 262px; 
    top: 14px; 

#Layer2 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:2; 
    left: 261px; 
    top: 393px; 

#Layer3 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:3; 
    left: 261px; 
    top: 225px; 

#Layer4 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:4; 

#Layer5 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:4; 
    left: 6px; 
    top: 3px; 

#Layer6 { 
    position:absolute; 
    width:700px; 
    height:166px; 
    z-index:5; 
    left: 261px; 
    top: 398px; 

#Layer7 { 
    position:absolute; 
    width:132px; 
    height:82px; 
    z-index:6; 
    left: 20px; 
    top: 287px; 

body { 
    background-image: url(imagenes/mainbox_bg.jpg); 

#Layer8 { 
    position:absolute; 
    width:205px; 
    height:208px; 
    z-index:7; 
    left: 260px; 
    top: 4px; 

#Layer9 { 
    position:absolute; 
    width:479px; 
    height:400px; 
    z-index:1; 
    left: 7px; 
    top: 7px; 

#Layer10 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:2; 

#Layer11 { 
    position:absolute; 
    width:525px; 
    height:115px; 
    z-index:1; 
    left: 9px; 
    top: 5px; 

.Estilo5 {color: #FFFFFF} 
--> 
</style></head> 

<body> 
<div id="Layer11"> 
  <form action = "<?php echo $editFormAction?>" method="POST" name="formu" id="formu"> 
    <table width="398" border="0" cellpadding="3" cellspacing="3"> 
      <tr> 
        <td width="180"><div align="left" class="Estilo5">Usuario:</div></td> 
        <td width="197"><label> 
          <div align="left"> 
            <input name="usuadio" type="text" id="usuadio" size="30" /> 
          </div> 
          </label></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">Contrase&ntilde;a</div></td> 
        <td> 
          <div align="left"> 
            <input name="contrasena1" type="password" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">Reconfirme contrase&ntilde;a </div></td> 
        <td> 
          <div align="left"> 
            <input name="contrasena2" type="password" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">Nombre:</div></td> 
        <td> 
          <div align="left"> 
            <input name="nombre" type="text" id="nombre" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">Apellido:</div></td> 
        <td> 
          <div align="left"> 
            <input name="apellido" type="text" id="apellido" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td height="49"><div align="left" class="Estilo5">Sexo</div></td> 
        <td><label> 
          <label></label> 
</label> 
          <p> 
            <label> 
              <input type="radio" name="sexo" value="masculino" /> 
              <span class="Estilo5">masculino</span></label> 
            <span class="Estilo5"><br /> 
            <label> 
              <input type="radio" name="sexo" value="femenino" /> 
              femenino</label> 
            </span><br /> 
          </p></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">pais</div></td> 
        <td> 
          <div align="left"> 
            <input name="pais" type="text" id="pais" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">ciudad</div></td> 
        <td> 
          <div align="left"> 
            <input name="ciudad" type="text" id="ciudad" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">E-mail</div></td> 
        <td> 
          <div align="left"> 
            <input name="email" type="text" id="email" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5"> 
          <input type="submit" name="submit" value="Ingresar datos" /> 
        </div></td> 
        <td><div align="left"></div></td> 
      </tr> 
    </table> 
    <p>&nbsp; </p> 
      <input type="hidden" name="MM_insert" value="formu"> 
  </form>  
</div> 
</body> 
</html> 
<?php 
mysql_free_result
($Usuarios); 
?>
a y por sierto
HARE, va con H
suerte jaja
  #7 (permalink)  
Antiguo 06/04/2008, 09:14
 
Fecha de Ingreso: noviembre-2007
Mensajes: 49
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: contraseña y confirmar contraseña

Muchas Gracias a Todos, ya esta solucionado !!!!

aaaaa... y gracias por haber correjido la escritura jejejejej :P
  #8 (permalink)  
Antiguo 06/04/2008, 09:33
 
Fecha de Ingreso: noviembre-2007
Mensajes: 49
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: contraseña y confirmar contraseña

que tengo que agregarle para que despues de que se registren vayan a una pagina x que yo eliga...

ayudenme porfavor !!!
  #9 (permalink)  
Antiguo 06/04/2008, 09:50
(Desactivado)
 
Fecha de Ingreso: diciembre-2006
Mensajes: 529
Antigüedad: 17 años, 5 meses
Puntos: 11
Re: contraseña y confirmar contraseña

Cita:

a y por sierto
HARE, va con H
suerte jaja
La paja de nuestro ojo... "sierto" va con "c" amigo.
  #10 (permalink)  
Antiguo 06/04/2008, 09:53
(Desactivado)
 
Fecha de Ingreso: diciembre-2006
Mensajes: 529
Antigüedad: 17 años, 5 meses
Puntos: 11
Re: contraseña y confirmar contraseña

Cita:
Iniciado por Albertair1 Ver Mensaje
que tengo que agregarle para que despues de que se registren vayan a una pagina x que yo eliga...

ayudenme porfavor !!!
Al terminar todo tu script usa esto para redireccionar:

Código PHP:
header ("Location:  redireccion.php");
exit(); 
Reemplaza "redireccionar.php" por tu página.

Salud!
  #11 (permalink)  
Antiguo 06/04/2008, 10:12
 
Fecha de Ingreso: noviembre-2007
Mensajes: 49
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: contraseña y confirmar contraseña

USERMAX Gracias por contestar.. mira sabes lo puse pero no surtio efecto lo puse de esta manera
Código PHP:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formu")) { 
  if(
$_POST['contrasena1'] == $_POST['contrasena2']){
  
$insertSQL sprintf("INSERT INTO usuarios (usuario, nombre, apellido, Pais, ciudad, Email, Sexo, pass) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)"
                       
GetSQLValueString($_POST['usuadio'], "text"), 
                       
GetSQLValueString($_POST['nombre'], "text"), 
                       
GetSQLValueString($_POST['apellido'], "text"), 
                       
GetSQLValueString($_POST['pais'], "text"), 
                       
GetSQLValueString($_POST['ciudad'], "text"), 
                       
GetSQLValueString($_POST['email'], "text"), 
                       
GetSQLValueString($_POST['sexo'], "text"), 
                       
GetSQLValueString($_POST['contrasena1'], "text")); 

  
mysql_select_db($database_prosperidad$prosperidad); 
  
$Result1 mysql_query($insertSQL$prosperidad) or die(mysql_error()); 
  } else {
     echo 
"Las contraseñas no coinciden";
     
header ("Location:  felicitaciones.php");
     exit(); 
  }

esta bien?
  #12 (permalink)  
Antiguo 06/04/2008, 10:25
Avatar de yoseman  
Fecha de Ingreso: diciembre-2003
Ubicación: Alicante (Spain)
Mensajes: 471
Antigüedad: 20 años, 5 meses
Puntos: 5
Re: contraseña y confirmar contraseña

Lo has puesto en la parte de error de registro:
Código PHP:
<?
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formu")) 

    if(
$_POST['contrasena1'] == $_POST['contrasena2'])
    {
        
$insertSQL sprintf("INSERT INTO usuarios (usuario, nombre, apellido, Pais, ciudad, Email, Sexo, pass) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)"
        
GetSQLValueString($_POST['usuadio'], "text"), 
        
GetSQLValueString($_POST['nombre'], "text"), 
        
GetSQLValueString($_POST['apellido'], "text"), 
        
GetSQLValueString($_POST['pais'], "text"), 
        
GetSQLValueString($_POST['ciudad'], "text"), 
        
GetSQLValueString($_POST['email'], "text"), 
        
GetSQLValueString($_POST['sexo'], "text"), 
        
GetSQLValueString($_POST['contrasena1'], "text")); 
        
mysql_select_db($database_prosperidad$prosperidad); 
        if(
mysql_query($insertSQL$prosperidad))
            
header ("Location:  felicitaciones.php");
        else 
            die(
mysql_error()); 
    } 
    else 
    {
        echo 
"Las contraseñas no coinciden";
        exit(); 
    }
}
Prueba ahí...

Un saludo
__________________
[+]
[+]
  #13 (permalink)  
Antiguo 06/04/2008, 10:28
 
Fecha de Ingreso: noviembre-2007
Mensajes: 49
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: contraseña y confirmar contraseña

lo acabo de intentar y me dio este error


Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\prosperidad2\registrarse.php:2) in C:\AppServ\www\prosperidad2\registrarse.php on line 47



Código PHP:
<?php require_once('Connections/prosperidad.php'); ?> 
<?php 
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue "")  

  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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"] == "formu")) { 
  if(
$_POST['contrasena1'] == $_POST['contrasena2']){
  
$insertSQL sprintf("INSERT INTO usuarios (usuario, nombre, apellido, Pais, ciudad, Email, Sexo, pass) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)"
                       
GetSQLValueString($_POST['usuadio'], "text"), 
                       
GetSQLValueString($_POST['nombre'], "text"), 
                       
GetSQLValueString($_POST['apellido'], "text"), 
                       
GetSQLValueString($_POST['pais'], "text"), 
                       
GetSQLValueString($_POST['ciudad'], "text"), 
                       
GetSQLValueString($_POST['email'], "text"), 
                       
GetSQLValueString($_POST['sexo'], "text"), 
                       
GetSQLValueString($_POST['contrasena1'], "text")); 

  
mysql_select_db($database_prosperidad$prosperidad); 
  if(
mysql_query($insertSQL$prosperidad))
     
header ("Location:  felicitaciones.php");
  else 
     die(
mysql_error()); 
  } else {
     echo 
"Las contraseñas no coinciden";

     exit(); 
  }
}  


mysql_select_db($database_prosperidad$prosperidad); 
$query_Usuarios "SELECT * FROM usuarios"
$Usuarios mysql_query($query_Usuarios$prosperidad) or die(mysql_error()); 
$row_Usuarios mysql_fetch_assoc($Usuarios); 
$totalRows_Usuarios mysql_num_rows($Usuarios); 
?><!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=iso-8859-1" /> 
<title>Registrarse</title> 
<style type="text/css"> 
<!-- 
#Layer1 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:1; 
    left: 262px; 
    top: 14px; 

#Layer2 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:2; 
    left: 261px; 
    top: 393px; 

#Layer3 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:3; 
    left: 261px; 
    top: 225px; 

#Layer4 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:4; 

#Layer5 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:4; 
    left: 6px; 
    top: 3px; 

#Layer6 { 
    position:absolute; 
    width:700px; 
    height:166px; 
    z-index:5; 
    left: 261px; 
    top: 398px; 

#Layer7 { 
    position:absolute; 
    width:132px; 
    height:82px; 
    z-index:6; 
    left: 20px; 
    top: 287px; 

body { 
    background-image: url(imagenes/mainbox_bg.jpg); 

#Layer8 { 
    position:absolute; 
    width:205px; 
    height:208px; 
    z-index:7; 
    left: 260px; 
    top: 4px; 

#Layer9 { 
    position:absolute; 
    width:479px; 
    height:400px; 
    z-index:1; 
    left: 7px; 
    top: 7px; 

#Layer10 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:2; 

#Layer11 { 
    position:absolute; 
    width:525px; 
    height:115px; 
    z-index:1; 
    left: 9px; 
    top: 5px; 

.Estilo5 {color: #FFFFFF} 
--> 
</style></head> 

<body> 
<div id="Layer11"> 
  <form action = "<?php echo $editFormAction?>" method="POST" name="formu" id="formu"> 
    <table width="398" border="0" cellpadding="3" cellspacing="3"> 
      <tr> 
        <td width="180"><div align="left" class="Estilo5">Usuario:</div></td> 
        <td width="197"><label> 
          <div align="left"> 
            <input name="usuadio" type="text" id="usuadio" size="30" /> 
          </div> 
          </label></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">Contrase&ntilde;a</div></td> 
        <td> 
          <div align="left"> 
            <input name="contrasena1" type="password" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">Reconfirme contrase&ntilde;a </div></td> 
        <td> 
          <div align="left"> 
            <input name="contrasena2" type="password" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">Nombre:</div></td> 
        <td> 
          <div align="left"> 
            <input name="nombre" type="text" id="nombre" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">Apellido:</div></td> 
        <td> 
          <div align="left"> 
            <input name="apellido" type="text" id="apellido" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td height="49"><div align="left" class="Estilo5">Sexo</div></td> 
        <td><label> 
          <label></label> 
</label> 
          <p> 
            <label> 
              <input type="radio" name="sexo" value="masculino" /> 
              <span class="Estilo5">masculino</span></label> 
            <span class="Estilo5"><br /> 
            <label> 
              <input type="radio" name="sexo" value="femenino" /> 
              femenino</label> 
            </span><br /> 
          </p></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">pais</div></td> 
        <td> 
          <div align="left"> 
            <input name="pais" type="text" id="pais" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">ciudad</div></td> 
        <td> 
          <div align="left"> 
            <input name="ciudad" type="text" id="ciudad" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">E-mail</div></td> 
        <td> 
          <div align="left"> 
            <input name="email" type="text" id="email" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5"> 
          <input type="submit" name="submit" value="Ingresar datos" /> 
        </div></td> 
        <td><div align="left"></div></td> 
      </tr> 
    </table> 
    <p>&nbsp; </p> 
      <input type="hidden" name="MM_insert" value="formu"> 
  </form>  
</div> 
</body> 
</html> 
<?php 
mysql_free_result
($Usuarios); 
?>
ahi esta como lo deje y me da el error que puedo hacer?
  #14 (permalink)  
Antiguo 06/04/2008, 10:33
Avatar de yoseman  
Fecha de Ingreso: diciembre-2003
Ubicación: Alicante (Spain)
Mensajes: 471
Antigüedad: 20 años, 5 meses
Puntos: 5
Re: contraseña y confirmar contraseña

Tienes que poner al principio de todo de tu script:

Código PHP:
ob_start(); 
y al final:
Código PHP:
ob_end_flush(); 
Si quieres evitar ese warning...

O cambiarlo todo para que no se mande salida alguna al navegador antes del header...

O sea que menos lios lo primero...

Salu2 ;)
__________________
[+]
[+]

Última edición por yoseman; 06/04/2008 a las 10:46
  #15 (permalink)  
Antiguo 06/04/2008, 10:41
 
Fecha de Ingreso: noviembre-2007
Mensajes: 49
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: contraseña y confirmar contraseña

no entendi muy bien donde tengo que ponerlo me puedes mostrar un poquito porfavor??

Disculpa las molestias..
  #16 (permalink)  
Antiguo 06/04/2008, 10:46
Avatar de yoseman  
Fecha de Ingreso: diciembre-2003
Ubicación: Alicante (Spain)
Mensajes: 471
Antigüedad: 20 años, 5 meses
Puntos: 5
Re: contraseña y confirmar contraseña

asi:
Código PHP:
<?
ob_start
();
php require_once('Connections/prosperidad.php');

function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue "")  

  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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"] == "formu")) { 
  if(
$_POST['contrasena1'] == $_POST['contrasena2']){
  
$insertSQL sprintf("INSERT INTO usuarios (usuario, nombre, apellido, Pais, ciudad, Email, Sexo, pass) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)"
                       
GetSQLValueString($_POST['usuadio'], "text"), 
                       
GetSQLValueString($_POST['nombre'], "text"), 
                       
GetSQLValueString($_POST['apellido'], "text"), 
                       
GetSQLValueString($_POST['pais'], "text"), 
                       
GetSQLValueString($_POST['ciudad'], "text"), 
                       
GetSQLValueString($_POST['email'], "text"), 
                       
GetSQLValueString($_POST['sexo'], "text"), 
                       
GetSQLValueString($_POST['contrasena1'], "text")); 

  
mysql_select_db($database_prosperidad$prosperidad); 
  if(
mysql_query($insertSQL$prosperidad))
     
header ("Location:  felicitaciones.php");
  else 
     die(
mysql_error()); 
  } else {
     echo 
"Las contraseñas no coinciden";

     exit(); 
  }
}  


mysql_select_db($database_prosperidad$prosperidad); 
$query_Usuarios "SELECT * FROM usuarios"
$Usuarios mysql_query($query_Usuarios$prosperidad) or die(mysql_error()); 
$row_Usuarios mysql_fetch_assoc($Usuarios); 
$totalRows_Usuarios mysql_num_rows($Usuarios); 
?><!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=iso-8859-1" /> 
<title>Registrarse</title> 
<style type="text/css"> 
<!-- 
#Layer1 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:1; 
    left: 262px; 
    top: 14px; 

#Layer2 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:2; 
    left: 261px; 
    top: 393px; 

#Layer3 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:3; 
    left: 261px; 
    top: 225px; 

#Layer4 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:4; 

#Layer5 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:4; 
    left: 6px; 
    top: 3px; 

#Layer6 { 
    position:absolute; 
    width:700px; 
    height:166px; 
    z-index:5; 
    left: 261px; 
    top: 398px; 

#Layer7 { 
    position:absolute; 
    width:132px; 
    height:82px; 
    z-index:6; 
    left: 20px; 
    top: 287px; 

body { 
    background-image: url(imagenes/mainbox_bg.jpg); 

#Layer8 { 
    position:absolute; 
    width:205px; 
    height:208px; 
    z-index:7; 
    left: 260px; 
    top: 4px; 

#Layer9 { 
    position:absolute; 
    width:479px; 
    height:400px; 
    z-index:1; 
    left: 7px; 
    top: 7px; 

#Layer10 { 
    position:absolute; 
    width:200px; 
    height:115px; 
    z-index:2; 

#Layer11 { 
    position:absolute; 
    width:525px; 
    height:115px; 
    z-index:1; 
    left: 9px; 
    top: 5px; 

.Estilo5 {color: #FFFFFF} 
--> 
</style></head> 

<body> 
<div id="Layer11"> 
  <form action = "<?php echo $editFormAction?>" method="POST" name="formu" id="formu"> 
    <table width="398" border="0" cellpadding="3" cellspacing="3"> 
      <tr> 
        <td width="180"><div align="left" class="Estilo5">Usuario:</div></td> 
        <td width="197"><label> 
          <div align="left"> 
            <input name="usuadio" type="text" id="usuadio" size="30" /> 
          </div> 
          </label></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">Contrase&ntilde;a</div></td> 
        <td> 
          <div align="left"> 
            <input name="contrasena1" type="password" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">Reconfirme contrase&ntilde;a </div></td> 
        <td> 
          <div align="left"> 
            <input name="contrasena2" type="password" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">Nombre:</div></td> 
        <td> 
          <div align="left"> 
            <input name="nombre" type="text" id="nombre" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">Apellido:</div></td> 
        <td> 
          <div align="left"> 
            <input name="apellido" type="text" id="apellido" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td height="49"><div align="left" class="Estilo5">Sexo</div></td> 
        <td><label> 
          <label></label> 
</label> 
          <p> 
            <label> 
              <input type="radio" name="sexo" value="masculino" /> 
              <span class="Estilo5">masculino</span></label> 
            <span class="Estilo5"><br /> 
            <label> 
              <input type="radio" name="sexo" value="femenino" /> 
              femenino</label> 
            </span><br /> 
          </p></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">pais</div></td> 
        <td> 
          <div align="left"> 
            <input name="pais" type="text" id="pais" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">ciudad</div></td> 
        <td> 
          <div align="left"> 
            <input name="ciudad" type="text" id="ciudad" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5">E-mail</div></td> 
        <td> 
          <div align="left"> 
            <input name="email" type="text" id="email" size="30" /> 
          </div></td> 
      </tr> 
      <tr> 
        <td><div align="left" class="Estilo5"> 
          <input type="submit" name="submit" value="Ingresar datos" /> 
        </div></td> 
        <td><div align="left"></div></td> 
      </tr> 
    </table> 
    <p>&nbsp; </p> 
      <input type="hidden" name="MM_insert" value="formu"> 
  </form>  
</div> 
</body> 
</html> 
<?php 
mysql_free_result
($Usuarios);
ob_end_flush();
?>
Un saludo.
__________________
[+]
[+]
  #17 (permalink)  
Antiguo 06/04/2008, 11:12
 
Fecha de Ingreso: noviembre-2007
Mensajes: 49
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: contraseña y confirmar contraseña

me da este error con tu codigo


Parse error: parse error, unexpected T_REQUIRE_ONCE in C:\AppServ\www\prosperidad2\registrarse.php on line 3
  #18 (permalink)  
Antiguo 06/04/2008, 11:35
Avatar de yoseman  
Fecha de Ingreso: diciembre-2003
Ubicación: Alicante (Spain)
Mensajes: 471
Antigüedad: 20 años, 5 meses
Puntos: 5
Re: contraseña y confirmar contraseña

Cita:
Iniciado por Albertair1 Ver Mensaje
me da este error con tu codigo


Parse error: parse error, unexpected T_REQUIRE_ONCE in C:\AppServ\www\prosperidad2\registrarse.php on line 3
Ey perdona se me ha colado un 'php' al hacer copy&pasteen las primeras líneas:

Código PHP:
<?
ob_start
();
require_once(
'Connections/prosperidad.php');
sólo quita 'php de esa línea que no pinta nada, era del tag de apertura de código...

Salu2 ;)
__________________
[+]
[+]
  #19 (permalink)  
Antiguo 11/04/2008, 19:05
 
Fecha de Ingreso: noviembre-2007
Mensajes: 49
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: contraseña y confirmar contraseña

Muchas Gracias Yoseman ya lo e logrado


Saludos !!!!
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 11:26.