将用户会话添加到表中?

时间:2015-04-13 09:23:53

标签: php html forms

我正在尝试将用户会话添加到完成表单时填写的表。然后我想显示他们在主页上创建的表单。

<?php 
require_once("/extlib/vdaemon/vdaemon.php");

require_once("./core/config.php");


 ?>


<html>
<head>
<style type="text/css">
body {
    background: #e4e4e4;
}

.form {
    width: 600px;
    margin: 0 auto;
    background: #fff;
    padding: 45px;
    border: 1px solid #c2c2c2;
}

.error {
    color: #AA0000
}
.controlerror {
    background-color: #ffffdd;
    border: 1px solid #AA0000;
}

.input {
    width: 300px;
    height: 35px;
    margin-left: 10px;
}
</style>
</head>
<body>
<div class="form">
<?php
$msg = $_GET['msg'];

if ( $msg == '1' ) {
    echo '<p>Your information was submitted successfully.</p>';
}
?>

<form action="core/process.php" method="post" id="registration" >
<input type="hidden" name="formID" value="Product_Tracker" />

**<input type="hidden" name="id_user" value="$_SESSION['id_user']" />**

<p>Name of product:<input type="text" name="Name of Product" class="input" />

<p>Please select the tests that were done on the product.</p>   
<p>In Circuit Test (ICT): Yes: <input type="radio" name="ICT" value="yes" /> No: <input type="radio" name="ICT" value="no" /></p>
<p>Visual Inspection: Yes: <input type="radio" name="Visual Inspection" value="yes" /> No: <input type="radio" name="Visual Inspection" value="no" /></p>
<p>XRAY: Yes: <input type="radio" name="XRAY" value="yes" /> No: <input type="radio" name="XRAY" value="no" /></p>
<p>Automated Optical Inspection (AOI): Yes: <input type="radio" name="AOI" value="yes" /> No: <input type="radio" name="AOI" value="no" /></p>
<!--<p>Checkbox1 <input type="checkbox" name="checkbox" value="checkbox1" /> Checkbox2: <input type="checkbox" name="checkbox" value="checkbox2" /></p>-->



<input type="submit" value="Submit" />
<p>
<a href='access-controlled.php'>Back</a>
</p>
</form>
</div>
</body>
</html>
<?php VDEnd(); ?>

当我在创建表单时查看phpMyAdmin时,id_user是$_SESSION['id_user']而不是创建它的用户的名称。

1 个答案:

答案 0 :(得分:2)

你没有回显$ _SESSION ['id_user']的值,试试这个

<input type="hidden" name="id_user" value="<?php echo $_SESSION['id_user']"; ?> />