elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


  Mostrar Mensajes
Páginas: 1 ... 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [20] 21 22 23 24 25 26 27 28 29
191  Sistemas Operativos / Windows / Eliminé el disco local C, no tengo sistema operativo, y no me deja instalarlo en: 10 Julio 2018, 12:11 pm
Hola, tengo un problemón, quise instalar Ubuntu en windows 10, desde USB, para que cuando inicie el PC me  salga  la opción de ir a Ubuntu o Windows, todo fue bien, instalé la ISO  de Ubuntu en un USB, y lo arranque desde ahí, con la BIOS,, hice la instalación de Linux, bien, pero al estar en las particiones, eliminé mi sistema operativo W10 pro, pero al menos tenia Ubuntu, pero quise recuperar, el W10 pro, para eso instalé la ISO en otro USB y lo arranqué, y en las particiones, no sé que hice y formateé el disco duro System (en el instalador de Windows) para instalar windows 10, por la cual me quedé sin ambos sistemas y solamente puedo entrrar en la BIOS (Surface Pro i5) y al arrancar el instalador de Windows 10 desde USB, me pide que instale en un disco duro, y me dice que no puede instalar el sistema, ya que los discos duros son de recuperación del sistema, y ya que no me deja no sé que hacer. ¿Como lo puedo solucionar?

Gracias
192  Programación / PHP / Como hacer que cuando al dar click en una fecha del calen. me inse. datos en DB en: 1 Julio 2018, 23:39 pm
Hola tengo un calendario php y me gustaría que al clicar en una fecha (es decir en una de sus celdas) me inserte un evento en la DB, por ahora lo estoy intentando hacer, y la llamada a la inserción de datos a la DB lo haré con AJAX.

Tengo estos ficheros:

HTML (parte):
Código:
<script>
  $(document).ready(function(){
    $(".dates li").click(function(){
      alert("<?php echo $j; ?>");
    });
  })
</script>
</head>
<body id="fondo">
<div style="position:absolute;opacity:1;width:auto;left:0%;right:0%;">
<div class="gridcontainer">
<div class="gridwrapper" style="height:10vw;" id="header1">
  <a href="http://g-t-e.260mb.net/profesorado/" style="text-decoration: none;">
    <img src="http://g-t-e.260mb.net/profesorado/imagenes/logo_GTE_profesorado.png" class="logo_inicio" id="logo_inicio1">
  </a>
