【问题标题】:PHP Post form not workingPHP Post表单不起作用
【发布时间】:2017-01-13 16:26:13
【问题描述】:

我无法将表单发送到 $_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'] 没有返回。我希望我错过了一些我看过的东西。任何帮助,将不胜感激。

【问题讨论】:

  • a) 编辑您的问题。 b) 注意正确的格式。 c) 清楚地写下你的问题。只是向我们扔一堆代码是没有帮助的。
  • 如果你使用 $_SESSION 那么你需要在页面上包含 session_start()。
  • 出于某种原因,它在 EOF 中添加了一个空格;我这边的语法是正确的。
  • Jeff - 我在其中一项要求中调用会话。
  • name="sumbit"if (isset($_POST['submit'])){...} 等于“不高兴”。错误报告会在这里为您提供帮助; undefined submit index.... php.net/manual/en/function.error-reporting.php - 答案/解决方案是:name="submit"@R.SABO

标签: php html forms


【解决方案1】:

已解决。 RE 编写了代码并修复了它。删除了函数并将 html 与 php.ini 结合起来。感谢大家的帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-29
    • 2021-02-06
    • 1970-01-01
    • 2015-07-21
    • 1970-01-01
    • 1970-01-01
    • 2014-06-02
    • 2012-01-18
    相关资源
    最近更新 更多