require("include/top.php");
unset($submitok);
// check the submitted data
if($name)
{
// check user account
if(!$_SESSION["SESSION"]||!$_SESSION["SCENEID"])
$errormessage[]="you need to be logged in first.";
// check the group name
$result=mysql_query("SELECT count(0) FROM parties WHERE name='".$name."'");
if(mysql_result($result,0))
$errormessage[]="a party with the same name is already in the database";
// check the party website
if($website)
{
$myurl=parse_url($website);
if($myurl["scheme"]!="http")
$errormessage[] = "only the http protocol is supported for the party website";
if(strlen($myurl["host"])==0)
$errormessage[] = "missing hostname in the download link";
}
// if everything is ok
if(!$errormessage)
$submitok=true;
}
// add the submitted party
if($submitok){
$query = "INSERT INTO parties SET ";
$query.= "name='".$name."', ";
$query.= "web='".$website."', ";
$query.= "added='".$_SESSION["SCENEID_ID"]."', ";
$query.= "quand=NOW()";
mysql_query($query);
$lastid=mysql_insert_id();
}
// build the form
$query="SELECT name FROM parties ORDER BY name";
$result=mysql_query($query);
while($tmp=mysql_fetch_array($result)) {
$parties[]=$tmp["name"];
}
?>