VeneHosting.com :: Tu Hosting en Venezuela

Autor Tema: Ayuda Urgente  (Leído 269 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado alicebermudez

  • Novato
  • *
  • Mensajes: 4
  • Puntuación: 0
    • Ver Perfil
Ayuda Urgente
« : 28 de noviembre de 2011, 08:35:47 pm »
 :-[ Buenas, esta es mi primera vez en este foro estoy desesperada voy a defender mi tesis el dia jueves de esta semana y no he logrado validar los campos cedulas( si existe no duplicar) y es requisito indispensable para que me aprueben la tesis, les dejo parte del codigo :'(
<?php
session_start();
if (isset($_SESSION['s_username'])) {

?>

<html>
<head>
<title>SRCMT- Registro Civil</title>
<link href="estilo.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="valform.js"> </script>

<style type="text/css">
<!--
.Estilo2 {color: #FF0000}
-->
</style>

<Script Language="JavaScript">
<!--
function mensaje()
{
window.alert("¡¡¡Los Datos han sido Guardados Exitosamente!!!")
}

function mensaje2()
{
window.alert("¡¡¡ Debe LLenar todos los Campos !!!")
}
function opcion_si()
{
formul.nota_marginal.value = "";
}
function opcion_no()
{
formul.nota_marginal.value = "SIN NOTA MARGINAL";
}

//-->
</Script>
</head>

<body onLoad="JavaScript: document.formul.numero.focus();">

<?php if (isset($_POST['guardar'])) {

$post_ano = $_POST['ano'];
$post_numero = $_POST['numero'];
$post_folio = $_POST['folio'];
$post_fecha = $_POST['fecha'];

$post_aut = $_POST['nombre_aut'];
$post_cargo = $_POST['cargo'];
$post_cedula_aut = $_POST['cedula_aut'];

$post_nombre_nino = strtoupper($_POST['nombre_nino']);
$post_sexo = $_POST['sexo'];
$post_dia = $_POST['dia'];
$post_mes = $_POST['mes'];
$post_year = $_POST['year'];
$post_nacido = strtoupper($_POST['nacido']);
$post_hora = $_POST['hora'];
$post_minutos = $_POST['minutos'];
$post_am_pm = $_POST['am_pm'];
$post_lugar_nino = strtoupper($_POST['lugar_nino']);
$post_municipio_nino = strtoupper($_POST['municipio_nino']);
$post_estado_nino = strtoupper($_POST['estado_nino']);
$post_legitimo = strtoupper($_POST['legitimo']);

$post_nombre_testigo1 = strtoupper($_POST['nombre_testigo1']);
$post_cedula_testigo1 = $_POST['cedula_testigo1'];
$post_nombre_testigo2 = strtoupper($_POST['nombre_testigo2']);
$post_cedula_testigo2 = $_POST['cedula_testigo2'];

$post_nombre_madre = strtoupper($_POST['nombre_madre']);
$post_cedula_madre = $_POST['cedula_madre'];
$post_edad_madre = $_POST['edad_madre'];
$post_nacionalidad_madre = $_POST['nacionalidad_madre'];
$post_civil_madre = $_POST['civil_madre'];
$post_prof_madre = strtoupper($_POST['prof_madre']);
$post_domicilio_madre = strtoupper($_POST['domicilio_madre']);
$post_lugar_madre = strtoupper($_POST['lugar_madre']);
$post_municipio_madre = strtoupper($_POST['municipio_madre']);
$post_estado_madre = strtoupper($_POST['estado_madre']);

$post_nombre_padre = strtoupper($_POST['nombre_padre']);
$post_cedula_padre = $_POST['cedula_padre'];
$post_edad_padre = $_POST['edad_padre'];
$post_nacionalidad_padre = $_POST['nacionalidad_padre'];
$post_civil_padre = $_POST['civil_padre'];
$post_prof_padre = strtoupper($_POST['prof_padre']);
$post_domicilio_padre = strtoupper($_POST['domicilio_padre']);
$post_lugar_padre = strtoupper($_POST['lugar_padre']);
$post_municipio_padre = strtoupper($_POST['municipio_padre']);
$post_estado_padre = strtoupper($_POST['estado_padre']);

$post_nombre_otro = strtoupper($_POST['nombre_otro']);
$post_cedula_otro = $_POST['cedula_otro'];
$post_edad_otro = $_POST['edad_otro'];
$post_nacionalidad_otro = $_POST['nacionalidad_otro'];
$post_civil_otro = $_POST['civil_otro'];
$post_prof_otro = strtoupper($_POST['prof_otro']);
$post_parentesco = strtoupper($_POST['parentesco']);
$post_domicilio_otro = strtoupper($_POST['domicilio_otro']);
$post_lugar_otro = strtoupper($_POST['lugar_otro']);
$post_municipio_otro = strtoupper($_POST['municipio_otro']);
$post_estado_otro = strtoupper($_POST['estado_otro']);

$post_usuario = $_SESSION['s_username'];

@$post_presentacion = @$_POST['rad_presentacion'];
if ($post_presentacion == 'rad_padre') {
 $post_pre_padre = 1;
 $post_pre_madre = 0;
 $post_pre_otro = 0;
}

if ($post_presentacion == 'rad_madre') {
 $post_pre_padre = 0;
 $post_pre_madre = 1;
 $post_pre_otro = 0;
}

if ($post_presentacion == 'rad_otro') {
 $post_pre_padre = 0;
 $post_pre_madre = 0;
 $post_pre_otro = 1;
}

$post_op_marginal = $_POST['rad_marginal'];
$post_nota_marginal = strtoupper($_POST['nota_marginal']);
if ($post_op_marginal == 'nota_si') {
 $post_op_marginal_t = "SI";
}
if ($post_op_marginal == 'nota_no') {
 $post_op_marginal_t = "NO";
}

if ($post_am_pm == 'AM'){
   $post_am_pm_t = 1;
}
if ($post_am_pm == 'PM'){
   $post_am_pm_t = 2;
}
list($diax,$mesx,$aniox)=explode("-",$post_fecha);
$post_fecha_t = "$aniox-$mesx-$diax";

$post_fecha_nac = "$post_year-$post_mes-$post_dia";

if ($post_sexo=="MASCULINO") {
    $post_sexo_t = 1;
    } else {
    $post_sexo_t = 2;
}


if ($_POST['ano'] <> "" and $_POST['numero'] <> "" and $_POST['folio'] <> "" and $_POST['fecha'] <> "" and $_POST['nombre_nino'] <> "" and $_POST['sexo'] <> "" and $_POST['dia'] <> "" and $_POST['mes'] <> "" and $_POST['year'] <> "" and $_POST['nacido'] <> "" and $_POST['hora'] <> "" and $_POST['minutos'] <> "" and $_POST['am_pm'] <> "" and $_POST['lugar_nino'] <> "" and $_POST['municipio_nino'] <> "" and $_POST['estado_nino'] <> "" and $_POST['nombre_testigo1'] <> "" and $_POST['cedula_testigo1'] <> "" and $_POST['nombre_testigo2'] <> "" and $_POST['cedula_testigo2'] <> "" and $_POST['nombre_madre'] <> "" and $_POST['cedula_madre'] <> "" and $_POST['edad_madre'] <> "" and $_POST['nacionalidad_madre'] <> "" and $_POST['civil_madre'] <> "" and $_POST['prof_madre'] <> "" and $_POST['domicilio_madre'] <> "" and $_POST['lugar_madre'] <> "" and $_POST['municipio_madre'] <> "" and $_POST['estado_madre'] <> "" and $_POST['nombre_padre'] <> "" and $_POST['cedula_padre'] <> "" and $_POST['edad_padre'] <> "" and $_POST['nacionalidad_padre'] <> "" and $_POST['civil_padre'] <> "" and $_POST['prof_padre'] <> "" and $_POST['domicilio_padre'] <> "" and $_POST['lugar_padre'] <> "" and $_POST['municipio_padre'] <> "" and $_POST['estado_padre'] <> "" and $_POST['rad_presentacion'] <> "" and $_POST['nombre_otro'] <> "" and $_POST['cedula_otro'] <> "" and $_POST['edad_otro'] <> "" and $_POST['nacionalidad_otro'] <> "" and $_POST['civil_otro'] <> "" and $_POST['prof_otro'] <> "" and $_POST['parentesco'] <> "" and $_POST['domicilio_otro'] <> "" and $_POST['lugar_otro'] <> "" and $_POST['municipio_otro'] <> "" and $_POST['estado_otro'] <> "" and $_POST['nota_marginal'] <> "") {


include ("conectar.php");

$consulta="insert into nacimientos (ano,numero,fecha,folio,autoridad,cargo_autoridad,cedula_autoridad,nombre_madre,edad_madre,nacionalidad_madre,civil_madre,cedula_madre,prof_madre,domicilio_madre,ciudad_madre,municipio_madre,estado_madre,presenta_madre,nombre_padre,edad_padre,nacionalidad_padre,civil_padre,cedula_padre,prof_padre,domicilio_padre,ciudad_padre,municipio_padre,estado_padre,presenta_padre,nombre_nino,sexo_nino,fecha_nino,hospital,hora,minuto,am_pm,ciudad_nino,municipio_nino,estado_nino,legitimo,cedula_testigo1,nombre_testigo1,cedula_testigo2,nombre_testigo2,nombre_otro,cedula_otro,edad_otro,nacionalidad_otro,civil_otro,prof_otro,parentesco,domicilio_otro,ciudad_otro,municipio_otro,estado_otro,op_marginal,nota_marginal,usuario)values($post_ano,$post_numero,'$post_fecha_t','$post_folio','$post_aut','$post_cargo',$post_cedula_aut,'$post_nombre_madre',$post_edad_madre,'$post_nacionalidad_madre','$post_civil_madre',$post_cedula_madre,'$post_prof_madre','$post_domicilio_madre','$post_lugar_madre','$post_municipio_madre','$post_estado_madre',$post_pre_madre,'$post_nombre_padre',$post_edad_padre,'$post_nacionalidad_padre','$post_civil_padre',$post_cedula_padre,'$post_prof_padre','$post_domicilio_padre','$post_lugar_padre','$post_municipio_padre','$post_estado_padre',$post_pre_padre,'$post_nombre_nino',$post_sexo_t,'$post_fecha_nac','$post_nacido',$post_hora,$post_minutos,$post_am_pm_t,'$post_lugar_nino','$post_municipio_nino','$post_estado_nino','$post_legitimo',$post_cedula_testigo1,'$post_nombre_testigo1',$post_cedula_testigo2,'$post_nombre_testigo2','$post_nombre_otro',$post_cedula_otro,$post_edad_otro,'$post_nacionalidad_otro','$post_civil_otro','$post_prof_otro','$post_parentesco','$post_domicilio_otro','$post_lugar_otro','$post_municipio_otro','$post_estado_otro','$post_op_marginal_t','$post_nota_marginal','$post_usuario');";
$query = mysql_query($consulta); ?>

<form action="registrar_nacimiento.php" name="formul" method="post">

<script language="JavaScript">
   var w = 400;
   var h = 150;
   resizeTo(w, h);
   moveTo((screen.width - w)/ 2, (screen.height - h)/ 2);
  </script>

<script language="JavaScript">
<!--

function asignarfoco()

{
   if (document.formul.numero.value.length==6)
     {
      document.formul.numero.focus();
    }
}
-->
</script>

Desconectado eape

  • Usuario Junior
  • **
  • Mensajes: 83
  • Puntuación: 0
  • Sexo: Masculino
    • Ver Perfil
Re:Ayuda Urgente
« Respuesta #1 : 30 de noviembre de 2011, 08:39:01 am »
Antes que todo BUenos Días
Que el Señor Jesucristo le guarde y le ayude en su tesis
Estimada alicebermudez
imagino que esa información esta guardada en un tabla de una base de datos, si es asi a continuación te explicare como hacerlo:
Primero creas una variable de consulta ejemplo
$sqlConsulta = "SELECT * FROM tabla WHERE cedula='". $_POST['cedula_testigo1']. "'";

Posteriormente estableces la conexion con la base de datos

$hostname = "localhost";

$database = "inventario_nx";

$username = "root";

$password = "";

$cnx = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);

mysql_select_db($database, $cnx);

$Consulta = mysql_query($sqlConsulta,$cnx) or die(mysql_error());

if (mysql_affected_rows() == 0) {

// AQUI COLOCAS EL CODIGO PARA GUARDAR LA INFORMACIÓN
}

else {

                 echo "La Cedula ". $_POST['cedula_testigo1']. "  ya existe ";

}




Espero que te sirva y cualquier cosa estamos a la orden
Feliz Día
CRISTO NOS AMA
¿Sabes el Nombre de Dios?

Desconectado el_santo

  • Usuario Dedicado
  • ***
  • Mensajes: 192
  • Puntuación: 7
  • Sexo: Masculino
    • Ver Perfil
Re:Ayuda Urgente
« Respuesta #2 : 30 de noviembre de 2011, 12:46:14 pm »
Antes que todo BUenos Días
Que el Señor Jesucristo le guarde y le ayude en su tesis
Estimada alicebermudez
imagino que esa información esta guardada en un tabla de una base de datos, si es asi a continuación te explicare como hacerlo:
Primero creas una variable de consulta ejemplo
$sqlConsulta = "SELECT * FROM tabla WHERE cedula='". $_POST['cedula_testigo1']. "'";

Posteriormente estableces la conexion con la base de datos

$hostname = "localhost";

$database = "inventario_nx";

$username = "root";

$password = "";

$cnx = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);

mysql_select_db($database, $cnx);

$Consulta = mysql_query($sqlConsulta,$cnx) or die(mysql_error());

if (mysql_affected_rows() == 0) {

// AQUI COLOCAS EL CODIGO PARA GUARDAR LA INFORMACIÓN
}

else {

                 echo "La Cedula ". $_POST['cedula_testigo1']. "  ya existe ";

}




Espero que te sirva y cualquier cosa estamos a la orden
Feliz Día
CRISTO NOS AMA

Se debe usar mysql_num_rows o un select usando un count

http://www.php.net/manual/es/function.mysql-num-rows.php

affected_rows se usar cuando una peticion realiza alguna alteracion por sobre los registros consultados... ver referencia
Yo hablo php........!!!

Desconectado eape

  • Usuario Junior
  • **
  • Mensajes: 83
  • Puntuación: 0
  • Sexo: Masculino
    • Ver Perfil
Re:Ayuda Urgente
« Respuesta #3 : 30 de noviembre de 2011, 01:50:30 pm »
Tienes razon
el_santo
Es como tu dices disculpen el error. recuerden que errar es de humano y rectificar de sabio.
Ademas de los errores se aprende.
¿Sabes el Nombre de Dios?

PHP de Venezuela

Re:Ayuda Urgente
« Respuesta #3 : 30 de noviembre de 2011, 01:50:30 pm »

 

PHP de Venezuela on Facebook