Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $username = "";
- $userid = "";
- $title = "";
- $content = "";
- $upfile = "";
- if( isset($_FILES['upfile']) ) {
- if( $_FILES['upfile']['name'] ) {
- $path = "../data/";
- $filename = $_FILES['upfile']['name'];
- $savefile = $path . $filename;
- if( move_uploaded_file($_FILES['upfile']['tmp_name'], $savefile) ){
- $upfile = $filename;
- }
- }
- }
- if( isset($_POST['username']) ){
- $username = $_POST['username'];
- }
- if( isset($_POST['userid']) ){
- $userid = $_POST['userid'];
- }
- if( isset($_POST['title']) ){
- $title = $_POST['title'];
- }
- if( isset($_POST['content']) ){
- $content = $_POST['content'];
- }
- if( $username && $userid && $title && $content ) {
- $sql = "insert into blog set ";
- $sql .= " username='{$username}' ";
- $sql .= ", userid='{$userid}' ";
- $sql .= ", title='{$title}' ";
- $sql .= ", content='{$content}' ";
- $sql .= ", upfile='{$upfile}' ";
- $sql .= ", wdate=now()";
- include("../lib/dbcon.php");
- if( $db->query($sql) ) {
- header("Location: /blog/");
- } else {
- header("Location: /blog/pages/write.php");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment