
05/03/2009, 21:08
|
| | Fecha de Ingreso: marzo-2009
Mensajes: 22
Antigüedad: 16 años Puntos: 0 | |
Respuesta: Formulario en partes No me marca error, pero me sigue guardando el nombre duplicado.
te paso el codigo entero de nuevo, saludos:
Código:
<?
include "conexion.php";
if (!isset($_GET["accion"])){
echo"
<html>
<head><title>Guardar datos en la base</title><style type=\"text/css\">
<!--
body,td,th {
color: #FFFFFF;
}
-->
</style></head>
<body bgcolor=\"#000000\">
<center><table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td height=\"71\"><img src=\"titulo.jpg\" width=\"500\" height=\"71\"></td>
</tr>
<tr>
<td height=\"529\" background=\"fondo.jpg\">
<center>
<form name=\"form1\" method=\"post\"
action=\"guardar.php?accion=guardar\">
<p>Vendedor:<br>
<input type=\"text\" name=\"vendedor\">
<br />
Fecha:<br>
<input type=\"text\" name=\"fecha\">
<br />
Nombre del Doctor:<br>
<input type=\"text\" name=\"nombre\">
<br />
Calle:<br>
<input type=\"text\" name=\"calle\">
<br />
Numero Externo e Interno:<br>
<input type=\"text\" name=\"numero\">
<br />
Colonia:<br>
<input type=\"text\" name=\"colonia\">
<br />
Delegacion:<br>
<input type=\"text\" name=\"delegacion\">
<br />
Telefono:<br>
<input type=\"text\" name=\"telefono\">
<br />
Correo Electronico:<br>
<input type=\"text\" name=\"correo\">
</p>
<p>
<input type=\"submit\" name=\"Submit\" value=\"Guardar Datos\">
</p>
</form>
</center>
</td>
</tr>
</center>
</body>
</html>";
}elseif($_GET["accion"]=="guardar"){
include "conexion.php";
$pag_referida = $url[0];
$redir = $pag_referida;
$vendedor = $_POST['vendedor'];
$fecha = $_POST['fecha'];
$nombre = $_POST['nombre'];
$calle = $_POST['calle'];
$numero = $_POST['numero'];
$colonia = $_POST['colonia'];
$delegacion = $_POST['delegacion'];
$telefono = $_POST['telefono'];
$correo = $_POST['correo'];
$sql = "SELECT nombre FROM doctores WHERE nombre='$nombre'";
$result = mysql_query($sql);
if(mysql_num_rows($result) > 0)
{
header ("Location: $redir?error_login=1");
exit;
}
else{
$result=mysql_query("INSERT INTO doctores (vendedor,fecha,nombre,calle,numero,colonia,delegacion,telefono,correo)
VALUES ('.$vendedor.','.$fecha.','.$nombre.','.$calle.','.$numero.','.$colonia.','.$delegacion.','.$telefono.','.$correo.')",$conexion);
};
echo" <html>
<head></head>
<body bgcolor=\"#000000\">
<center><table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td height=\"71\"><img src=\"titulo.jpg\" width=\"500\" height=\"71\"></td>
</tr>
<tr>
<td height=\"529\" background=\"fondo.jpg\">
<center>
<p></p>
<p></p>
<p>LOS DATOS HAN SIDO AGREGADOS<br>
</p>
</center>
</td>
</tr>
</center>
</body>
</html>";
}
include "cerrar_conexion.php";
?>
|