我想发送存储在会话变量中的用户 ID。当用户提交表单时,数据库应该接收用户提交的数据并从数据库中获取用户ID。这是我所拥有的:
session_start();
if (!isset($_SESSION['username']));
{
header('Location: index.php');
}
<p>Welcome, <b> echo $_SESSION['username'];</b>
if(isset($_POST['submit']))
{
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
if(! get_magic_quotes_gpc() )
{
$complaint = addslashes ($_POST['complaint']);
}
else
{
$complaint = $_POST['complaint'];
}$sql = "INSERT INTO employee ".
"(complaint) ".
"VALUES('$complaint')";
mysql_select_db('sistempinjaman');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
echo "You complaint sent. We will respon soon via email \n";
mysql_close($conn);
}
用户名可以与提交表单一起发送吗?
当我们想要显示数据时,表格将具有:
| username | complaint |