<?php
  include "include/dbcon.php";
?>
<?php
  global $conn;

  $mytstamp = time();

  $pschname = $_POST["txtSchName"];
  $adminpass = $_POST["txtAdminPass"];
  $pejpass = $_POST["txtPajPass"];
  $stype = $_POST["stype"];
  $gbname = $_POST["gbname"];
  $gtname = $_POST["gtname"];
  $phimgpath0 = $_POST["himgpath"];
  $target_file = "comlogo".rand(100,999).".png";
?>
<?php
  if( $_FILES["myfile"]["name"]!=="" ){
    if (move_uploaded_file($_FILES["myfile"]["tmp_name"], "img/".$target_file)) {
		$pimgpath = $target_file;
    }else{
		$pimgpath = $phimgpath0;
	}
	
  }else{
	  $pimgpath = $phimgpath0;
  }
?>
<?php

  $query = "UPDATE xoops_pc_setting 
              SET stype='$stype', gbname='$gbname', gtname='$gtname'";
  mysqli_query($conn,$query);
  
  $query = "UPDATE xoops_adm_teacher
              SET `password`='$adminpass', tstamp='$mytstamp' WHERE id='admin'";
  mysqli_query($conn,$query);
  
  $query = "UPDATE xoops_adm_teacher
              SET `password`='$pejpass', tstamp='$mytstamp' WHERE id='pejabat'";
  mysqli_query($conn,$query);
  
  $query = "UPDATE xoops_sps_system
              SET `schName`='$pschname' , imgPath='$pimgpath'";
  mysqli_query($conn,$query);
?>
<?php
  header("location: main.php?pg=sys&ac=stt");
?>