My code for the upload script is:
<?php
switch (@$_POST['html'])
{
case "upload":
include("dbstuff.inc");
$cxn = mysqli_connect($host,$user,$passwd,$dbname);
$title = htmlspecialchars($_POST['title']);
$article = htmlspecialchars($_POST['article']);
$author = htmlspecialchars($_COOKIE['name']);
$comment = htmlspecialchars($_POST['comment']);
$add_art = addslashes($article);
$add_title = addslashes($title);
$final = nl2br($add_art);
$date = date('Y-m-d');
$time = date('h:i:s');
$cxn;
$insert = "INSERT INTO 'uploaded' ('title', 'body', 'insert_time', 'insert_date', 'author', 'comment') VALUES ('$add_title', '$final', '$time', '$date', '$author', '$comment')";
mysqli_query($cxn,$insert);
if($insert){
echo "Ok.";
}else{
echo "Nope.";
}
mysqli_close($cxn);
default:include("upload.inc");
}?>
and for the form:
<?include("header.php")?>
<title>Submit a file</title>
</head>
<body>
<?include("nav.php")?>
<div id="content">
<form action=<?php echo $_SERVER['PHP_SELF']?> method="POST">
<table style="font-family:arial;" cellpadding="8">
<tr valign="top">
<td>Title:</td>
<td><input type="text" name="title" /></td>
</tr>
<tr valign="top">
<td>Article:</td>
<td><textarea cols="40" rows="20" name="article"></textarea></td>
</tr>
<tr>
<td>Additional Comments</td>
<td><textarea cols="40" rows="10" name="comment"></textarea></td>
</tr>
</table>
<table>
<tr>
<td><input type="submit" name="html" value="upload"/></td>
</tr>
</table>
</form>
</div>
<?include("footer.php")?>

New Topic/Question
Reply




MultiQuote





|