seque esto ya se ha solucionado antes pero aun ami no me sale realmetne no lo se si me falta algo o que sera ps
espero me ayuden ...
se em dupñica la persona ingresada y deseariaque esto no sucediera yaque si ingresa otra vez le pagan mas a el usuario cuando n oes verdad y para que esto nopase no debe duplicarse en la base de datos
espero su apoyo en esto ..
Código PHP:
<?
session_start();
include("include/db.php");
include("include/functions.php");
db_connect();
$meses = array('01' => 'Enero', '02' => 'Febrero', '03' => 'Marzo', '04' => 'Abril', '05' => 'Mayo', '06' => 'Junio', '07' => 'Julio',
'08' => 'Agosto', '09' => 'Setiembre', '10' => 'Octubre', '11' => 'Noviembre', '12' => 'Diciembre');
if(!isset($_SESSION['user'])) {
header("Location: index.php");
}
if(isset($_POST['Registrar'])) {
$ins_personal = "INSERT INTO personal(paterno, materno, nombres, dni, fec_nac, sexo, direccion, id_departamento, id_provincia, id_distrito, telefono, celular, email, profesion, grado_academico, asignatura, nombre_banco, nro_cuenta, fec_registro, ind_personal, usuario_registro, tipo_user)
VALUES('" . $_POST['paterno'] . "', '" . $_POST['materno'] . "', '" . $_POST['nombres'] . "', '" . $_POST['dni'] . "', '" . $_POST['ano'] . '-' . $_POST['mes'] . '-' . $_POST['dia'] . "', '" . $_POST['sexo'] . "', '" . $_POST['direccion'] . "', '" . $_POST['id_departamento'] . "', '" . $_POST['id_provincia'] . "', '" . $_POST['id_distrito'] . "', '" . $_POST['telefono'] . "', '" . $_POST['celular'] . "', '" . $_POST['email'] . "', '" . $_POST['profesion'] . "', '". $_POST['grado_academico']."'. '". $_POST['asignatura']."'. '". $_POST['nombre_banco'] . "', '" . $_POST['nro_cuenta'] . "', '" . date('Y-m-d H:i') . "', 'S', '" . $_SESSION['id_usuario'] . "', '5')";
echo $ins_personal;
db_query($ins_personal);
header("Location: " . $_SERVER['PHP_SELF']);
}
?>
<html>
<head>
<title>CESAD</title>
<link rel="stylesheet" href="include/estilos.css" type="text/css">
<script language="JavaScript" src ="include/common.js"> </script>
<script language="JavaScript" type="text/javascript">
function ajax_provincia() {
if (http.readyState == 4) { //4: completado
if (http.status == 200) { //200: OK
res = http.responseText;
document.getElementById('prov').innerHTML = res;
//Procesarespuesta();
}
else { //Se produjo un error
alert("Error: " + http.statusText);
}
}
}
function ajax_distrito() {
if (http.readyState == 4) { //4: completado
if (http.status == 200) { //200: OK
res = http.responseText;
document.getElementById('dist').innerHTML = res;
//Procesarespuesta();
}
else { //Se produjo un error
alert("Error: " + http.statusText);
}
}
}
function buscaProvincia(IDdep) {
//alert("dep=" + IDdep);
http.open('get', 'proc_provincia.php?IDdep=' + IDdep);
http.onreadystatechange = ajax_provincia;
http.send(null);
}
function buscaDistrito(IDdep, IDdist) {
//alert("dep=" + IDdep + ", dist=" + IDdist);
http.open('get', 'proc_distrito.php?IDdep=' + IDdep + '&IDdist=' + IDdist);
http.onreadystatechange = ajax_distrito;
http.send(null);
}
function validaPersonal() {
if(document.frmPersonal.paterno.value == '') {
alert("Debe ingresar el apellido paterno");
document.frmPersonal.paterno.focus();
return false;
}
if(document.frmPersonal.materno.value == '') {
alert("Debe ingresar el apellido materno");
document.frmPersonal.materno.focus();
return false;
}
if(document.frmPersonal.nombres.value == '') {
alert("Debe ingresar el nombre");
document.frmPersonal.nombres.focus();
return false;
}
if(document.frmPersonal.grado.value == ''){
alert("Debe ingresar el grado academico");
document.frmPersonal.grado.focus();
return false;
}
if(document.frmPersonal.dni.value == '') {
alert("Debe ingresar el numero de DNI");
document.frmPersonal.dni.focus();
return false;
}
if (isset($_POST[Registrar]) && $_POST[personal] !="")
{
$dni= strtolower($_POST[personal]);
$dni = htmlentities($dni);
//$dni = strtolower(htmlentities($_POST[personal]));
$sql = mysql_query(SELECT * FROM ins_personal WHERE dni = '$dni')
if (mysql_num_rows($sql) == 0)
{
echo "Usaurio Creado";
}
else
{
echo "el usuario existe";
}
}
/*if(document.frmPersonal.direccion.value == '') {
alert("Debe ingresar la direccion");
document.frmPersonal.direccion.focus();
return false;
}
if(document.frmPersonal.telefono.value == '') {
alert("Debe ingresar el telefono");
document.frmPersonal.telefono.focus();
return false;
}*/
return true;
}
</script>
</head>
<body>
<?include("cabecera.php");?>
<form name="frmPersonal" method="post" action="<?echo $_SERVER['PHP_SELF']?>" onsubmit="return validaPersonal();">
<table border="0" width="774" height="458" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<table border="0" width="500" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center"><p class="clsLblTituloPagina">Registro Datos de Tutor</p></td>
</tr>
<tr>
<td><hr></td>
</tr>
</table><br>
<table border="0" width="500" cellpadding="0" cellspacing="0" align="center">
<tr>
<td colspan="2" class="clsTituloTabla">Datos Personales</td>
</tr>
<tr>
<td height="2"> </td>
</tr>
<tr>
<td>Apellido Paterno:</td>
-----------------------------------------------------(//aqui poner el ingreso de los valores_________________________________
<td align="center">
<input type="submit" name="Registrar" value="Registrar Datos" class="clsSubmit">
<input type="reset" name="limpiar" value="Limpiar" class="clsSubmit">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?include("pie.php");?>
</body>
</html>