<?php
session_start();

include 'conexao.php';

if($_POST){
    $nome = $_POST["nome"];
    $login = $_POST["email"];
    $senha = md5($_POST["senha"]);
    $linkedin = $_POST["linkedin"];
    $burgues = $_POST["burgues"];



if ($burgues == '1') {

$sql = "SELECT * FROM FREELANCER   WHERE LOGIN LIKE '$login'";
    $resultado = mysqli_query($conexao, $sql);

    if(mysqli_num_rows($resultado) > 0){
            echo "<script>alert('Login já existe. Tente outro!')</script>";
    }
    else{
        $sql = "INSERT INTO FREELANCER VALUES(NULL, '$nome', '$login', '$senha')";

        if(mysqli_query($conexao, $sql))    echo "<script>alert('Cadastro realizado com sucesso!')</script>";
        else die("Falha no Cadastro!");
    }

}else{

    $sql = "SELECT * FROM EMPRESARIO   WHERE LOGIN LIKE '$login'";
    $resultado = mysqli_query($conexao, $sql);

    if(mysqli_num_rows($resultado) > 0){
            echo "<script>alert('Login já existe. Tente outro!')</script>";
    }
    else{
        $sql = "INSERT INTO EMPRESARIO VALUES(NULL, '$nome', '$login', '$senha')";

        if(mysqli_query($conexao, $sql))    echo "<script>alert('Cadastro realizado com sucesso!')</script>"; 
        else die("Falha no Cadastro!");
    }
}

}

 
mysqli_close($conexao); // encerrar conexão

?>

<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>
        Inscreva-se no Helpy Frella</title>

    <!-- Font Icon -->
    <link rel="stylesheet" href="fonts/material-icon/css/material-design-iconic-font.min.css">

    <!-- Main css -->
    <link rel="stylesheet" href="css/style.css">
</head>
<body>

    <div class="main">

        <div class="container">
            <form action="formulario.php" method="POST" class="appointment-form" id="appointment-form">
                <h2>Crie sua conta</h2>
                <div class="form-group-1">
                    <input type="text" name="nome" id="nome" placeholder="Nome completo" required />
                    <input type="text" name="linkedin" id="linkedin" placeholder="Link Linkedin" required />
                    <input type="text" name="email" id="email" placeholder="Email" required />
                    <input type="password" name="senha" id="senha" placeholder="Senha" required />
                    <div class="select-list">
                        <select name="burgues" id="burgues">
                            <option value="1">Freelancer</option>
                            <option value="2">Empresario</option>
                        </select>
                    </div>
              
                </div>
    
                <div class="form-submit">
                    <input onclick="window.location.href = 'escolha.php';" name="submit" id="submit" class="submit" type="submit" value="Concluir" />
                </div>
            </form>
        </div>

    </div>
</body>
</html>
    <!-- JS -->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="js/main.js"></script>
