<?php

	include('public/functions.php');

  $qry = "SELECT * FROM tbl_equipe WHERE id = '".$_GET['idevento']."' ";
  $result = mysqli_query($connect, $qry);
  $row_result = mysqli_fetch_assoc($result);

	if(isset($_POST['submit'])) {
	if($_FILES['img_equipe']['name'] != '') {
  			$img_equipe = time().'_'.$_FILES['img_equipe']['name'];
  			$pic2			 = $_FILES['img_equipe']['tmp_name'];
   			$tpath2			 = 'upload/img_equipe/'.$img_equipe;
  			copy ($pic2, $tpath2);
		
		$data = array(
          'img_equipe'  => $img_equipe,
          'nome'    => $_POST['nome'],
          'programa'    => $_POST['programa'],
          'facebook'    => $_POST['facebook'],
          'instagram'    => $_POST['instagram'],
          'whatsapp'    => $_POST['whatsapp']
  		);
		
  		}else{

  		$data = array(
          'nome'    => $_POST['nome'],
          'programa'    => $_POST['programa'],
          'facebook'    => $_POST['facebook'],
          'instagram'    => $_POST['instagram'],
          'whatsapp'    => $_POST['whatsapp']
  		);
	}
		
		$registro = Update('tbl_equipe', $data, " WHERE id = '".$_GET['idevento']."' ");
  		
			$_SESSION['msg'] = "Equipe Alterada com êxito!.";
      header( "Location:    equipe.php");
      exit;
      
 	}

?>

<!-- START CONTENT -->
<section id="content">

      <!--breadcrumbs start-->
      <div id="breadcrumbs-wrapper" class=" grey lighten-3">
          <div class="container">
            <div class="row">
                <div class="col s12 m12 l12">
                  <h5 class="breadcrumbs-title">Equipe</h5>
                  <ol class="breadcrumb">
                    <li><a href="dashboard.php">Inicio</a>
                    </li>
                    <li><a class="active">Editar Equipe</a>
                    </li>
                  </ol>
                </div>
            </div>
          </div>
      </div>
      <!--breadcrumbs end-->

      <!--start container-->
      <div class="container">
          <div class="section">
              <div class="row">

                  <div class="col s12 m12 l12">
                                    <form method="post" enctype="multipart/form-data">
                                    <div class="col s12 m12 l6">
                                        <div class="input-field col s12 l12">
                                          <label >Nome</label>
                                          <br>
                                          <input type="text" name="nome"  value="<?php echo $row_result['nome'] ;?>">
                                          
                                        </div>
                                    </div>
                                    
                                                                        <div class="col s12 m12 l6">
                                        <div class="input-field col s12 l12">
                                          <label >Programa</label>
                                          <br>
                                          <input type="text" name="programa"  value="<?php echo $row_result['programa'] ;?>">
                                          
                                        </div>
                                    </div>
                                    
                                    
                                    <div class="col s12 m12 l6">
                                        <div class="input-field col s12 l12">
                                          <label >Facebook</label>
                                          <br>
                                          <input type="text" name="facebook"  value="<?php echo $row_result['facebook'] ;?>">
                                          
                                        </div>
                                    </div>
                                
                                    <div class="col s12 m12 l6">
                                        <div class="input-field col s12 l12">
                                          <label >Instagram</label>
                                          <br>
                                          <input type="text" name="instagram"  value="<?php echo $row_result['instagram'] ;?>">
                                          
                                        </div>
                                    </div>
                                    
                                    <div class="col s12 m12 l6">
                                        <div class="input-field col s12 l12">
                                          <label >Whatsapp</label>
                                          <br>
                                          <input type="text" name="whatsapp"  value="<?php echo $row_result['whatsapp'] ;?>">
                                          
                                        </div>
                                    </div>
										
										<div class="col s12 m12 l6">
                                        <div class="input-field col s12 l12">
                                          <label >Imagem do Locutor</label>
                                          <br>
											<br>
                                          <input type="file" name="img_equipe" id="img_equipe" value="">
                                          
                                        </div>
                                    </div>
                                  
 <div class="input-field col s12"><br>
                                      <button type="submit" name="submit" class="btn cyan waves-effect waves-light">Editar</button>
                                  </div>

                              </div>
                          </form>
                      </div>

                  </div>

              </div>
          </div>
      </div>

</section>
