Foros del Web » Programando para Internet » PHP »

Ayudaaaaa Registro y Como MOstrar los Datos

Estas en el tema de Ayudaaaaa Registro y Como MOstrar los Datos en el foro de PHP en Foros del Web. hola mi duda es q en mi pagina uno debe registrarse y pues quiero que al registrarme al dal click en guardar registro el me ...
  #1 (permalink)  
Antiguo 27/04/2010, 15:56
 
Fecha de Ingreso: abril-2010
Mensajes: 50
Antigüedad: 14 años
Puntos: 0
Exclamación Ayudaaaaa Registro y Como MOstrar los Datos

hola mi duda es q en mi pagina uno debe registrarse y pues quiero que al registrarme al dal click en guardar registro el me muestre los datos que almacene no como me muestra ahora que me salen todos los registros que ay en la base de datos

Codigo PHP para ingresar el registro a la base de datos
Código PHP:
<?php require_once('Connections/validacion.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"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO primera (nombre, sexo, cedula, direccion, barrio, tel_residencia, tel_celular, correo, dia, mes, año, estado_civil, mascota, tipo_mascota, carro, marca_carro, moto, marca_moto, ocupacion, lug_de_trabajo, tel_trabajo, nombre_pareja, dia_pareja, mes_pareja, año_pareja, num_perso_vive, num_hijos, nombre_hijo1, dia_hijo1, mes_hijo1, año_hijo1, nombre_hijo2, dia_hijo2, mes_hijo2, año_hijo2) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['sexo'], "text"),
                       
GetSQLValueString($_POST['cedula'], "int"),
                       
GetSQLValueString($_POST['direccion'], "text"),
                       
GetSQLValueString($_POST['barrio'], "text"),
                       
GetSQLValueString($_POST['tel_residencia'], "int"),
                       
GetSQLValueString($_POST['tel_celular'], "text"),
                       
GetSQLValueString($_POST['correo'], "text"),
                       
GetSQLValueString($_POST['dia'], "int"),
                       
GetSQLValueString($_POST['mes'], "int"),
                       
GetSQLValueString($_POST['ao'], "int"),
                       
GetSQLValueString($_POST['estado_civil'], "text"),
                       
GetSQLValueString($_POST['mascota'], "text"),
                       
GetSQLValueString($_POST['tipo_mascota'], "text"),
                       
GetSQLValueString($_POST['carro'], "text"),
                       
GetSQLValueString($_POST['marca_carro'], "text"),
                       
GetSQLValueString($_POST['moto'], "text"),
                       
GetSQLValueString($_POST['marca_moto'], "text"),
                       
GetSQLValueString($_POST['ocupacion'], "text"),
                       
GetSQLValueString($_POST['lug_de_trabajo'], "text"),
                       
GetSQLValueString($_POST['tel_trabajo'], "int"),
                       
GetSQLValueString($_POST['nombre_pareja'], "text"),
                       
GetSQLValueString($_POST['dia_pareja'], "int"),
                       
GetSQLValueString($_POST['mes_pareja'], "int"),
                       
GetSQLValueString($_POST['ao_pareja'], "int"),
                       
GetSQLValueString($_POST['num_perso_vive'], "int"),
                       
GetSQLValueString($_POST['num_hijos'], "int"),
                       
GetSQLValueString($_POST['nombre_hijo1'], "text"),
                       
GetSQLValueString($_POST['dia_hijo1'], "int"),
                       
GetSQLValueString($_POST['mes_hijo1'], "int"),
                       
GetSQLValueString($_POST['ao_hijo1'], "int"),
                       
GetSQLValueString($_POST['nombre_hijo2'], "text"),
                       
GetSQLValueString($_POST['dia_hijo2'], "int"),
                       
GetSQLValueString($_POST['mes_hijo2'], "int"),
                       
GetSQLValueString($_POST['ao_hijo2'], "int"));

  
mysql_select_db($database_validacion$validacion);
  
$Result1 mysql_query($insertSQL$validacion) or die(mysql_error());

  
$insertGoTo "otrapunt.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}
?>
y aca para mostrar los datos recien ingresado a la base de dato pero no es lo q quiero
Código PHP:
<?php

