php表单在localhost上工作正常,但在线发送空输入

时间:2014-08-14 17:31:41

标签: php mysql forms web-hosting

我在php中有一些将数据上传到mysql数据库的表单。我已经使用xampp在localhost服务器上进行了测试,但是当我将文件上传到我的主机ftp时,表单不起作用。我认为它与我放置此文件以及密码限制下的“connect.php”文件这一事实有关,这与文件权限有关。我已经授予了数据库用户的权限和文件的权限,我也尝试过没有密码保护,但结果是一样的。

所以我开始尝试一点,我发现图像上传到数据库,但其他输入没有,既没有“标题”输入也没有“文章”textarea ...知道,我试过“回显”这些输入结果,但除非图像输入,否则它们都没有显示。我得出的结论是我的表单正在发送空数据。有人可以提出有关正在发生的事情以及如何解决问题的建议吗?这是我的代码:

<html>
<head>
<meta charset="UTF-8">
  <title>Untitled Document</title>
</head>
<body>
<div id="slider_upload">

<h1>Slider principal</h1>
    <div class="forma">

    <form action="sliderPrincipal.php" method="post" enctype="multipart/form-data">
        <p><label for="header">Header</label>
        <input type="text" id="header" name="header" /></p><br>
        <input type="hidden" name="MAX_FILE_SIZE" value="1048576" />
        <p><label for="fileupload">File to upload</label>
        <input type="file" id="fileupload" name="fileupload" /></p><br>
        <p><label for="article">article</label>
        <textarea id="article" name="article" rows="26" style="width: 100%;" >Write here</textarea></p><br>
         <button type="submit" name="submit" value"send">Upload File</button>
    </form><br><br>

</div>
</div>

<div class="message">
    <?php 



$file_dir = "../uploaded";

if (isset($_POST['header'])){
$header = mysql_real_escape_string($_POST['header']);
$article = mysql_real_escape_string($_POST['article']);
}


foreach($_FILES as $file_name => $file_array){
   //echo "path: ".$file_array['tmp_name']."<br />\n";
   //echo "name: ".$file_array['name']."<br/>\n";
   //echo "type: ".$file_array['type']."<br/>\n";
   //echo "size: ".$file_array['size']."<br/><br/>\n";
   //echo "encabezado ".$encabezado;

        if(is_uploaded_file($file_array['tmp_name'])){
        move_uploaded_file($file_array['tmp_name'], "$file_dir/".$file_array['name']) or die ("Your image couldnt be uploaded <br>");   
        $newpath = addslashes("uploaded/".$file_array['name']);
        include "connect.php"; 
        $addfile = "INSERT INTO slider (header, image, article) VALUES ('$header','$newpath', '$article')"; 
        $result = mysql_query($addfile);
        if ( $result === FALSE ) {
            echo "your post could not be uploaded but we already got your image in our files ";
        } else{
            echo '<p style="padding: 20px;"><h1>Your post was successfully uploaded <h2></p><br><br>';

        }


        mysql_close();  

    } else "No file found";


 }

 ?>
</div>  
</div>
</body>
</html>

0 个答案:

没有答案