<?php

include 'dbconnection.php';
// Perform queries
$Email = $_GET["Email"]; 
$ID = $_GET["id"]; 



$DB = mysqli_query($mysql,"SELECT dbname FROM tb_users WHERE email ='$Email'");
while($row = mysqli_fetch_array($DB)){
$dbname = $row ['dbname'];}


$hostname2 = "localhost";
$username2 = "tempdpe5_nicolas";
$password2= "(Made7575)";
$conn = mysqli_connect($hostname2,$username2,$password2,$dbname);
if (mysqli_connect_errno()){
  printf("Connect failed: %s\n", mysqli_connect_error());
  exit();
} 
mysqli_set_charset($conn ,"utf8");

// Perform queries

mysqli_query($conn,"UPDATE calendar SET start = STR_TO_DATE(fechadeinicio, '%Y-%m-%d %h:%i %p') , end = STR_TO_DATE(fechafinal, '%Y-%m-%d %h:%i %p') WHERE id ='$ID' AND Status IN ('Completada','Revisada')");

mysqli_query($conn,"UPDATE calendar SET start2 = DATE_FORMAT(start,'%Y-%m-%d') WHERE id ='$ID' AND Status IN ('Completada','Revisada')");
mysqli_query($conn,"UPDATE calendar SET end2 = DATE_FORMAT(end,'%Y-%m-%d') WHERE id ='$ID' AND Status IN ('Completada','Revisada')");




mysqli_close($conn);
mysqli_close($con);

echo "<script>window.location.href='programaciondeactividades';</script>";
?>