<?php
session_start();


include "../phpscripts/config.php";
include "../phpscripts/valida_login.php";
include "../phpscripts/funcoes.php";
include "../phpscripts/funcoes/slugfy.php";



    $nome       =$_POST['nome'];
    $slug       = slugfyURL($_POST['slug']); 
    $views        =$_POST['views']; 
    $status        =$_POST['status']; 
    $modo        =$_POST['mddo'];
    $categoria   =$_POST['categoria'];  
    $descricao  =$_POST['descricao'];



$slug = trim($_POST['slug']);
if(strlen($slug)==0) { $slug=slugfyURL($nome); }


mysql_query("INSERT INTO projetos SET  
nome='$nome', 
slug='$slug',
posicao='0',
views='0',
status='$status',
descri='$descricao',
data_cad=now()", $con) or die(mysql_error());



$sql_insert = mysql_query("SELECT id FROM projetos ORDER BY id DESC LIMIT 1");

$lin = mysql_fetch_assoc($sql_insert);

$lasid = $lin['id'];


foreach($categoria as $cat){

    mysql_query("INSERT INTO tiposrel SET  
    id_tipo='$cat', 
    id_proj='$lasid'", $con);

}


  
header("location:index.php");