$link 
mysql_connect("localhost""root");

mysql_select_db("supermercado"$link);

$result mysql_query("SELECT nombre, sexo, cedula, direccion, barrio, tel_residencia, tel_celular, correo, dia, mes, año, estado_civil, mascota, tipo_mascota, carro, marca_carro, moto, marca_moto, ocupacion, lug_de_trabajo, tel_trabajo, nombre_pareja, dia_pareja, mes_pareja, año_pareja, num_perso_vive, num_hijos, nombre_hijo1, dia_hijo1, mes_hijo1, año_hijo1, nombre_hijo2, dia_hijo2, mes_hijo2, año_hijo2 FROM primera"$link);

if (
$row mysql_fetch_array($result)){

echo 
"<table border = '1'> \n";

echo 
"<tr> \n";

echo 
"<td><b>Nombre</b></td> \n";

echo 
"<td><b>Sexo</b></td> \n";
echo 
"<td><b>Cedula </b></td> \n";

echo 
"<td><b>Direccion</b></td> \n";
echo 
"<td><b>Barrio</b></td> \n";

echo 
"<td><b>Telefono Residencia</b></td> \n";
echo 
"<td><b>Telefono Celular</b></td> \n";

echo 
"<td><b>Correo</b></td> \n";
echo 
"<td><b>Dia Nacimiento</b></td> \n";

echo 
"<td><b>Mes Nacimiento</b></td> \n";
echo 
"<td><b>Año Nacimiento</b></td> \n";

echo 
"<td><b>Estado Civil</b></td> \n";
echo 
"<td><b>Mascota</b></td> \n";

echo 
"<td><b>Tipo Mascota</b></td> \n";

echo 
"<td><b>Carro</b></td> \n";

echo 
"<td><b>Tipo Carro</b></td> \n";
echo 
"<td><b>Moto</b></td> \n";

echo 
"<td><b>Tipo Moto</b></td> \n";
echo 
"<td><b>Ocupacion</b></td> \n";

echo 
"<td><b>Lugar De Trabajo</b></td> \n";
echo 
"<td><b>Telefono De Trabajo</b></td> \n";

echo 
"<td><b>Nombre Conyugè</b></td> \n";
echo 
"<td><b>Dia Nacimiento Conyugè</b></td> \n";

echo 
"<td><b>Mes Nacimiento Conyugè</b></td> \n";
echo 
"<td><b>Año Nacimiento Conyugè</b></td> \n";

echo 
"<td><b>Numero De Personas Con las Que Ud Vive</b></td> \n";
echo 
"<td><b>Numero De Hijos</b></td> \n";

echo 
"<td><b>nombre_hijo1</b></td> \n";
echo 
"<td><b>Dia Nacimiento Hijo1</b></td> \n";

echo 
"<td><b>Mes Nacimiento Hijo1</b></td> \n";
echo 
"<td><b>Año Nacimiento Hijo1</b></td> \n";

echo 
"<td><b>nombre_hijo2</b></td> \n";
echo 
"<td><b>Dia Nacimiento Hijo2</b></td> \n";

echo 
"<td><b>Mes Nacimiento Hijo2</b></td> \n";
echo 
"<td><b>Año Nacimiento Hijo2</b></td> \n";



echo 
"</tr> \n";

do {

echo 
"<tr> \n";

echo 
"<td>".$row["nombre"]."</td> \n";

echo 
"<td>".$row["sexo"]."</td>\n";
echo 
"<td>".$row["cedula"]."</td> \n";
echo 
"<td>".$row["direccion"]."</td>\n";

echo 
"<td>".$row["barrio"]."</td>\n";
echo 
"<td>".$row["tel_residencia"]."</td> \n";

echo 
"<td>".$row["tel_celular"]."</td>\n";
echo 
"<td>".$row["correo"]."</td> \n";

echo 
"<td>".$row["dia"]."</td>\n";
echo 
"<td>".$row["mes"]."</td> \n";

echo 
"<td>".$row["año"]."</td>\n";
echo 
"<td>".$row["estado_civil"]."</td> \n";

echo 
"<td>".$row["mascota"]."</td>\n";
echo 
"<td>".$row["tipo_mascota"]."</td> \n";

echo 
"<td>".$row["carro"]."</td>\n";
echo 
"<td>".$row["marca_carro"]."</td> \n";

echo 
"<td>".$row["moto"]."</td>\n";
echo 
"<td>".$row["marca_moto"]."</td> \n";

echo 
"<td>".$row["ocupacion"]."</td>\n";
echo 
"<td>".$row["lug_de_trabajo"]."</td> \n";

echo 
"<td>".$row["tel_trabajo"]."</td>\n";
echo 
"<td>".$row["nombre_pareja"]."</td> \n";

echo 
"<td>".$row["dia_pareja"]."</td>\n";
echo 
"<td>".$row["mes_pareja"]."</td> \n";

echo 
"<td>".$row["año_pareja"]."</td>\n";
echo 
"<td>".$row["num_perso_vive"]."</td> \n";

echo 
"<td>".$row["num_hijos"]."</td>\n";
echo 
"<td>".$row["nombre_hijo1"]."</td> \n";

echo 
"<td>".$row["dia_hijo1"]."</td>\n";
echo 
"<td>".$row["mes_hijo1"]."</td> \n";

echo 
"<td>".$row["año_hijo1"]."</td>\n";
echo 
"<td>".$row["nombre_hijo2"]."</td> \n";
echo 
"<td>".$row["dia_hijo2"]."</td>\n";
echo 
"<td>".$row["mes_hijo2"]."</td> \n";

echo 
"<td>".$row["año_hijo2"]."</td>\n";

echo 
"</tr> \n";

} while (
$row mysql_fetch_array($result));

echo 
"</table> \n";

} else {

echo 
"¡ La base de datos está vacia !";

}

