-5

I can not get my form to $_POST. Does anyone have any ideas?

<?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    
}

?>

Ask me for any questions. When I submit the form I get no return from $_POST['submit']. I hope I am missing something I over looked. Any help would be appreciated.

R.SABO
  • 9
  • 2
  • 3
    a) **edit** your question. b) take care of proper **formatting**. c) **clearly** write your question. just throwing a bunch of code at us is not helpful. – Franz Gleichmann Jan 13 '17 at 16:27
  • If you are using $_SESSION then you need to include session_start() on the page. –  Jan 13 '17 at 16:36
  • for some reason it added a space to the EOF; the syntax is correct on my side. – R.SABO Jan 13 '17 at 16:37
  • Jeff - I am calling the session in one of the requirements. – R.SABO Jan 13 '17 at 16:40
  • `name="sumbit"` and `if (isset($_POST['submit'])){...}` equals "no joy". Error reporting would have helped you here; `undefined submit index....` http://php.net/manual/en/function.error-reporting.php - And the answer/solution for this is: `name="submit"` @R.SABO – Funk Forty Niner Jan 13 '17 at 16:48
  • Possible duplicate of [PHP: “Notice: Undefined variable” and “Notice: Undefined index”](http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index) – Funk Forty Niner Jan 13 '17 at 16:51
  • and if what I wrote above didn't solve it, then you need to check for errors using the link I gave you for error reporting. – Funk Forty Niner Jan 13 '17 at 16:54
  • I have error reporting enabled. it refreshes the page for some reason I am not passing the variable submit. Note: I do not have any notices for undefined variables. – R.SABO Jan 13 '17 at 17:04

1 Answers1

0

SOLVED. RE Wrote the code and it fixed it. Removed the function and combined the html with the php. Thanks everyone for the help!

R.SABO
  • 9
  • 2