</div>
</div>
  <nav class="menu">
    <ul class="submenus">
      <li class="dropdown">
        <a href="http://g-t-e.260mb.net/profesorado/GTE/1_eso" class="dropbtn">1 ESO</a>
        <div class="dropdown-content">
          <a href="http://g-t-e.260mb.net/profesorado/GTE/1_eso/1A">1&ordm; A</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/1_eso/1B">1&ordm; B</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/1_eso/1C">1&ordm; C</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/1_eso/1D">1&ordm; D</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/1_eso/1E">1&ordm; E</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/1_eso/1F">1&ordm; F</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/1_eso/1G">1&ordm; G</a>
        </div>
      </li>
      <li class="dropdown">
        <a href="http://g-t-e.260mb.net/profesorado/GTE/2_eso" class="dropbtn">2 ESO</a>
        <div class="dropdown-content">
          <a href="http://g-t-e.260mb.net/profesorado/GTE/2_eso/2A">2&ordm; A</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/2_eso/2B">2&ordm; B</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/2_eso/2C">2&ordm; C</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/2_eso/2D">2&ordm; D</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/2_eso/2E">2&ordm; E</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/2_eso/2F">2&ordm; F</a>
        </div>
      </li>
      <li class="dropdown">
        <a href="http://g-t-e.260mb.net/profesorado/GTE/3_eso" class="dropbtn">3 ESO</a>
        <div class="dropdown-content">
          <a href="http://g-t-e.260mb.net/profesorado/GTE/3_eso/3A">3&ordm; A</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/3_eso/3B">3&ordm; B</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/3_eso/3C">3&ordm; C</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/3_eso/3D">3&ordm; D</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/3_eso/3E">3&ordm; E</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/3_eso/3F">3&ordm; F</a>
        </div>
      </li>
      <li class="dropdown">
        <a href="http://g-t-e.260mb.net/profesorado/GTE/4_eso" class="dropbtn">4 ESO</a>
        <div class="dropdown-content">
          <a href="http://g-t-e.260mb.net/profesorado/GTE/4_eso/4A">4&ordm; A</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/4_eso/4B">4&ordm; B</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/4_eso/4C">4&ordm; C</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/4_eso/4D">4&ordm; D</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/4_eso/4E">4&ordm; E</a>
          <a href="http://g-t-e.260mb.net/profesorado/GTE/4_eso/4F">4&ordm; F</a>
        </div>
    </li>
    <li style="float:right;" class="icons">
      <a href="http://www.g-t-e.260mb.net/profesorado">
        <i class="fa fa-home"></i>
      </a>
    </li>
    <li style="float:right;" class="icons">
      <a href="https://sites.google.com/site/iescalvia/organitzacio/equip" target="_blank">
        <i class="fa fa-users"></i>
      </a>
    </li>
    </ul>
  </nav>
  <li class="fa fa-pencil-square" title="A&ntilde;adir eventos" id="eventos1"></li>
  <font id="title_1A">1 ESO A</font>
  <div id="calendar_div" style="position: relative; top:5vmax; left: 0vmax;">
     <?php echo getCalender(); ?>
  </div>
  <br>
  <table align="center" class="legenda_calendario">
      <tbody>
        <tr>
            <th colspan="2" class="subtitulo">Inicio de curso y vacaciones</th>
            <th class="titulo">otros</th>
        </tr>
        <tr>
            <td class="td">Inicio de curso:&nbsp;<canvas height="20" width="20" style="background-color:#F78181; border-radius:5px;"></canvas></td>
            <td class="td">Vacaciones de navidad:&nbsp;<canvas height="20" width="20" style="background-color:#81F781; border-radius:5px;"></canvas></td>
            <td class="td">Hoy:&nbsp;<canvas height="20" width="20" style="background-color:#DDDDDD; border-radius: 5px;"></canvas></td>
        </tr>
        <tr>
            <td class="td">Vacaciones de Pascua:&nbsp;<canvas height="20" width="20" style="background-color:#F2F5A9; border-radius:5px;"></canvas></td>
            <td class="td">Dias festivos:&nbsp;<canvas height="20" width="20" style="background-color:#E2A9F3; border-radius:5px;"></canvas></td>
            <td class="td">eventos:&nbsp;<canvas height="20" width="20" style="background-color:#B9FFFF; border-radius:5px;"></canvas></td>
        </tr>
    </tbody></table>
  <div class="gridwrapper" style="height:15vw; position:relative; bottom:-10vw;" id="footer1">
  <!-- footer -->
    <a href="https://web2.alexiaedu.com/ACWeb/LogOn.aspx?key=WRcKBnV4m3M%3d" target="_blank" style="text-decoration: none;">
      <img src="imagenes/Alexia1.png" class="alexia" title="Alexia">
    </a>
    <a href="http://moodle2.iescalvia.com/" target="_blank" style="text-decoration: none;">
      <img src="imagenes/moodle.png" class="moodle" title="Moodle">
    </a>
    <a href="https://www.bachilleratoartistico-iescalvia.com/" target="_blank" style="text-decoration: none; opacity: 1;">
      <img src="imagenes/batart.png" class="batart" title="Bachillerato art&iacute;stico">
    </a>
    <a href="http://iescalviablog.blogspot.com.es/" target="_blank" style="text-decoration: none;">
      <img src="imagenes/pillospress.png" class="pillospress" title="pillo's press">
    </a>
    <a href="http://www.cucalvia.com/" target="_blank" style="text-decoration: none;">
      <img src="imagenes/CUC.png" class="CUC" title="CUC">
    </a>
    <a href="http://weib.caib.es/" target="_blank" style="text-decoration: none;">
      <img src="imagenes/weib.png" class="weib" title="weib">
    </a>
    <br>
    <a href="http://iescalvia.blogspot.com.es/" target="_blank" style="text-decoration: none;">
      <img src="imagenes/bloggeries.png" class="bloggeries" title="Informaci&oacute;n del IES Calvi&aacute;">
    </a>
    <a href="http://www.erasmusplus.gob.es/" target="_blank" style="text-decoration: none;">
      <img src="imagenes/erasmus.png" class="erasmus" title="Erasmus">
    </a>
    <a href="https://www3.caib.es/xestib/xestib/menu/iniciGestio" target="_blank" style="text-decoration: none;">
      <img src="imagenes/GESTIB2.0.jpg" class="GESTIB2" title="GESTIB2.0">
    </a>
    <a href="mailto:iescalvia@gmail.com" style="text-decoration: none;">
      <i class="fa fa-envelope mail" title="iescalvia@gmail.com"></i>
    </a>
    <a href="tel:+34 971690229" style="text-decoration: none;">
      <i class="fa fa-tty telefono" title="+34 971690229"></i>
    </a>
    <a href="fax:+34 971694931" style="text-decoration: none;">
      <i class="fa fa-fax fax1" title="+34 971694931"></i>
    </a>
    <a href="https://sites.google.com/site/iescalvia/organitzacio/equip" target="_blank" style="text-decoration: none;" title="&iquest;Quienes somos?">
      <i class="fa fa-users equipo"></i>
    </a>
    <a href="guia.pdf" download="guia.pdf">
      <i class="fa fa-file-pdf-o descarga"></i>
    </a>
    <div class="red">
              <div class="social">
                  <div><a href="https://www.facebook.com/ies.calvia" target="_blank" class="fa fa-facebook-square facebook"></a></div>
                  <div><a href="https://www.youtube.com/user/iescalviablog" target="_blank" class="fa fa-youtube-play youtube"></a></div>
                  <div><a href="https://plus.google.com/114947718295379948989" target="_blank" class="fa fa-google-plus googleplus"></a></div>
                  <div><a href="mailto:iescalvia@gmail.com" class="fa fa-envelope correo" title="iescalvia@gmail.com"></a></div>
                  <div><a href="tel:+34971690229" class="fa fa-volume-control-phone telf" title="+34 971690229"></a></div>
                  <div><a href="fax:+34971694931" class="fa fa-fax mensaje" title="+34 971694931"></a></div>
              </div>
              <div class="volver12">
                <div class="volver_1">
                  <div>
                    <a href="http://www.g-t-e.260mb.net/profesorado/GTE/" class="volver_eso fa fa-square-o" title="Volver a los cursos">
                    </a>
                  </div>
                  <div>
                    <a href="http://www.g-t-e.260mb.net/profesorado/GTE/1_eso/" class="fa fa-arrow-left  volver" title="Volver">
                    </a>
                  </div>
                </div>
              </div>
    </div>
  </div>
<div id="contactos_div"></div>
</div>
</div>
<div class="fondo_popup">
  <div class="popup-edicion">
    <center class="fondo_centrado"><font class="texto_edicion">Editar vacaciones</font><i class="fa fa-close"></i></center>
    <div>
      <left class="coordinar_left">
        <select id="tipoEventos">
          <option selected disabled>-Editar...-</option>
          <option value="Vacaciones_de_Pascua">Vacaciones de Pascua</option>
          <option value="Vacaciones_de_Navidad">Vacaciones de Navidad</option>
          <option value="Dias_festivos">Dias festivos</option>
          <option value="inicio_de_curso">Inicio de curso</option>
        </select>
      </left>
      <center>
          <div class="caja">
            <?php
            include 'calendario.php';
             
            $calendar = new Calendar();
             
            echo $calendar->show();
            ?>             
          </div>
      </center>     
    </div>
  </div>