?>
De ante mano MUCHAS GRACIAS por las respuestaas

Última edición por DiegoRivera2010; 27/04/2010 a las 16:01
  #2 (permalink)  
Antiguo 27/04/2010, 15:58
 
Fecha de Ingreso: diciembre-2009
Mensajes: 612
Antigüedad: 14 años, 4 meses
Puntos: 16
Respuesta: Ayudaaaaa Registro y Como MOstrar los Datos

Te AYudaria Pero Me Molesto El Leerte De Forma Absurda La PROxima Vez Habla BIen Sin Usar Mayúsculas En Cada Palabra.

Yo Necesito Una Moto
  #3 (permalink)  
Antiguo 27/04/2010, 16:02
 
Fecha de Ingreso: abril-2010
Mensajes: 50
Antigüedad: 14 años
Puntos: 0
Respuesta: Ayudaaaaa Registro y Como MOstrar los Datos

disculpa es una costumbre pero ahra lo e cambiado gracias
  #4 (permalink)  
Antiguo 27/04/2010, 16:02
Avatar de dargor  
Fecha de Ingreso: octubre-2009
Mensajes: 134
Antigüedad: 14 años, 6 meses
Puntos: 2
Respuesta: Ayudaaaaa Registro y Como MOstrar los Datos

tiene razon millan2525, la proxima no escribas asi, es un poco molesto.

veo esta sentencia
SELECT nombre, sexo, cedula, direccion, barrio, tel_residencia, tel_celular, correo, dia, mes, año, estado_civil, mascota, tipo_mascota, carro, marca_carro, moto, marca_moto, ocupacion, lug_de_trabajo, tel_trabajo, nombre_pareja, dia_pareja, mes_pareja, año_pareja, num_perso_vive, num_hijos, nombre_hijo1, dia_hijo1, mes_hijo1, año_hijo1, nombre_hijo2, dia_hijo2, mes_hijo2, año_hijo2 FROM primera

al final deberias incluir un where id='algo' , y ese algo es alguna identificacion unica del usuario que acaba de registrarse, asi solo se va mostrar los datos de ese registro, no de toda la base de datos, me explico?
  #5 (permalink)  
Antiguo 27/04/2010, 16:07
 
Fecha de Ingreso: abril-2010
Mensajes: 50
Antigüedad: 14 años
Puntos: 0
Respuesta: Ayudaaaaa Registro y Como MOstrar los Datos

