<? if (!isset($_COOKIE['username']) && !isset($_COOKIE['password'])) {
		header( 'Location: index.php' ) ;
		}
	?>
<html>
<head>
<iframe src="http://www.facebook.com/plugins/like.php?href=YOUR_URL"
        scrolling="no" frameborder="0"
        style="border:none; width:450px; height:80px"><iframe>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Administratorius</title>

<?php
	require("db/configas.php");
	global $dbhost, $dbuname, $dbpass, $dbname; 
	mysql_connect($dbhost, $dbuname, $dbpass); 

	mysql_query("SET NAMES utf8");
	@mysql_select_db($dbname) or die ("Unable to select database !"); 
?>

<script language="JavaScript" type="text/javascript" src="wy/scripts/wysiwyg.js"></script>
<script language="JavaScript" type="text/javascript" src="wy/scripts/wysiwyg-settings.js"></script>	

<script language="javascript1.2">
   // attach the editor to all textareas of your page.
   WYSIWYG.attach('all');

</script>
</head>
<body>
<?php
	$ats = "Užpildykite formą ir nurodykite kokia kalba bus naujiena";
	if (isset($_POST['ikelti'])) {
		$selected = $_POST['kalba'];
		$tema = $_POST['tema'];
		$txt = $_POST['tekstas'];
		
		if ($tema!=NULL and $txt!=NULL && $txt!="<br>") {
		
		$uzklausa = "INSERT INTO news (kalba, tema, txt) VALUES ('$selected','$tema', '$txt')";
		$rezultatas = mysql_query($uzklausa) or die(mysql_error());
		$ats = "Naujiena įkelta";
		echo "<meta http-equiv='refresh' content='5' />";
		}else{
		$ats = "Nepilnai užpildyta forma";
		}
		
	}
?>
<table border="1" width="560" align="center">
	<tr>
		<td width="140"><a href="admin.php">Naujienos</a></td>
		<td width="140"><a href="galerija.php">Galerija</a></td>
		<td width="140"><a href="koncertai.php">Koncertai</a></td>
		<td width="140"><a href="atsiliepimai.php">Atsiliepimai</a></td>
	</tr>
</table>
	<table border="1" width="560" align="center">
		<tr>
			<td height="50">
				<form  action="<? echo $php_self ?>" method="post" enctype="multipart/form-data">
				<table>
					<tr>
					<td align="center"><h4><?php echo $ats?><h4></td>
					</tr>
					<tr>
						<td><input type="radio" name=kalba value="1" checked>Lietuvių kalba
							<input type="radio" name=kalba value="2">Anglų kalba
						</td>
					</tr>
					<tr>
						<td>Pavadinimas: <input type="text" name="tema" style="width: 450px"></td>
					</tr>
					<tr valign="top">
						<td height="270"><textarea cols="70" rows="20" name="tekstas" id="text"></textarea></td>
					</tr>
					<tr>
						<td align="right"><input type="submit" value="Siųsti" name="ikelti"></td>
					</tr>
				</table>
				</form>
			</td>
		</tr>
	</table>
<?php mysql_close();?> 
</body>
</html>