</div>
</body>

calendario.php:
Código:
<?php
/**
*@author  Xu Ding
*@email   thedilab@gmail.com
*@website http://www.StarTutorial.com
**/
class Calendar { 
     
    /**
     * Constructor
     */
    public function __construct(){     
        $this->naviHref = htmlentities($_SERVER['PHP_SELF']);
    }
     
    /********************* PROPERTY ********************/ 
    private $dayLabels = array("L","M","X","J","V","S","D");
     
    private $currentYear=0;
     
    private $currentMonth=0;
     
    private $currentDay=0;
     
    private $currentDate=null;
     
    private $daysInMonth=0;
     
    private $naviHref= null;
     
    /********************* PUBLIC **********************/ 
       
    /**
    * print out the calendar
    */
    public function show() {
        $year  == null;
         
        $month == null;
         
        if(null==$year&&isset($_GET['year'])){
 
            $year = $_GET['year'];
         
        }else if(null==$year){
 
            $year = date("Y",time()); 
         
        }         
         
        if(null==$month&&isset($_GET['month'])){
 
            $month = $_GET['month'];
         
        }else if(null==$month){
 
            $month = date("m",time());
         
        }                 
         
        $this->currentYear=$year;
         
        $this->currentMonth=$month;
         
        $this->daysInMonth=$this->_daysInMonth($month,$year); 
         
        $content='<div id="calendar">'.
                        '<div class="box">'.
                        $this->_createNavi().
                        '</div>'.
                        '<div class="box-content">'.
                                '<ul class="label">'.$this->_createLabels().'</ul>';   
                                $content.='<div class="clear"></div>';     
                                $content.='<ul class="dates">';   
                                 
                                $weeksInMonth = $this->_weeksInMonth($month,$year);
                                // Create weeks in a month
                                for( $i=0; $i<$weeksInMonth; $i++ ){
                                     
                                    //Create days in a week
                                    for($j=1;$j<=7;$j++){
                                        $content.=$this->_showDay($i*7+$j);
                                    }
                                }
                                 
                                $content.='</ul>';
                                 
                                $content.='<div class="clear"></div>';     
             
                        $content.='</div>';
                 
        $content.='</div>';
        return $content;   
    }
     
    /********************* PRIVATE **********************/
    /**
    * create the li element for ul
    */
    private function _showDay($cellNumber){
         
        if($this->currentDay==0){
             
            $firstDayOfTheWeek = date('N',strtotime($this->currentYear.'-'.$this->currentMonth.'-01'));
                     
            if(intval($cellNumber) == intval($firstDayOfTheWeek)){
                 
                $this->currentDay=1;
                 
            }
        }
         
        if( ($this->currentDay!=0)&&($this->currentDay<=$this->daysInMonth) ){
             
            $this->currentDate = date('Y-m-d',strtotime($this->currentYear.'-'.$this->currentMonth.'-'.($this->currentDay)));
             
            $cellContent = $this->currentDay;
             
            $this->currentDay++;   
             
        }else{
             
            $this->currentDate =null;
 
            $cellContent=null;
        }
             
         
        return '<li id="li-'.$this->currentDate.'" class="'.($cellNumber%7==1?' start ':($cellNumber%7==0?' end ':' ')).
                ($cellContent==null?'mask':'').'">'.$cellContent.'</li>';
    }
     
    /**
    * create navigation
    */
    private function _createNavi(){
    setlocale(LC_TIME, "spanish");
  $date_new = date('Y M',strtotime($this->currentYear.'-'.$this->currentMonth.'-1'));
  $day = strftime("%G del %B",strtotime($date_new));
        $fecha = $this->currentYear.'-'.$this->currentMonth.'-1';
        $nextMonth = $this->currentMonth==12?1:intval($this->currentMonth)+1;
         
        $nextYear = $this->currentMonth==12?intval($this->currentYear)+1:$this->currentYear;
         
        $preMonth = $this->currentMonth==1?12:intval($this->currentMonth)-1;
         
        $preYear = $this->currentMonth==1?intval($this->currentYear)-1:$this->currentYear;
         
        return
            '<div class="header">'.
                '<a class="prev" href="'.$this->naviHref.'?month='.sprintf('%02d',$preMonth).'&year='.$preYear.'"><i class="fa fa-angle-double-left"></i></a>'.
                    '<span class="title">'.$day.'</span>'.
                '<a class="next" href="'.$this->naviHref.'?month='.sprintf("%02d", $nextMonth).'&year='.$nextYear.'"><i class="fa fa-angle-double-right"></i></a>'.
            '</div>';
    }
         
    /**
    * create calendar week labels
    */
    private function _createLabels(){ 
                 
        $content='';
         
        foreach($this->dayLabels as $index=>$label){
             
            $content.='<li class="'.($label==6?'end title':'start title').' title">'.$label.'</li>';
 
        }
         
        return $content;
    }
     
     
     
    /**
    * calculate number of weeks in a particular month
    */
    private function _weeksInMonth($month=null,$year=null){
         
        if( null==($year) ) {
            $year =  date("Y",time());
        }
         
        if(null==($month)) {
            $month = date("m",time());
        }
         
        // find number of days in this month
        $daysInMonths = $this->_daysInMonth($month,$year);
         
        $numOfweeks = ($daysInMonths%7==0?0:1) + intval($daysInMonths/7);
         
        $monthEndingDay= date('N',strtotime($year.'-'.$month.'-'.$daysInMonths));
         
        $monthStartDay = date('N',strtotime($year.'-'.$month.'-01'));
         
        if($monthEndingDay<$monthStartDay){
             
            $numOfweeks++;
         
        }
         
        return $numOfweeks;
    }
 