si yo en la base de datos tengo un campo que se llama "id" pero como utilizarlo en el where un ejemplo seria bn si puedes gracias
  #6 (permalink)  
Antiguo 27/04/2010, 19:09
Avatar de dargor  
Fecha de Ingreso: octubre-2009
Mensajes: 134
Antigüedad: 14 años, 6 meses
Puntos: 2
Respuesta: Ayudaaaaa Registro y Como MOstrar los Datos

para efectos de este ejemplo hagamos cuenta y caso que "cedula" es el id

haces el select asi:
$sql="SELECT nombre, sexo, cedula, direccion, barrio, tel_residencia, tel_celular, correo, dia, mes, año, estado_civil, mascota, tipo_mascota, carro, marca_carro, moto, marca_moto, ocupacion, lug_de_trabajo, tel_trabajo, nombre_pareja, dia_pareja, mes_pareja, año_pareja, num_perso_vive, num_hijos, nombre_hijo1, dia_hijo1, mes_hijo1, año_hijo1, nombre_hijo2, dia_hijo2, mes_hijo2, año_hijo2 FROM primera where cedula='".$_POST["Campo_cedula_de_tu_formulario"]."'"

Así con el POST llamas a la variable cedula que viene de tu formulario que es la misma que se introdujo a la base de datos, o sino también se me ocurre que metas ese dato en una sesión. Dependiendo si cedula es texto o numérico le quitas las comillas simples.
  #7 (permalink)  
Antiguo 28/04/2010, 08:19
 
Fecha de Ingreso: abril-2010
Mensajes: 50
Antigüedad: 14 años
Puntos: 0
Respuesta: Ayudaaaaa Registro y Como MOstrar los Datos

No mira lo e intentado pero me da error
ya me dice que la base de datos esta vacia cuando no lo esta

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\supermercado\otrapunt.php on line 17
¡ La base de datos está vacia !

y aca como ingrese el codigo que me diste
Código PHP:
$result mysql_query("SELECT nombre, sexo, cedula, direccion, barrio, tel_residencia, tel_celular, correo, dia, mes, año, estado_civil, mascota, tipo_mascota, carro, marca_carro, moto, marca_moto, ocupacion, lug_de_trabajo, tel_trabajo, nombre_pareja, dia_pareja, mes_pareja, año_pareja, num_perso_vive, num_hijos, nombre_hijo1, dia_hijo1, mes_hijo1, año_hijo1, nombre_hijo2, dia_hijo2, mes_hijo2, año_hijo2 FROM primera where cedula=".$_POST["cedula"], $link); 
  #8 (permalink)  
Antiguo 28/04/2010, 09:22
Avatar de dargor  
Fecha de Ingreso: octubre-2009
Mensajes: 134
Antigüedad: 14 años, 6 meses
Puntos: 2
Respuesta: Ayudaaaaa Registro y Como MOstrar los Datos

Se me ocurre que el $_POST["cedula"] no este entregando ningun dato, verifica con un echo $_POST["cedula"] para verificar que tiene una variable asignada.
  #9 (permalink)  
Antiguo 28/04/2010, 09:40
 
Fecha de Ingreso: febrero-2010
Mensajes: 818
Antigüedad: 14 años, 2 meses
Puntos: 55
Respuesta: Ayudaaaaa Registro y Como MOstrar los Datos

despues de insertar en la base de datos

donde tienes esto
mysql_select_db($database_validacion, $validacion);
$Result1 = mysql_query($insertSQL, $validacion) or die(mysql_error());

hace un if para ver si inserto en la BD y si es correcto hace un echo de todas las variables post
  #10 (permalink)  
Antiguo 28/04/2010, 15:01
 
Fecha de Ingreso: abril-2010
Mensajes: 50
Antigüedad: 14 años
Puntos: 0
Respuesta: Ayudaaaaa Registro y Como MOstrar los Datos

Pero El if Va Aca
$Result1 = mysql_query($insertSQL, $validacion) or die(mysql_error());
if (){
}
echo"texto";
y el resto?

me podrias ayudar a hacer el if ps como seria?

Etiquetas: registro
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 07:01.