<? include("../login/include/session.php"); ?>
<?php
include"connect.php";
if(!isset($_POST['add_news']))
{
echo"
<br />
<br />
<form action='$self?action=addnews' name='addnews' method='post' enctype=\"multipart/form-data\">
<table>
<tr>
<td>
Title
</td>
<td>
<input type='text' name='title'>
</td>
</tr>
<tr>
<td>
Description:
</td>
<td>
<textarea cols='15' name='description' rows='5'></textarea>
</td>
</tr>
<tr>
<td>
URL: http://
</td>
<td>
<input type='text' name='url'></input>
</td>
</tr>
<tr>
<td>
Upload Image:
</td>
<td>
<input type='file' name='imgfile'></input>
</td>
</tr>
<tr>
<td>
<input type='submit' name='add_news' value='submit news topic'>
</td>
</tr>
</table>
</form>";
}
elseif(isset($_POST['add_news']))
{
$title = mysql_real_escape_string($_POST['title']);
$url = mysql_real_escape_string($_POST['url']);
$description = $_POST['description'];
$date = date("d.m.y");
$username = $_SESSION['username'];
$error = array();
if(empty($title)) {
$error[] = "You must enter a title!";
}
if(empty($description)) {
$error[] = "Enter a description please";
}
if(empty($url)) {
$error[] = "The URL is needed";
}
if(count($error)>0) {
echo"<font size='3' color='#CC0000'><strong>ERROR:</strong></font>";
foreach($error as $error2);
echo"$error2";
}
else {
$sql = "INSERT INTO submit(title, description, url, author, date, valid) VALUES('$title', '$description', '$url', '$username', '$date', '0')";
mysql_query($sql);
echo"Website successfully queued for verification. Your site will be added when verified by an Admin. Check back soon to see it. An email will be sent if there is any problems.";
}
}
if(isset($_POST['submit'])) {
$uploadpath = "upload/";
$uploadpath = $uploadpath . basename( $_FILES['imgfile']['name']);
if(move_uploaded_file($_FILES['imgfile']['tmp_name'], $uploadpath)) {
echo"This file: ". basename( $_FILES['imgfile']['name']). "has been uploaded Other Details:";
echo"Mime Type: ". $_FILES['imgfile']['type'] ."";
echo"Size (Bytes): ". $_FILES['imgfile']['size'] ."";
echo"File Name: ". $_FILES['imgfile']['name'] ."";
}
else {
echo "There was an error uploading the file, please try again!";
}
}
?>