    /**
    * calculate number of days in a particular month
    */
    private function _daysInMonth($month=null,$year=null){
         
        if(null==($year))
            $year =  date("Y",time());
 
        if(null==($month))
            $month = date("m",time());
             
        return date('t',strtotime($year.'-'.$month.'-01'));
    }   
}
?>

Por ahora se que el $j son los dias que hay en el calendario, pero no sé como hacer para que al clicar las celdas me haga una consulta.

¿No me oriento bien, alguien sabría como hacerlo?, y si se puede hacer en PHP?

Gracias.
193  Programación / Bases de Datos / No puedo modificar la tabla DB porque me detecta ', en: 18 Abril 2018, 22:21 pm
Hola tengo un formulario dónde tengo que especificar que tabla de la base de datos tengo que modificar. Pero cuando le doy en modificar, me sale un error
Código:
error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' materia=, asunto=ddddfdsffa, tarea=, evento=dddddfdWHERE fecha=2018-04-12, tipo' at line 1

Código:
<?php
$servername = "xxxxxxx";
$username = "xxxxxxxx";
$password = "xxxxxxx";
$dbname = "xxxxxxx";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Desconectado" . $conn->connect_error);
}
$fecha= $_POST['seleccionar_fecha'];
$tipoevento_se = $_POST['especificar_tipoEventos'];
$materia_se = $_POST['especificar_materiabox'];
$asunto_se = $_POST['especificar_asuntobox'];
mysql_real_escape_string($conn, $_POST['seleccionar_fecha']);
mysql_real_escape_string($conn, $_POST['especificar_asuntobox']);
mysql_real_escape_string($conn, $_POST['especificar_materiabox']);
mysql_real_escape_string($conn, $_POST['especificar_TipoEventos']);
$tipoevento = $_POST['modificar_tipoEventos'];
$otro = $_POST['modificar_otroTipoEventos'];
$materia = $_POST['modificar_materiabox'];
$asunto = $_POST['modificar_asuntobox'];
$tarea = $_POST['modificar_tareabox'];
$evento = $_POST['modificar_eventobox'];
mysql_real_escape_string($conn, $_POST['modificar_tipoEventos']);
mysql_real_escape_string($conn, $_POST['modificar_otroTipoEventos']);
mysql_real_escape_string($conn, $_POST['modificar_materiabox']);
mysql_real_escape_string($conn, $_POST['modificar_asuntobox']);
mysql_real_escape_string($conn, $_POST['modificar_tareabox']);
mysql_real_escape_string($conn, $_POST['modificar_eventobox']);
$sql = "UPDATE 1esoacalendar SET tipoevento=".$tipoevento.", otro=".$otro.", materia=".$materia.", asunto=".$asunto.", tarea=".$tarea.", evento=".$evento."WHERE fecha=".$fecha.", tipoevento=".$tipoevento_se.", materia=".$materia_se.", asunto=".$asunto_se."";

if ($conn->query($sql) === TRUE) {
    echo $sql;
} else {
    echo "error: ".$conn-> error;
}
$conn->close();
?>
No sé de donde sale esa comilla. Y creo que en teoría esta bien.
Código:
$sql = "UPDATE 1esoacalendar SET tipoevento=".$tipoevento.", otro=".$otro.", materia=".$materia.", asunto=".$asunto.", tarea=".$tarea.", evento=".$evento."WHERE fecha=".$fecha.", tipoevento=".$tipoevento_se.", materia=".$materia_se.", asunto=".$asunto_se."";

Gracias por vuestra atención
194  Programación / PHP / Re: Envio de datos a la base de datos con AJAX en: 9 Marzo 2018, 20:33 pm
Código
  1. ...
  2. $.when($.ajax("verificar_captcha.php"),$.ajax("anadirevento.php"))
  3. .then(validar12(),send());
  4. ...

Creo que el error se debe a validar12(), debe pasarse como una referencia a una funcion(validar12) en .then y como es una funcion sin argumentos siempre se cumplira la condicion.

Código
  1. ...
  2. .then(validar12);  //Nota que es sin los parentesis.
  3. ...

Creo que no es valido usar send() despues de validar12, segun la documentacion la sagunda funcion se reserba en caso de que alguno de las peticiones ajax no pudieron realizarse.

Ademas, deberias plantear si de verdad necesitas un captcha, por que estas tratando de validar el captcha pero a la vez subes la consulta, osea que el captcha no sirve para nada. Fijate en la consola, F12 > Network, veras como se disparan las dos consultas ajax cuando apretas el boton. Deberias ser.. verificar campos vacios > verificar captcha > añadir evento.

Hola. Ya lo conseguí, era más fácil de lo que creía, al final no lo hice con when(), así que lo hice con condiciones if else, este es el código:
Código:
	$(document).ready(function() {
$("#enviar").click(function(){
var datos=$('#demo').serialize();
var fecha2 = $("#data");
var tipo2 = $("#tipoEventos");
var otro2 = $("#otroTipoEventos");
var materia2 = $("#materia");
var tarea2 = $("#tarea");
$.ajax({
        type:"POST",
        url:"verificar_captcha.php",
        data:datos,
        success:function(resp){
          if (resp!=1){
            $(".popup_errorcaptchaevento").delay(500).slideDown("slow");
            $(".popup_errorcaptchaevento").delay(1000).slideUp("slow");
          }else{
            $(".popup_correctoevento").delay(500).slideDown("slow");
            $(".popup_correctoevento").delay(1000).slideUp("slow");
          $.ajax({
          type:"POST",
          url:"anadirevento.php",
          data:datos,
          success:function(r){
          if (r!=1){
              $(".popup_errorevento").delay(500).slideDown("slow");
              $(".popup_errorevento").delay(1000).slideUp("slow");
          }
          }
          })
          }
        }
})
return false;
});
});
No puse el popup de aviso de campos vacíos, ya que no me lo ejecutaba, y además no era de gran importancia, era más un detalle.

