由于上传,表单页面无法重定向

时间:2014-09-27 16:32:31

标签: php smarty

我正在使用一个智能平台来操作带有上传功能的表单页面。在我包含上传功能之前,在我的localhost和远程服务器上提交和处理表单之后的重定向都很好。

在我上传图像到其中一个远程目录的上传功能之后,远程服务器中不会​​发生重定向,而是在我的本地主机中进行重定向。

可能是什么问题?

// page header
PageHeader("Create a new Post on Pulse");

if($_POST['apply']){



    $addAuthor=$db->query("INSERT INTO pulseauthors(`UserID`,`signature`,`AboutAuthor`)  VALUES('".$userArray['UserID']."','".$_POST['signature']."','".$_POST['about']."')");

    if(!$addAuthor){
header("Location: ".SITE_URL."/pulse");

    }else{


    $wlcmMsg=true && $message='<div class="alert alert-success"><strong>Welcome to Pulse!</strong> You can write your new post below now, or some other time.</div>';
    }


    $smarty->assign('wlcmMsg',$wlcmMsg);

    $smarty->assign('message',$message);

}

if($_POST['submit']) {





    // sanitize title
    $title = Sanitize($_POST['title']);


    if($_POST['newCat'] != ""){



        //assign category to the new created one
        $cat=$_POST['newCat'];

        //Create a new CategorY

        $db->query("INSERT INTO pulse_cat (`category`) VALUES('".$cat."')");



    }else{

        $cat=$_POST['cat'];

    }

    require_once 'libs/upload_file.php';//This is the upload function



    $body=$_POST['body'];


    // check if empty
    if(!IsEmpty($title) && !IsEmpty($body) && !IsEmpty($_FILES["file"]["name"]) && !IsEmpty($cat) ) {
        // check title length
        if(strlen($title) < 256) {
            // check body length
            if(strlen($body) <= 100000) {



                // insert app post
                $db->query(sprintf("INSERT INTO posts_discussions (Title, Text,category,featuredImage) VALUES (%s, %s,%s,%s)", SafeSQL($title), SafeSQL($body),SafeSQL($cat),SafeSQL($featuredImage) )) or SQLError();
                $postId = $db->insert_id;
                // insert post
                $db->query(sprintf("INSERT INTO posts (UserID, PostType, PostID, Time) VALUES (%s, 5, %s, %s)", Secure($userArray['UserID'], 'int'), Secure($postId, 'int'), Secure($now) )) or SQLError();
                // update user posts
                $db->query(sprintf("UPDATE users SET UserPosts = UserPosts + 1 WHERE UserID = %s", Secure($userArray['UserID'], 'int') )) or SQLError();
                // redirect


                header('Location: '.SITE_URL.'/pulse/'.$postId);   


            }else {
                $error = "Your body is too long. The maximum length is 100,000 characters.";

                unlink("".SITE_URL."/".$featuredImage."");

            }
        }else {
            $error = "Your title is too long. The maximum length is 255 characters.";

            unlink("".SITE_URL."/".$featuredImage."");
        }
    }else {
        $error = "Please provide all the fields to be able to postan article.";

        unlink("".SITE_URL."/".$featuredImage."");
    }
}

0 个答案:

没有答案