예제 #1
0
    $idCategoria = $_POST['categoria'];
    $nombreTema = $_POST['tema_nombre'];
    $idTema = $_POST['id_tema'];
    if ($idCategoria == "default") {
        $notifMsg = "Debes introducir una categoria";
        $notificacion = "ON";
        $_SESSION['notifMsg'] = $notifMsg;
        $_SESSION['notificacion'] = $notificacion;
        header("Location:" . $_SERVER['HTTP_REFERER'] . " ");
        exit;
    }
    $validacion = getTemasById($idTema, $idCategoria);
    while ($val = mysqli_fetch_array($validacion)) {
        $resultado = $val[0];
    }
    if ($resultado == 0) {
        $notifMsg = "El tema introducido no existe";
        $notificacion = "ON";
        $_SESSION['notifMsg'] = $notifMsg;
        $_SESSION['notificacion'] = $notificacion;
        header("Location:" . $_SERVER['HTTP_REFERER'] . " ");
        exit;
    }
    modificarTema($idCategoria, $idTema, $nombreTema);
    $notifMsg = "El tema se ha modificado correctamente";
    $notificacion = "ON";
    $_SESSION['notifMsg'] = $notifMsg;
    $_SESSION['notificacion'] = $notificacion;
    header("Location:" . $_SERVER['HTTP_REFERER'] . " ");
}
exit;
예제 #2
0
//variable para saber en que metodo debe entrar en caso de llegar aqui a travez de un form
if (isset($_POST['accion'])) {
    //verifica si $accion llego en POST o GET dependiendo del form usado
    $accion = $_POST['accion'];
} else {
    if (isset($_GET['accion'])) {
        $accion = $_GET['accion'];
    }
}
//switch que recibe una accion para cada caso
switch ($accion) {
    case 1:
        guardarTema();
        break;
    case 2:
        modificarTema();
        break;
}
function guardarTema()
{
    $siglaCurso = $_POST['SiglaCursoTema'];
    $nombreTema = $_POST['NombreTema'];
    //crea el objeto tema
    $tem = new Tema();
    $tem->crearTema($siglaCurso, $nombreTema);
    //ejecuta la funcion en TemaData que inserta un tema
    insertarTema($tem);
}
function modificarTema()
{
    $idTema = $_POST['IdTema'];