我有一个注册和登录PHP脚本,它使用会话并在登录时显示每个用户名。我还有一个表格,他们可以填写并添加到mysql数据库。是否有可能只有填写了THEIR形式的用户才能在显示时看到它?目前,只要有任何用户填写表格,其显示给每个用户。
<?PHP
require_once("./include/membersite_config.php");
if(!$fgmembersite->CheckLogin())
{
$fgmembersite->RedirectToURL("login.php");
exit;
}
?>
<!DOCTYPE>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title></title>
<link rel="STYLESHEET" type="text/css" href="style/fg_membersite.css">
</head>
<body>
<div id='fg_membersite_content'>
<h2>Product control page</h2>
<p>
Logged in as: <?= $fgmembersite->UserFullName() ?>
</p>
<p>Here you can see your Current Products:</p>
<?php
$con = mysql_connect("localhost","root","password");
if (!$con){
die("Can not connect: " . mysql_error());
}
mysql_select_db("trackerweb",$con);
$result = mysql_query("SELECT Name_of_Product FROM Product_Tracker");
while ($row = mysql_fetch_assoc($result)) {
echo $row['Name_of_Product'];
echo "<br />";
mysql_query($query);
}
mysql_close($con);
?>
<p>
<a href='add_customer.php'>Add a new product </a>
</p>
<p>
<a href='view.php'>View all product details</a>
</p>
<p>
<a href='login-home.php'>Home</a>
</p>
</div>
</body>
</html>
我只需要在同一页面填写表格时显示产品名称。
这是表格:
<?php
require_once("/extlib/vdaemon/vdaemon.php");
require_once("./core/config.php");
$_SESSION['user']= ['$fgmembersite->UserFullName'];
?>
<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" />
<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(); ?>