<?php
require 'sessao.php'; 
$erros = "";
$domain = $_POST['domain'];
if (strlen($domain) == 0){
	$erros .= "Insira o Domínio;<br>";
}
if ($erros <> ""){
	$_SESSION['erros'] = $erros;
	header("Location: add-dominio.php?error");
}
// Montagem do hostname
$query_d = mysql_query("SELECT * FROM `domains` WHERE `dominio`='$domain'");
if(mysql_num_rows($query_d) >= 1){
	header("Location: add-dominio.php?error");
}else{
	$query = mysql_query("INSERT INTO `domains` (`dominio`, `id_user`) VALUES ('$domain', '$id_user')");
	header("Location: add-dominio.php?sucesso");
}

?>