Gracais por vuestra atención.
195  Programación / PHP / Re: Envio de datos a la base de datos con AJAX en: 5 Marzo 2018, 19:09 pm
Obviamente no tienes ni idea de lo que estas haciendo, no entiendes tampoco los conceptos, ni javascript ni jquery ni php, todo tiene una funcion logica aqui. Copiando, pegando codigo y luego refrescando la pagina no va a funcionar si no sabes lo que haces, tomate tu tiempo para aprender.
Hola, es verdad, no entendía lo que hacia así que me tomé mi tiempo, es que las prisas...

Y ahora lo entiendo. Este código:

Código:
<script type="text/javascript">
$(document).ready(function() {
$("#enviar").click(function(){
var datos=$('#demo').serialize();
$.ajax({
type:"POST",
url:"anadirevento.php",
data:datos,
success:function(r){
if (r==1){
$(".popup_correctoevento").delay(500).slideDown("slow");
$(".popup_correctoevento").delay(1000).slideUp("slow");
}else{
$(".popup_errorevento").delay(500).slideDown("slow");
$(".popup_errorevento").delay(1000).slideUp("slow");
}
}
});
return false;
});
});
</script>
anadirevento.php
Código:
<?php
$servername = "";
$username = "";
$password = "";
$dbname = "";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Error: " . $conn->connect_error);
}
$fecha = $_POST['databox'];
$tipoEvento = $_POST['tipoEventos'];
$otro = $_POST['otroTipoEventos'];
$materia = $_POST['materiabox'];
$asunto = $_POST['asuntobox'];
$tarea = $_POST['tareabox'];
$evento = $_POST['eventobox'];
mysqli_escape_string($_POST['databox']);
mysqli_escape_string($_POST['tipoEventos']);
mysqli_escape_string($_POST['otroTipoEventos']);
mysqli_escape_string($_POST['materiabox']);
mysqli_escape_string($_POST['asuntobox']);
mysqli_escape_string($_POST['tareabox']);
mysqli_escape_string($_POST['eventobox']);

$sql = " INSERT INTO 1esoacalendar (fecha, tipoevento, otro, materia, asunto, tarea, evento) VALUES ('$fecha','$tipoEvento','$otro','$materia','$asunto','$tarea','$evento')";
echo mysqli_query($conn,$sql);
$conn->close();
?>

Eso ya lo conseguí, pero realmente no quería hacer eso, sino hacer una función que cuando clique en el boton #enviar me haga una condición if que sí algún campo de texto está vacío me muestre el pop-up que informe de algún campo vacío y sino que me ejecute dos funciones AJAX, me informe y creo que se hace con la función when(), por la cual cosa hice esto:
Código:
	$(document).ready(function() {
var data1 = $("#data");
var tipoEventos1 = $("#tipoEventos");
var materia1 = $("#materia");
var tarea1 = $("#tarea");
var captcha1 = $("#captcha");
function validar12(resp){
          if (resp!=1){
            $(".popup_errorcaptchaevento").delay(500).slideDown("slow");
            $(".popup_errorcaptchaevento").delay(1000).slideUp("slow");
          }
        }
        function send(r){
          if(r==1){
            $(".popup_correctoevento").delay(500).slideDown("slow");
            $(".popup_correctoevento").delay(1000).slideUp("slow");          
          }else{
            $(".popup_errorevento").delay(500).slideDown("slow");
            $(".popup_errorevento").delay(1000).slideUp("slow");            
          }
}
$("#enviar").click(function(){
if(data1.val() === "" || tipoEventos1.val() === "" || materia1.val() === "" || tarea1.val() === "" || captcha1.val() === ""){
$(".popup_validar").delay(500).slideDown('slow');
$(".popup_validar").delay(1000).slideUp('slow');
}else{
$.when($.ajax("verificar_captcha.php"),$.ajax("anadirevento.php"))
.then(validar12(),send());
}
 return false;    
});
});
Código:
       <?php
          session_start( ); // allows us to retrieve our key form the session
          /*
          First encrypt the key passed by the form, then compare it to the already encrypted key we have stored inside our session variable
          */
          echo md5($_POST["code"]) == $_SESSION["key"];
        ?>
Cuando dejo un input vacío me lanza el popup de advertencia bien, y cuando relleno todo, y doy click en enviar, me lannza el popup de error de captcha, siempre, auque el captcha lo tenga bien y además no me guarda los datos en la base de datos.

Nosé donde esta el problema, ¿Es lógico lo que he planteado?.

PD: Además leí el api de jquery de la función when() y, si no recuerdo mal, creo que decía que solamente en la parte de .then(),se ejecuta la primera función, y si es así nosé como hacer para que me ejecute ambas.

Gracias de antermano.
196  Programación / PHP / Re: Envio de datos a la base de datos con AJAX en: 1 Marzo 2018, 23:40 pm
Hola,
no existe afterSend con la librería jQuery.

Sin embargo, puedes utilizar... complete o done, dependiendo de para que lo necesites.

Un pequeño ejemplo con done...

Código
  1. $(document).ready(function(){
  2. $('#send').click(function(e){
  3. $.ajax({
  4. type: 'POST',
  5. url: 'ejemplo.php',
  6. data: { user: $('#user').val(), pass: $('#pass').val() }
  7. }).done(function(response){
  8. if( response == "ok" )
  9. window.location="ejemplo2.php";
  10. });
  11. });
  12. });
  13.  

