PHP Post表单不起作用

时间:2017-01-13 16:26:14

标签: php html forms

我无法将表单转到$ _POST。有没有人有任何想法?

<?php
require_once ($_SERVER['DOCUMENT_ROOT'].'/functions/requirements.php'); 

if ($_SESSION['loggedin'] != true){
    forceRedirect('./hub.php?page=login', 0); 

    }else{

    $row = DB::queryFirstRow("SELECT status FROM app_vendor WHERE user_id=%i LIMIT 1", $_SESSION['user_id']); 
    $status = ($row['status'] - 1);


    if (isset($_POST['submit'])){

        echo "worked";

        //forceRedirect('./hub.php?page=dashboard', 0); 
        //die();

    }else{


        include ($_SERVER['DOCUMENT_ROOT'].'/vendor_template/top.php');

        function label($url,$file){

            $html =<<<EOF
                <li>
                    <img width="250" height="300" alt="---Non Viewable PDF DOCUMENT---"" src="$url" />
                        <div class="text">
                        <!-- <div class="inner">Sample Caption on Hover</div> -->                                       
                        </div>
                    <input type="text" name ="$file" id="form-field-1" placeholder="Document name" class="col-xs-10 col-sm-30"> 
                </li>

EOF;

            return $html;

        }   

    if ($documents = DB::query("SELECT name, url FROM files WHERE  user_id=%i AND status=%i",  $_SESSION['user_id'] , $row['status'])){ 
        echo '<h3> <center> Please label your documents </center> </h3>';
        echo '<form method = "POST">';
        echo '<ul class="ace-thumbnails clearfix">';
        foreach ($documents as $document){

                $file = substr($document['name'], 0, -4); 
                echo label('../'.$document['url'],$file);

        }

        echo '</ul>';


        echo '<center>';
        echo '<br>';    
        echo '<br>';
        echo '<br>';
        //echo '<button type="submit" value ="submit" class="btn btn-primary" data-toggle="button" aria-pressed="false">Submit</button>';
        echo '<input type="submit" name="sumbit" value="submit" />';
        echo '</center>';
        echo '</form>';

    }

    include ($_SERVER['DOCUMENT_ROOT'].'/vendor_template/bottom_label.php');

    }


}else{

// not logged in    
}

?>

向我询问任何问题。当我提交表格时,我没有从$ _POST ['submit']返回。我希望我错过了一些我看过的东西。任何帮助,将不胜感激。

1 个答案:

答案 0 :(得分:0)

解决。 RE写了代码并修复了它。删除了该功能并将html与php结合起来。谢谢大家的帮助!