给提交按钮一个Php变量

时间:2016-05-08 10:36:33

标签: php forms session submit

我在这个论坛上找不到我的问题的解决方案。我试图通过从我的数据库中提取数据来为提交按钮提供PHP值(唯一ID )。我还想将值存储在SESSION中。当我将其他字符串作为值时,提交按钮不起作用。 学生观点

<pre>

    <?php foreach ($tabinternships as $internship) { ?>
        <tr>
            <td><span class="html"><?php echo $internship->id_internship() ?></span></td>
            <td><?php echo $internship->email_teacher1_internship() ?></span></td>
            <td><?php echo $internship->email_teacher2_internship() ?></span></td>
            <td><?php echo $internship->email_responsible_internship() ?></span></td>
            <td><?php echo $internship->id_promoter_internship() ?></span></td>
            <td><?php echo $internship->name_enterprise_internship() ?></span></td>     
            <td><?php echo $internship->stage_internship() ?></span></td>       
            <td><input type="radio" name="apply" value="<?php $tabinternship->id_internship() ?>"></td> <!-- Method calls an Object rather than an Array because I'm only displaying the attributes of 1 Object therefore the Array is not required here-->
        </tr>
    <?php } ?>

</pre>

StudentController:

<pre>

$tabinternships = Db::getInstance()->select_internships();

if(isset($_POST['apply']) && isset($_POST['application'])){
    $_SESSION['apply']= $_POST['apply'];
    $_SESSION['application']= $_POST['application'];
    $_SESSION['redirect']='redirect';
}

if(!empty($_SESSION['application']) && !empty($_SESSION['apply']) && !empty($_SESSION['redirect'])){
    $_SESSION['redirect']='';
    header("Location: index.php?action=formdeux");
    die();
}
</pre>

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

我发现错误,在给收音机输入值时我没有使用echo

 echo $tabinternship->id_internship()