Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/05/2014, 00:27
joseberrocalobando
 
Fecha de Ingreso: mayo-2014
Ubicación: Liberia, Guanacaste, Costa Rica
Mensajes: 17
Antigüedad: 10 años
Puntos: 0
Desacuerdo Notice Undefined variable x in /...

Buenas gente tengo un problema apenas estoy iniciando con esto del php, la situacion es la siguiente tengo un notice <b>Notice</b>: Undefined index: apellidos in <b>C:\xampp\htdocs\UCR\Nuevo.php</b> on line <b>7</b><br />

en el JavaScript tengo lo siguiente:

function GrabarDatos(){
try{
var carnet = document.getElementById("Carnet").value;
var nombre = document.getElementById("Nombre").value;
var apellidos = document.getElementById("Apellidos").value;
var fecha_nacimiento = document.getElementById("Fecha_Nacimiento").value;
var lugar_nacimiento = document.getElementById("Lugar_Nacimiento").value;
var telefono = document.getElementById("Telefono").value;
var direccion = document.getElementById("Direccion").value;
var sexo = "";
if (document.getElementById("radio1").checked == true)
sexo = "M"
if (document.getElementById("radio2").checked == true)
sexo = "F"
var promedio = document.getElementById("Promedio").value;
$.ajax({
url: 'Nuevo.php',
type: "POST",
data: "submit=&carnet=" +carnet + "&nombre=" + nombre + "&apellidos" + apellidos + "&fecha_nacimiento=" +fecha_nacimiento + "&lugar_nacimiento=" + lugar_nacimiento + "&telefono="+telefono + "&direccion=" + direccion + "&sexo=" +sexo + "&telefono=" + telefono + "&promedio=" + promedio,
success: function(datos){
ConsultaDatos();
alert(datos);
$("#formulario").hide();
$("#tabla").show();
}
});
return false;
}catch(e)
{
alert(e);
}
}

y donde tengo el error es aqui:
<?php

if(isset($_POST['submit'])){
require('clases/estudiantes.class.php');
$carnet = htmlspecialchars(trim($_POST['carnet']));
$nombre = htmlspecialchars(trim($_POST['nombre']));
if (isset($_POST['apellidos']))
{
$apellidos= htmlspecialchars(trim($_POST['apellidos']));
}
$fecha_nacimiento = htmlspecialchars(trim($_POST['fecha_nacimiento']));
$lugar_nacimiento = htmlspecialchars(trim($_POST['lugar_nacimiento']));
$telefono = htmlspecialchars(trim($_POST['telefono']));
$direccion = htmlspecialchars(trim($_POST['direccion']));
$sexo = htmlspecialchars(trim($_POST['sexo']));
$promedio = htmlspecialchars(trim($_POST['promedio']));

$objCliente=new Cliente;
if ( $objCliente->insertar(array($carnet, $nombre, $apellidos, $fecha_nacimiento, $lugar_nacimiento, $telefono, $direccion, $sexo, $promedio)) == true){
echo 'Datos guardados';
}else{
echo 'Se produjo un error. Intente nuevamente';
}
}
?>

la verdad no se porque esta quedando perdida esa variable...

de verdad agradeceria su ayuda
Gracias