Location: PHPKode > projects > EZphotopress > ezphotopress-1.0.0/admin/posts/addPost.php
<h3><?=ADDPOST_TITLE?></h3>
<br>
<?php
if (isset($_POST['action']) && $_POST['action'] == ADDPOST_FORM_SUBMIT_VALUE) {
	$title = $_POST['title'];
	$code = $_POST['code'];
	$body = $_POST['body'];
	$publish = $_POST['publish']; //checkpox
	
	$isPublish = 1;
	if (isset($publish)) {
		$isPublish = 1; 
	} else {
		$isPublish = 0;
	}
	
	$query = "insert into ".TABPREFIX."blog(code,title,body,create_date,last_modify,published) values(";
	$query .= "'".addslashes($code)."',";
	$query .= "'".addslashes($title)."',";
	$query .= "'".addslashes($body)."',";
	$query .= "NOW(),";
	$query .= "NOW(),";
	$query .= $isPublish;
	$query .= ")";
	
	$result = $db->query($query);
	if ($result->sizeIDU() != -1) {
		?>
		<p class="ok">
			<?=ADDPOST_OK?><br><br>
		</p>
		<br>
		<center>
			<a href="home.php?id=blog&action=new" class="back"><?=ADDPOST_LINK?></a>
		</center>
		<?php
	} else {
		?>				
		<p class="ok">
			<?=ADDPOST_ERROR?><br><br>
		</p>
		<br>
		<center>
			<a href="home.php?id=blog&action=new" class="back"><?=ADDPOST_LINK?></a>
		</center>
		<?php
	}
} else {
	?>
	<script type="text/javascript">
	function changeTest(form) { 
		var s = document.getElementById('title').value;
		//replace all special chars
		s = s.replace(/[^0-9a-zA-Z]+/g, "_");
		document.getElementById('code').value = s.toLowerCase();
	} 
	</script>
	<form action="home.php?id=blog&action=new" method="post" name="form_blog" id="form_blog">
		<input type="hidden" id="idpost" name="idpost" value="-1">
		<fieldset>
			<div>
				<label><?=ADDPOST_FORM_PUBLISH?></label>
				<input type="checkbox"" id="idpublish" name="publish">
			</div>
			<div>
				<label><?=ADDPOST_FORM_TITLE?></label>
				<input type="text" id="title" name="title"  size="40" onkeyup="changeTest(this)">
			</div>
			<div>
				<label><?=ADDPOST_FORM_ID?></label>
				<input type="text" id="code" name="code"  size="40">
			</div>
			<div>
				<label><?=ADDPOST_FORM_TEXT?></label>
				<textarea rows="20" class="tinymce" name="body"></textarea>
			</div>
			<div style="text-align: center;">
				<input type="submit" name="action" value="<?=ADDPOST_FORM_SUBMIT_VALUE?>">
			</div>
		</fieldset>
	</form>
	<?php 
}
?>
Return current item: EZphotopress