Having trouble with functions structure not following (PHP)

前端 未结 2 1586
梦毁少年i
梦毁少年i 2021-01-20 00:51


        
相关标签:
2条回答
  • 2021-01-20 01:03

    I'm not sure that submit buttons work that way.

    Also, you need to have method="POST" in the form if you want it sending POST vars, you had post="", which AFAIK does not do anything.

    Try this:

    function ShowAssessment()
    {   
    
    <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="POST">
    <input name="answerSubmit" type="hidden" value="1" />
    <input id="answerSubmit" type="submit" value="Get Student's Answers" />
    </form>
    
    <?php
    }
    
    0 讨论(0)
  • 2021-01-20 01:20

    I think I see the error here, In the PickSession function you have this line of code, within the form,

    <input type="hidden" name="module" value="<?php echo $_POST['module']; ?>">
    

    This re-posts the specified module back to the script, you are missing this line under the ShowAssessment function so when the user submits the "Get Student's Answers" form the data is not being posted in the form. Note that you will also have to re-post the session variable within the form as i see you have done but I assume you would want to make it a hidden field as such,

    function ShowAssessment()
    {
        //Sql...
    
         //Line 169 of bottom code sample
         <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">         
         <p>
            <input type="hidden" name="module" value="<?php echo $_POST['module']; ?>">
            //type="hidden" not "text"    
            <input type="hidden" name="session" value="<?php echo $_POST['session']; ?>">
    
            //Rest of code...
    }
    

    I believe adding this will fix your code. Note that you will have to continually re-post all the previously submitted data to maintain this structure of the code.

    0 讨论(0)
提交回复
热议问题