y la documentación de la libreria.

Nota: Prueba sustituyendo el $(document).ready... del verificar_catpcha.php por este script

Código
  1. $(function(){
  2. $(".popup_errorcaptchaevento").delay(500).slideDown("slow");
  3. $(".popup_errorcaptchaevento").delay(1000).slideUp("slow");
  4. });
  5.  

Saludos.

Hola Rave1996 he probado con este código:
Código:
  $(document).ready(function(){
    $("#enviar").click(function(){
      var datos = $("#demo").serialize();
      $.ajax({
        url: 'verificar_captcha.php',
        type: 'POST',
        data:datos,
      })
      .done(function(res) {
        if (res != "ok") {
          $(".popup_errorcaptchaevento").delay(500).slideDown("slow");
          $(".popup_errorcaptchaevento").delay(1000).slideUp("slow");
        }else{
          alert("hola");
        }
      })
      return false;
    });
  });

Y no me ejecuta bien la declaración if else, solamente me lo ejecuta el if pero no el else tanto si el
Código:
res
no es igual al
Código:
ok
como si lo es.

Porque no me ejecuta el else?

verificar_captcha.php:
Código:
       <?php

session_start( ); // allows us to retrieve our key form the session

/*

First encrypt the key passed by the form, then compare it to the already encrypted key we have stored inside our session variable

*/

if( md5( $_POST[ 'code' ] ) != $_SESSION[ 'key' ] ) {
?>
<script>
  $(function(){
    $(".popup_errorcaptchaevento").delay(500).slideDown("slow");
    $(".popup_errorcaptchaevento").delay(1000).slideUp("slow");
  });
</script>
<?
}
?>

Gracias de antemano.
197  Programación / PHP / Envio de datos a la base de datos con AJAX en: 25 Febrero 2018, 22:19 pm
Hola. quiero enviar mis datos del formulario a mi DDBB sin recargar la página, para eso necesito AJAX, me busque un tutorial por YouTube y lo hice pero pasa una cosa, y es que me lo ejecuta bien pero no me ejecuta el afterSend. (La funcion de afterSend es que me muestre un popup diciendome que esta guardado en la DDBB.)

Código:
  $(document).ready(function(){
    $("#enviar").click(function(){
      var datos = $("#demo").serialize();
      $.ajax({
        type:"POST",
        url:"verificar_captcha.php",
        data:datos,
        afterSend:function(){
          $(".popup_correctoevento").delay(500).slideDown("slow");
          $(".popup_correctoevento").delay(1000).slideUp("slow");
        }
      })
    });
  });

verificar_captcha.php
Código:
<?php
  session_start( ); // allows us to retrieve our key form the session
  /*
  First encrypt the key passed by the form, then compare it to the already encrypted key stored inside our session variable
          */
  if( md5( $_POST[ 'code' ] ) != $_SESSION[ 'key' ] ) {
  ?>
  <script>
    $(document).ready(function(){
        $(".popup_errorcaptchaevento").delay(500).slideDown("slow");
        $(".popup_errorcaptchaevento").delay(1000).slideUp("slow");
    });
  </script>
  <?php
  } else {
    include('anadirevento.php');
  }
?>

anadirevento.php
Código:
<?php
$servername = "private";
$username = "private";
$password = "private";
$dbname = "private";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Error: " . $conn->connect_error);
}
$fecha = $_POST['databox'];
$tipoEvento = $_POST['tipoEventos'];
$otro = $_POST['otroTipoEventos'];
$materia = $_POST['materiabox'];
$asunto = $_POST['asuntobox'];
$tarea = $_POST['tareabox'];
$evento = $_POST['eventobox'];
mysqli_escape_string($_POST['databox']);
mysqli_escape_string($_POST['tipoEventos']);
mysqli_escape_string($_POST['otroTipoEventos']);
mysqli_escape_string($_POST['materiabox']);
mysqli_escape_string($_POST['asuntobox']);
mysqli_escape_string($_POST['tareabox']);
mysqli_escape_string($_POST['eventobox']);

$sql = " INSERT INTO 1esoacalendar (fecha, tipoevento, otro, materia, asunto, tarea, evento) VALUES ('$fecha','$tipoEvento','$otro','$materia','$asunto','$tarea','$evento')";

if ($conn->query($sql) === TRUE) {
?>
<script>
  $(document).ready(function(){
    $(".popup_correctoevento").delay(500).slideDown("slow");
    $(".popup_correctoevento").delay(1000).slideUp("slow");
  });
</script>
<?
}else{
?>
<script>
  $(document).ready(function(){
    $(".popup_errorevento").delay(500).slideDown("slow");
    $(".popup_errorevento").delay(1000).slideUp("slow");
  });
</script>
<?
}
$conn->close();
?>

Porque no me ejecuta el afterSend?

PD:
Ah!!  Y antes puse success y no afterSend sin ninguna funcion, y me ejecutaba el anadirevento.php pero sin los scripts.¿Porque?

Gracias de antemano.
198  Programación / PHP / actualizar mi calendario php mysql cuando detecte un nuevo dato en DB en: 24 Febrero 2018, 00:26 am
Hola como puedo hacer que mi calendario php mysql se actualice automaticamente cuando detecte que hay un nuevo dato en la base de datos?
Código:
<?php
/*
 * Function requested by Ajax
 */
if(isset($_POST['func']) && !empty($_POST['func'])){
  switch($_POST['func']){
    case 'getCalender':
      getCalender($_POST['year'],$_POST['month']);
      break;
    case 'getEvents':
      getEvents($_POST['date']);
      break;
    default:
      break;
  }
}

