<?php

	include('public/functions.php');

  $qry = "insert * FROM tbl_equipe";
  $registro = mysqli_query($connect, $qry);

	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']
  		);

  		$registro = insert('tbl_equipe', $data);
  		
			$_SESSION['msg'] = "Equipe Cadastrada 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">Adicionar 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">

                      <div class="card-panel">
                          <form method="post" enctype="multipart/form-data">
                              <div class="row">
                                  <?php if(isset($_SESSION['msg']))
                                  echo $_SESSION['msg'];
                                  unset($_SESSION['msg']);?>

                                  <div class="col s12 m12 l12">
                                    <div class="input-field col s12 l3">
                                      <label>Nome</label>
                                      <br>
                                      <input type="text" name="nome">
                                    </div>
                                    <br>
                                    <div class="col s12 m12 l12">
                                    <div class="input-field col s12 l3">
                                      <label>Programa</label>
                                      <br>
                                      <input type="text" name="programa">
                                     </div>
                                    </div>

                                    <div class="col s12 m12 l12">
                                    <div class="input-field col s12 l3">
                                      <label>Facebook</label>
                                      <br>
                                      <input type="text" name="facebook">
                                    </div>
                                    <div class="col s12 m12 l12">
                                    <div class="input-field col s12 l3">
                                      <label>Instagram</label>
                                      <input type="text" name="instagram">
                                    </div>
                                    <br>
                                      </div>
                                    <div class="col s12 m12 l12">
                                    <div class="input-field col s12 l3">
                                      <label>Whatsapp</label>
                                      <input type="text" name="whatsapp">
                                    </div>
                                    <br>
                                    </div>
										
										
								<div class="col s12 m12 l8">
                                    <div class="input-field col s12 l6">
                                      <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">Adicionar</button>
                                  </div>

                            
                          </form>
                      </div>

                  </div>

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

</section>