   <?php
/*================================================================+\
|| # PHPRetro - An extendable virtual hotel site and management
|+==================================================================
|| # Copyright (C) 2009 Yifan Lu. All rights reserved.
|| # http://www.yifanlu.com
|| # Parts Copyright (C) 2009 Meth0d. All rights reserved.
|| # http://www.meth0d.org
|| # All images, scripts, and layouts
|| # Copyright (C) 2009 Sulake Ltd. All rights reserved.
|+==================================================================
|| # PHPRetro is provided "as is" and comes without
|| # warrenty of any kind. PHPRetro is free software!
|| # License: GNU Public License 3.0
|| # http://opensource.org/licenses/gpl-license.php
\+================================================================*/

$page['allow_guests'] = true;
require_once('./includes/core.php');
require_once('./includes/session.php');

$page['id'] = "gang_create";
$page['name'] = 'Create Gang';
$page['bodyid'] = "home";
$page['cat'] = "bussiness";

require_once('./templates/community_header.php');
?>

<style type="text/css">
input[type="text"], input[type="password"] {
  background-color: #F1F1F1;
  border: 1px solid #999999;
  width: 175px;
  padding: 5px;
  font-family: verdana;
  font-size: 10px;
  color: #666666;
}
input[type="submit"] {
  background-color: #F1F1F1;
  border: 1px solid #999999;
  padding: 5px;
  font-family: verdana;
  font-size: 10px;
  color: #666666;
}
select {
  background-color: #F1F1F1;
  border: 1px solid #999999;
  padding: 5px;
  font-family: verdana;
  font-size: 10px;
  color: #666666;
}
</style>

<?php
if($user->name == "Guest"){
  header("Location: ".PATH);
}

if(isset($_POST['gangs_submit']))
{
  $gang_name = $input->FilterText($_POST['gang_name']);
  if($gang_name == NULL){
    $error_message = '<font color="red"><strong>You must imput the gang name!</strong></font><br /><br />';
             }else{
          $check_name_query = mysql_query("SELECT * FROM gangs WHERE gang_name = '".$gang_name."'");
          if(mysql_num_rows($check_name_query) > 0){
            $error_message = '<font color="red"><strong>The gang named '.$gang_name.' has already been created.</strong></font><br /><br />';
          }else{
            mysql_query("INSERT into gangs (id, gang_name, gang_members, owner) VALUES (NULL, '".$gang_name."', '".$gang_members."', '".$user->id."')");
            $get_gangs_id = mysql_query("SELECT id FROM gangs WHERE gang_name = '".$gang_name."'");
            $get_gangs = mysql_fetch_assoc($get_gangs_id);
            $error_message = '<font color="green"><strong>You have successfully created the '.$gang_name.'.</strong></font><br /><br />';
          }
        }
      }
?>


<div id="container">
    <div id="content" style="position: relative" class="clearfix">
    <div id="column1" class="column">

                <div class="habblet-container ">
                        <div class="cbb clearfix green ">

                            <h2 class="title">Create Your Own Gang!
                            </h2>
<p class="credits-countries-select">
<center>
<?php echo $error_message; ?>
<table width="180px">
<tr>
<td>
<form name="post" action="" method="post">
    My Gang Name:<br />
<input type="text" name="gang_name" value="<?php echo $gang_name; ?>" /><br />
<br />
<center><input type="submit" name="gangs_submit" value="Create My Gang!" /></center><br />
</form>
</td>
</tr>
</table>
</center>

</p>
                    </div>

                        <div class="cbb clearfix green ">

                            <h2 class="title">What is a gang?
                            </h2>
<p class="credits-countries-select">

Something Daft will go here. lolol.

</p>
                    </div>
                        
                </div>
</div>
<div id="column2" class="column">
                <div class="habblet-container ">
                        <div class="cbb clearfix green ">

                            <h2 class="title">My Gangs!
                            </h2>
                        <div id="purse-habblet">
                        <p class="credits-countries-select">
                        <img src="http://forum.ragezone.com/images/frank_15.gif" align="right">


<?php
$getinfo = mysql_query("SELECT * FROM users WHERE name = '".$user->name."'");
$info = mysql_fetch_array($getinfo);
$getevenmoreinfo = mysql_query("SELECT * FROM gangs WHERE owner = '".$info['id']."'");
$corpcount = mysql_num_rows($getevenmoreinfo);
if($corpcount > 0) {
      while($s = mysql_fetch_array($getevenmoreinfo)) {
            echo '<a href="#">'.$s['gang_name'].'</a><br />';
      }
}else{
      echo 'Sorry, but you do not have any corps.<br />
      You can create one <a href="gang_create">here!</a>';
}
?>

<br />
</p>


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


<?php require_once('./templates/community_footer.php'); ?> 