/*
 * Get calendar full HTML
 */
function getCalender($year = '',$month = '')
{
  $dateYear = ($year != '')?$year:date("Y");
  $dateMonth = ($month != '')?$month:date("m");
  $date = $dateYear.'-'.$dateMonth.'-01';
  $currentMonthFirstDay = date("N",strtotime($date));
  $totalDaysOfMonth = cal_days_in_month(CAL_GREGORIAN,$dateMonth,$dateYear);
  $totalDaysOfMonthDisplay = ($currentMonthFirstDay == 7)?($totalDaysOfMonth):($totalDaysOfMonth + $currentMonthFirstDay);
  $boxDisplay = ($totalDaysOfMonthDisplay <= 35)?35:42;
?>
  <div id="calender_section">
    <h2>
      <div id="seleccion_mes">
         <a href="javascript:void(0);" onclick="getCalendar('calendar_div','<?php echo date("Y",strtotime($date.' - 1 Month')); ?>','<?php echo date("m",strtotime($date.' - 1 Month')); ?>');" id="flecha_izquierda">&lt;&lt;</a>
            <select name="month_dropdown" class="month_dropdown dropdown" face="segoe script"><?php echo getAllMonths($dateMonth); ?></select>
           <select name="year_dropdown" class="year_dropdown dropdown" face="segoe script"><?php echo getYearList($dateYear); ?></select>
            <a href="javascript:void(0);" onclick="getCalendar('calendar_div','<?php echo date("Y",strtotime($date.' + 1 Month')); ?>','<?php echo date("m",strtotime($date.' + 1 Month')); ?>');" id="flecha_derecha">&gt;&gt;</a>
      </div>
    </h2>
    <div id="event_list" class="none"></div>
    <div id="calender_section_top">
      <ul id="dias_semana" class="dias_semana1">
        <li id="dia1">Dom.</li>
        <li id="dia2">Lun.</li>
        <li id="dia3">Mar.</li>
        <li id="dia4">Mi&eacute;.</li>
        <li id="dia5">Jue.</li>
        <li id="dia6">Vie.</li>
        <li id="dia7">S&aacute;b.</li>
      </ul>
    </div>
    <div id="calender_section_bot">
      <ul>
      <?php
        $dayCount = 1;
        for($cb=1;$cb<=$boxDisplay;$cb++){
          if(($cb >= $currentMonthFirstDay+1 || $currentMonthFirstDay == 7) && $cb <= ($totalDaysOfMonthDisplay)){
            //Current date
            $currentDate = $dateYear.'-'.$dateMonth.'-'.$dayCount;
            $eventNum = 0;
            //Include db configuration file
            include 'dbConfig.php';
            //Get number of events based on the current date
            $result = $db->query("SELECT * FROM 1esoacalendar WHERE fecha = '".$currentDate."'");
            $result1 = $db->query("SELECT * FROM inicio_de_curso WHERE data = '".$currentDate."'");
            $result2 = $db->query("SELECT * FROM vacaciones_de_navidad WHERE data = '".$currentDate."'");
            $result3 = $db->query("SELECT * FROM vacaciones_de_pascua WHERE data = '".$currentDate."'");
            $result4 = $db->query("SELECT * FROM dias_festivos WHERE data = '".$currentDate."'");
            $eventNum = $result->num_rows;
            $eventNum1  = $result1->num_rows;
            $eventNum2 = $result2->num_rows;
            $eventNum3 = $result3->num_rows;
            $eventNum4 = $result4->num_rows;
            //Define date cell color
            if(strtotime($currentDate) == strtotime(date("Y-m-d"))){
              echo '<li date="'.$currentDate.'" class="grey date_cell">';
            }elseif($eventNum > 0){
              echo '<li date="'.$currentDate.'" class="light_sky date_cell">';
            }elseif($eventNum1 > 0){
              echo '<li date="'.$currentDate.'" style="background-color: #F78181 !important;">';
            }elseif($eventNum2 > 0){
              echo '<li date="'.$currentDate.'" style="background-color: #81F781 !important;">';
            }elseif($eventNum3 > 0){
              echo '<li date="'.$currentDate.'" style="background-color: #F2F5A9 !important;">';
            }elseif($eventNum4 > 0){
              echo '<li date="'.$currentDate.'" style="background-color: #E2A9F3 !important;">';
            }else{
              echo '<li date="'.$currentDate.'" class="date_cell">';
            }
            //Date cell
            echo '<span>';
            echo $dayCount;
            echo '</span>';
           
            //Hover event popup
            echo '<div id="date_popup_'.$currentDate.'" class="date_popup_wrap none">';
            echo '<div class="date_window">';
            echo '<div class="popup_event">Eventos ('.$eventNum.')</div>';
            echo ($eventNum > 0)?'<a href="javascript:;" onclick="getEvents(\''.$currentDate.'\');" style="color:#0040FF; font-size:1em; padding:10px 0px 0px 0px;" class="evento_texto">ver eventos</a>':'';
            echo '</div></div>';
           
            echo '</li>';
            $dayCount++;
      ?>
      <?php }else{ ?>
        <li><span>&nbsp;</span></li>
      <?php } } ?>
      </ul>
    </div>
  </div>
  <script type="text/javascript">
    function getCalendar(target_div,year,month){
      $.ajax({
        type:'POST',
        url:'functions.php',
        data:'func=getCalender&year='+year+'&month='+month,
        success:function(html){
          $('#'+target_div).html(html);
        }
      });
    }
   
    function getEvents(date){
      $.ajax({
        type:'POST',
        url:'functions.php',
        data:'func=getEvents&date='+date,
        success:function(html){
          $('#event_list').html(html);
          $('#event_list').slideDown('slow');
        }
      });
    }
   
    function addEvent(date){
      $.ajax({
        type:'POST',
        url:'functions.php',
        data:'func=addEvent&date='+date,
        success:function(html){
          $('#event_list').html(html);
          $('#event_list').slideDown('slow');
        }
      });
    }
   
    $(document).ready(function(){
      $('.date_cell').mouseenter(function(){
        date = $(this).attr('date');
        $(".date_popup_wrap").fadeOut();
        $("#date_popup_"+date).fadeIn(); 
      });
      $('.date_cell').mouseleave(function(){
        $(".date_popup_wrap").fadeOut();   
      });
      $('.month_dropdown').on('change',function(){
        getCalendar('calendar_div',$('.year_dropdown').val(),$('.month_dropdown').val());
      });
      $('.year_dropdown').on('change',function(){
        getCalendar('calendar_div',$('.year_dropdown').val(),$('.month_dropdown').val());
      });
      $(document).click(function(){
        $('#event_list').slideUp('slow');
      });
    });
  </script>
<?php
}

