Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/06/2012, 14:36
oliverm
 
Fecha de Ingreso: noviembre-2008
Mensajes: 23
Antigüedad: 15 años, 5 meses
Puntos: 0
Datos del formulario HTML no llegan a PHP

Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registro Empleados</title>
</head>

<body>

<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
  <p><b>Formulario de registro de Empleado</b> <br><br>
    
    Primer nombre: <input type="text" name="nombre"><br>
    Primer apellido: <input type="text" name="apellido"><br>
    RUT: <input type="text" name="rut_e"><br>
    Calle y número: <input type="text" name="calle_nro"><br>
    Comuna: <input type="text" name="comuna"><br>
    Región: <input type="text" name="region"><br>
    Fecha contrato: <input type="text" name="fecha_contrato"><br>
    Tipo Empleado: <select name="tipo_empleado"><option>a</option><option>v</option><option>j</option>
</select>
    Rut jefe: <input type="text" name="rut_a_fk">
  </p>
  <p>	
    <input type="submit" value="Registrar" />
    <br>
  </p>
</form>
 
<?php
 
if(isset($_POST['nombre'])){
 
$host="localhost";
$username="root";
$password="";

$conexion=mysql_connect($host,$username,$password)  or die(mysql_error()); 
$db = @mysql_select_db("omohr4", $conexion) or die(mysql_error()); 
$nombre=$_POST["nombre"];
$apellido=$_POST["apellido"];
$rut_e=$_POST["rut_e"];
$calle_nro=$_POST["calle_nro"];
$comuna=$_POST["comuna"];
$region=$_POST["region"];
$fecha_contrato=$POST["fecha_contrato"];
$tipo_empleado=$POST["tipo_empleado"];
$rut_a_fk=$POST["rut_a_fk"];


mysql_query("INSERT INTO empleado (`rut_e`, `nombre`, `apellido`, `calle_nro`, `comuna`, `region`,`fecha_contrato`,`tipo_empleado`,`rut_a_fk`) VALUES ('$rut_e','$nombre','$apellido','$calle_nro','$comuna','$region','$fecha_contrato','$tipo_empleado','$rut_a_fk')") or die(mysql_error());


if ($tipo_empleado = a)
{
$titulo="DEFECTO";
mysql_query("INSERT INTO administrador (`rut_a`, `titulo`) VALUES ('$rut_e,'$titulo')") or die(mysql_error());
}
if ($tipo_empleado=v)
{
mysql_query("INSERT INTO vendedor (rut_v) VALUES ('rut_e')") or die(mysql_error());
}
if ($tipo_empleado=j)
{
$cargo_mantencion="DEFECTO";
mysql_query("INSERT INTO junior (rut_j, cargo_mantencion) VALUES ('$rut_e, '$cargo_mantencion')") or die(mysql_error());
}

}
?>

</body>
</html> 
Lo que pasa es que al registrar un empleado me sale este error abajo:

Notice: Undefined variable: POST in C:\xampp\htdocs\registroempleado.php on line 46

Notice: Undefined variable: POST in C:\xampp\htdocs\registroempleado.php on line 47

Notice: Undefined variable: POST in C:\xampp\htdocs\registroempleado.php on line 48
Cannot add or update a child row: a foreign key constraint fails (`omohr4`.`empleado`, CONSTRAINT `rut_a_fk` FOREIGN KEY (`rut_a_fk`) REFERENCES `administrador` (`rut_a`) ON DELETE NO ACTION ON UPDATE NO ACTION)



Agradecería alguien me ayude.

Saludos.