I have a form, where users enter personal data. I did an if, so that the CURP was not repeated, if the curp is repeated it sends an alert telling them that it is repeated and it returns them to the form, in that I do not have problem it seems to me, but in the else of that condition, that is to say when enter a curp that is not repeated in the base, execute the insertion of the data that the user filled in the form to the database and after that, I make a declaration of variables calling the data that the user filled with the method $ _REQUEST and in the end I print them, but what I want is to also print the id of the user that is registering, for this I need a query in my database and what I want is to select the id of the user where my field CURP is equal to the CURP that you entered in user, to indicate that this is your id and that you must save it, but it does not work out, this is my code.
<?php
$conexion=mysql_connect("localhost","id6681618_pagina26","aldair1234")
or die ("Problemas en la conexion");
mysql_select_db("id6681618_pagina26",$conexion)
or die("Problemas en la conexion de la base de datos");
$inscripciones=mysql_query("SELECT FOLIO, CURP
FROM inscripciones where
CURP='$_REQUEST[CURP]'",$conexion) or
die("Problemas en el select:".mysql_error());
if($reg=mysql_fetch_array($inscripciones))
{
$mensaje = "Este CURP ya fue ingresado, por favor intenta nuevamente.";
echo "<script>";
echo "alert('$mensaje');";
echo "history.back();";
echo "</script>";
//redirect('formulario.html', 'refresh');
//header( "refresh:5;url=formulario.html" );
}
This is the else:
else
{
mysql_query("insert into inscripciones(NOMBRE, APELLIDOPA, APELLIDOMA, CURP) values ('$_REQUEST[NOMBRE]','$_REQUEST[APELLIDOPA]','$_REQUEST[APELLIDOMA]','$_REQUEST[CURP]')", $conexion) or die("Problemas en el select".mysql_error());
mysql_close($conexion);
print '<script language="JavaScript">';
print 'alert("Proceso terminado");';
print '</script>';
}
Then I do my variables and finish the PHP:
$nom=$_REQUEST['NOMBRE'];
$apellipa=$_REQUEST['APELLIDOPA'];
$apellima=$_REQUEST['APELLIDOMA'];
$curp=$_REQUEST['CURP'];
?>
And now the impressions follow, that is, the query, this is for the user to check if his data is correct or not, but he does not show me the first id, he appears blank, when he reloads the page he shows it to me, but the CURP code returns me immediately to the form.
<h1>Verifica que los datos que ingresaste sean correctos, si así lo es, presiona para generar tu ficha.</h1>
<form action="eliminar.php">
<div class="col-4">
<label>
FOLIO
<input name="FOLIO" type="text" disabled="false" value="<?php echo $reg['FOLIO']; ?>" />
</label>
</div>
<div class="col-4">
<label>
NOMBRE
<input name="NOMBRE" type="text" disabled="false" value="<?php echo $nom ?>" />
</label>
</div>
<div class="col-4">
<label>
APELLIDO PATERNO
<input name="APELLIDOPA" type="text" disabled="false" value="<?php echo $apellipa ?>" />
</label>
</div>
<div class="col-4">
<label>
APELLIDO MATERNO
<input name="APELLIDOMA" type="text" disabled="false" value="<?php echo $apellima?>" />
</label>
</div>
<div class="col-3">
<label>
CURP
<input name="CURP" type="text" disabled="false" value="<?php echo $curp ?>" />
</label>
</div>
I would really appreciate it if you can help me, I've been thinking about how to do it for several days. : 'v