/*
 * Get months options list.
 */
function getAllMonths($selected = ''){
  $options = '';
  for($i=1;$i<=12;$i++)
  {
    $value = ($i < 10)?'0'.$i:$i;
    $selectedOpt = ($value == $selected)?'selected':'';
    $options .= '<option value="'.$value.'" '.$selectedOpt.' >'.date("F", mktime(0, 0, 0, $i+1, 0, 0)).'</option>';
  }
  return $options;
}

/*
 * Get years options list.
 */
function getYearList($selected = ''){
  $options = '';
  for( $i=2017; $i <= 2050; $i++)
  {
    $selectedOpt = ($i == $selected)?'selected':'';
    $options .= '<option value="'.$i.'" '.$selectedOpt.' >'.$i.'</option>';
  }
  return $options;
}

/*
 * Get events by date
 */
function getEvents($date = ''){
  //Include db configuration file
  include 'dbConfig.php';
  $eventListHTML = '';
  $date = $date?$date:date("Y-m-d");
  //Get events based on the current date
  $result = $db->query("SELECT * FROM 1esoacalendar WHERE fecha = '".$date."'");
  if($result->num_rows > 0){
    $eventListHTML = '<h2 id="seleccion_mes1"><p class="texto_dato">Events on '.date("l, d M Y",strtotime($date)).'</p></h2>';
    $eventListHTML .= '<ul>';
    while($row = $result->fetch_assoc()){
            $eventListHTML .= '<center><font size="5" class="texto_dato"><b>Evento</b></font></center>';
            $eventListHTML .= '<left class="texto_dato"><b>Tipo de evento:</b> '.$row['tipoevento'].'</left>';
            $eventListHTML .= '<br>';
            $eventListHTML .= '<left class="texto_dato"><b>otro:</b> '.$row['otro'].'</left>';
            $eventListHTML .= '<br>';
            $eventListHTML .= '<left class="texto_dato"><b>materia:</b> '.$row['materia'].'</left>';
            $eventListHTML .= '<br>';
            $eventListHTML .= '<left class="texto_dato"><b>asunto:</b> '.$row['asunto'].'</left>';
            $eventListHTML .= '<br>';
            $eventListHTML .= '<left class="texto_dato"><b>tarea:</b> '.$row['tarea'].'</left>';
            $eventListHTML .= '<br>';
            $eventListHTML .= '<left class="texto_dato"><b>evento:</b> '.$row['evento'].'</left>';
            $eventListHTML .= '<br>';
        }
    $eventListHTML .= '</ul>';
  }
  echo $eventListHTML;
}
?>
Gracias.
199  Programación / Desarrollo Web / ¿Porque en el background-size:cover, se ve la imagen grande? en: 23 Febrero 2018, 16:18 pm
Hola, estoy revisando el fondo web ya que lo hice mal, y le puse este código:
Código:
body{
    background-image: url('imagenes/stackofmagazines.jpg');
    background-size:cover;
    -webkit-background-size:cover;
    -o-background-size:cover;
    -moz-background-size:cover;
    background-repeat: no-repeat;
    background-position: top center;
    -moz-background-position:left right;
    background-attachment: fixed;
  }

Este fondo es para móviles , ya que esta con un media query, pero cuando lo ejecuto la imagen de fondo, es muy grande y esta muy aumentado, yo lo que hacia era ponerles porcentajes en en el background-size, pero me dijeron que era experimental y me recomendaron cover.

Lo que no sé, es porque pasa esto y si depende de la imagen o si está mal programado.

Así es como se ve:
[img src="https://drive.google.com/open?id=1APKGD324JRyr0ClefHTGE7luEuzYuzQZ"]http://[/img]
https://drive.google.com/open?id=1APKGD324JRyr0ClefHTGE7luEuzYuzQZ

y el fondo de la imagen original es este:
[img src="https://drive.google.com/open?id=1RhXEdIjR-KJlDKgtCHbJ6pR5xO4uh0s5"][/img]
200  Programación / Desarrollo Web / Re: ¿Porque en chrome, y otros, el background se ve bien y en Firefox no? en: 16 Febrero 2018, 21:55 pm
procura no usar los elementos -nav-propiedad ya que tiende a implicar que los que haces es experimental, te recomiendo en este caso que uses en background size "contain" o "cover" según tus necesidades


https://www.w3schools.com/cssref/css3_pr_background-size.asp

Hola, he probado lo que me ha dicho y no me fue bien, es decir, en los otros navegadores si me va bien, pero en Firefox en móvil no, se ve pequeño, como antes.

¿Cómo lo puedo hacer?

Gracias de antemano.
Páginas: 1 ... 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [20] 21 22 23 24 25 26 27 28 29
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines