<?php
session_start();
if(!isset($_SESSION['login'])){
header("Location: index.php");
}
?>

<?php include 'recordsbanner.php';?>
<br>
<br>
<html>
<head>

<title>Clashers</title>
</head>

<body align="center">
<form method="post">
<table align="center">

	<tr>
		<td>Name:</td>
		<td><input type="text" name="name" /></td>
	</tr>
	<tr>
		<td>Village Name:</td>
		<td><input type="text" name="vname" /></td>
	</tr>
	<tr>
		<td>Clan Name:</td>
		<td><input type="text" name="cname" /></td>
	</tr>
	<tr>
		<td>Trophies:</td>
		<td><input type="text" name="trophies" /></td>
	</tr>
	
	<tr>
		<td>Townhall Level:</td>
		<td><input type="text" name="thlevel" /></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td><input type="submit" name="submit" value="Add" /></td>
	
	</tr>
</table>
<form action="search.php" method="get">	
		<td>
		<input type = "text" name = "search"/> 
		<input type = "submit" value = "Search" />
		</td>
	</form>
<?php

if (isset($_POST['submit']))
	{	   
	include 'db.php';
	
			 		$name=$_POST['name'] ;
					$vname= $_POST['vname'] ;					
					$cname=$_POST['cname'] ;
					$trophies=$_POST['trophies'] ;
					$thlevel=$_POST['thlevel'] ;
												
		 mysql_query("INSERT INTO `clasher`(Name,VillageName,ClanName,Trophies,THlevel) 
		 VALUES ('$name','$vname','$cname','$trophies','$thlevel')"); 
	        }
?>

<table border="1" align="center">
	
			<?php
			include("db.php");
			
				
			$result=mysql_query("SELECT * FROM clasher");
			echo"<tr align='center'>";
				echo"<th>Name</th>";
				echo"<th>Clan Name</th>";
				echo"<th>Village Name</th>";
				echo"<th>Trophies</th>";
				echo"<th>Townhall Level</th>";
				echo"</tr>";
			
			while($test = mysql_fetch_array($result))
			{
				$id = $test['ClasherID'];	
				
				
				
				echo "<tr align='center'>";	
				
				echo"<td><font color='black'>" .$test['Name']."</font></td>";
				echo"<td><font color='black'>". $test['VillageName']. "</font></td>";
				echo"<td><font color='black'>". $test['ClanName']. "</font></td>";
				echo"<td><font color='black'>". $test['Trophies']. "</font></td>";
				echo"<td><font color='black'>". $test['THlevel']. "</font></td>";	
				echo"<td> <a href ='view.php?ClasherID=$id'>Edit</a>";
				echo"<td> <a href ='del.php?ClasherID=$id'><center>Delete</center></a>";
									
				echo "</tr>";
			}
			mysql_close($conn);
			?>
</table>
</body>
</html>
