Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/03/2015, 09:59
joscol
 
Fecha de Ingreso: marzo-2015
Ubicación: zulia
Mensajes: 71
Antigüedad: 9 años, 2 meses
Puntos: 0
me podrían ayudar con mi base de datos en php y mysql

soy nuevo en el foro y por segunda vez me gustaría que me ayudaran con esta base de datos ya que estuve un tiempo sin programar y se me olvido casi todo ademas de que era poco lo que sabia.

es urgente y necesito su ayuda

necesito que mi base de datos guarde información pero que al ingresar ciertos tipos de datos estos no se repitan ya que tienen que ser caracteres únicos.

un ejemplo seria la cédula, que en mi país es un numero de un documento de identificación único y que dos personas no lo pueden tener igual.

como hago para que al ingresarlo en un formulario y al darle el botón enviar, este me de una advertencia de que ya ese dato fue ingresado.


las partes en rojo son las que no se pueden repetir


index.php


<html>
<head>
<title> FORMULARIO DE REGISTRO </title>
</head>

<body>
<h1> FORMULARIO DE REGISTRO </h1>
<h5> todos los campos son requeridos </h5>
<form method="post" action="" />
<table>
<tr>
<td>
RIF DEL CONSEJO COMUNAL:
</td>
<td>
<input type="text" maxlength="10" name="rif_user"
</td>
</tr>

<tr>
<td>
NOMBRE DEL CONSEJO COMUNAL:
</td>
<td>
<input type="text" maxlength="100" name="nombre_user"
</td>
</tr>

<tr>
<td>
UBICACION DEL CONSEJO COMUNAL:
</td>
<td>
<input type="text" maxlength="150" name="ubicación_user"
</td>
</tr>
<tr>
<td>
CORREO DEL CONSEJO COMUNAL:
</td>
<td>
<input type="text" maxlength="50" name="correo_user"
</td>
</tr>

<tr>
<td>
TELEFONO DEL CONSEJO COMUNAL:
</td>
<td>
<input type="text" maxlength="11" name="telefono_user"
</td>
</tr>

<tr>
<td>
PRIMER REPRESENTANTE DEL CONSEJO COMUNAL:
</td>
<td>
<input type="text" maxlength="50" name="representante1"
</td>
</tr>
<tr>
<td>
CEDULA DEL PRIMER REPRESENTANTE:
</td>
<td>
<input type="text" maxlength="9" name="cedula_repre1"
</td>
</tr>

<tr>
<td>
CARGO DEL PRIMER REPRESENTANTE:
</td>
<td>
<input type="text" maxlength="50" name="cargo_repre1"
</td>
</tr>
<tr>
<td>
CORREO DEL PRIMER REPRESENTANTE:
</td>
<td>
<input type="text" maxlength="50" name="correo_repre1"
</td>
</tr>

<tr>
<td>
TELEFONO DEL PRIMER REPRESENTANTE:
</td>
<td>
<input type="text" maxlength="11" name="telefono_repre1"
</td>
</tr>

<tr>
<td>
SEGUNDO REPRESENTANTE DEL CONSEJO COMUNAL:
</td>
<td>
<input type="text" maxlength="50" name="representante2"
</td>
</tr>
<tr>
<td>
CEDULA DEL SEGUNDO REPRESENTANTE:
</td>
<td>
<input type="text" maxlength="9" name="cedula_repre2"
</td>
</tr>

<tr>
<td>
CARGO DEL SEGUNDO REPRESENTANTE:
</td>
<td>
<input type="text" maxlength="50" name="cargo_repre2"
</td>
</tr>
<tr>
<td>
CORREO DEL SEGUNDO REPRESENTANTE:
</td>
<td>
<input type="text" maxlength="50" name="correo_repre2"
</td>
</tr>

<tr>
<td>
TELEFONO DEL SEGUNDO REPRESENTANTE:
</td>
<td>
<input type="text" maxlength="11" name="telefono_repre2"
</td>
</tr>

<tr>
<td>
CONTRASEÑA:
</td>
<td>
<input type="password" maxlength="20" name="pass_user"
</td>
</tr>
<tr>
<td>
REPETIR CONTRASEÑA:
</td>
<td>
<input type="password" maxlength="20" name="rpass_user"
</td>
</tr>
</table>
<input type="submit" name="submit" value="registrar" /> <input type="reset" />
</form>
<?php
if (isset ($_POST['submit'])) {
require("registro.php");
}
?>
</body>
</html>



registro.php


<?php
$rif_user = $_POST['rif_user'];
$nombre_user = $_POST['nombre_user'];
$ubicación_user = $_POST['ubicación_user'];
$correo_user = $_POST['correo_user'];
$telefono_user = $_POST['telefono_user'];
$representante1 = $_POST['representante1'];
$cedula_repre1 = $_POST['cedula_repre1'];
$cargo_repre1 = $_POST['cargo_repre1'];
$correo_repre1 = $_POST['correo_repre1'];
$telefono_repre1 = $_POST['telefono_repre1'];
$representante2 = $_POST['representante2'];
$cedula_repre2 = $_POST['cedula_repre2'];
$cargo_repre2 = $_POST['cargo_repre2'];
$correo_repre2 = $_POST['correo_repre2'];
$telefono_repre2 = $_POST['telefono_repre2'];
$pass_user = $_POST['pass_user'];
$rpass_user = $_POST['rpass_user'];
$reqlen = strlen($rif_user) * strlen($nombre_user) * strlen($ubicación_user) * strlen($correo_user) * strlen($telefono_user) * strlen($representante1) * strlen($cedula_repre1) * strlen($cargo_repre1) * strlen($correo_repre1) * strlen($telefono_repre1) * strlen($representante2) * strlen($cedula_repre2) * strlen($cargo_repre2) * strlen($correo_repre2) * strlen($telefono_repre2) * strlen($pass_user) * strlen($rpass_user);
if ($reqlen > 0) {
if ($pass_user === $rpass_user) {
require ("connect_db.php");
$pass_user = md5($pass_user);
mysql_query("INSERT INTO usuarios VALUES ('','$rif_user','$nombre_user','$ubicación_user',' $correo_user','$telefono_user','$representante1',' $cedula_repre1','$cargo_repre1','$correo_repre1',' $correo_repre1','$telefono_repre1','$representante 2','$cedula_repre2','$cargo_repre2','$telefono_rep re2','$pass_user')");
mysql_close($link);
echo 'Se ha registrado correctamente';
} else {
echo 'Las Contraseñas no son Identicas';
}
} else {
echo 'Introduzca Informacion en Todos los Campos';
}


?>



connect_db.php


<?php
$link = mysql_connect("localhost","root","21544298");
if ($link) {
mysql_select_db("jornada",$link);
}
?>




gracias de antemano