我已经建立了这个IT支持票务系统,员工可以在系统中发送问题。
所以这是管理员看到的内容。
基本上我想要发生的是当我点击接受时,登录的用户(管理员)的全名将显示在受让人下方。
到目前为止,这就是我所做的:
我的表单上有会话代码:
<?php
session_start();
ob_start();
//Include the database connection file
include "database_connection.php";
//Check to be sure that a valid session has been created
if(isset($_SESSION["VALID_USER_ID"]))
{
//Check the database table for the logged in user information
$check_user_details = mysql_query("select * from `employee` where `username` = '".mysql_real_escape_string($_SESSION["VALID_USER_ID"])."'");
//Validate created session
if(mysql_num_rows($check_user_details) < 1)
{
session_unset();
session_destroy();
header("location: login.php");
}
else
{
//Get all the logged in user information from the database users table
$get_user_details = mysql_fetch_array($check_user_details);
$user_id = strip_tags($get_user_details['id']);
$fullname = strip_tags($get_user_details['fullname']);
$username = strip_tags($get_user_details['username']);
$email = strip_tags($get_user_details['email']);
$address = strip_tags($get_user_details['address']);
$gender = strip_tags($get_user_details['gender']);
$contact = strip_tags($get_user_details['contact']);
$user_access_level = strip_tags($get_user_details['user_levels']);
$passwd = strip_tags($get_user_details['password']);
$picture = strip_tags($get_user_details['picture']);
$sickleave = strip_tags($get_user_details['sickleave']);
$vacationleave = strip_tags($get_user_details['vacationleave']);
?>
&#13;
这就是我的所作所为:
<?php
include ('database.php');
$result = $database->prepare ("SELECT * FROM tickets order by ticketno DESC");
$result ->execute();
for ($count=0; $row_message = $result ->fetch(); $count++){
?>
<tr>
<td><?php echo $row_message['full_name']; ?></td>
<td><?php echo $row_message['time']; ?></td>
<td><?php echo $row_message['priority']; ?></td>
<td>
<form method="post" action="update1.php">
<input type="hidden" name="ticketno" value="<?php echo $row_message['ticketno']; ?>" />
<input type="submit" value="<?php echo $row_message['fullname'];?>" name="accept"></input>
</form>
</td>
<td><?php echo $row_message['subject']; ?></td>
<td><?php echo $row_message['problem']; ?></td>
</tr>
<?php } ?>
&#13;
Update1.php:
<?php
if(isset($_POST['accept']))
{
$msg = "Approved";
$assignee=$_POST['accept'];
}
$ticketno=$_POST['ticketno'];
$con = mysqli_connect('localhost', 'root', '');
mysqli_select_db($con, 'companydb');
$sql = "UPDATE tickets SET assignee = '$assignee' WHERE ticketno = '$ticketno'";
if(mysqli_query($con, $sql))
header("refresh:1; url=tickets.php?msg=$msg");
else
var_dump(mysqli_error($con));
?>
&#13;
以下是我的表格:
顺便说一下,我知道mysql已被弃用。我将来肯定会改变它,现在我需要解决这个问题。
答案 0 :(得分:0)
您必须存储在sh -c 'perl ...'
表格中的信息。因此,您只需使用if语句来显示受理人姓名而不是表单。
tickets
我认为你在数据库中存储的不是你想要的值:
<?php
include ('database.php');
$result = $database->prepare ("SELECT * FROM tickets order by ticketno DESC");
$result ->execute();
for ($count=0; $row_message = $result ->fetch(); $count++){
?>
<tr>
<td><?php echo $row_message['full_name']; ?></td>
<td><?php echo $row_message['time']; ?></td>
<td><?php echo $row_message['priority']; ?></td>
<?php if ($row_message['assignee']) : ?>
<td><?php echo $row_message['assignee']; ?></td>
<?php else : ?>
<td><form method="post" action="update1.php">
<input type="hidden" name="ticketno" value="<?php echo $row_message['ticketno']; ?>" />
<input type="submit" name="accept"></input>
</form></td>
<?php endif ; ?>
<td><?php echo $row_message['subject']; ?></td>
<td><?php echo $row_message['problem']; ?></td>
</tr>
<?php } ?>
答案 1 :(得分:0)
试试此代码
include ('database.php');
$result = $database->prepare("SELECT * FROM tickets order by ticketno DESC");
$result ->execute();
for ($count=0; $row_message = $result ->fetch(); $count++){
?>
<tr>
<td><?php echo $row_message['full_name']; ?></td>
<td><?php echo $row_message['time']; ?></td>
<td><?php echo $row_message['priority']; ?></td>
<?php if(empty($row_message['full_name'])) {?>
<td>
<form method="post" action="update1.php">
<input type="hidden" name="ticketno" value="<?php echo $row_message['ticketno']; ?>" />
<input type="submit" value="<?php echo $row_message['full_name'];?>" name="accept"></input>
</form>
</td>
<?php }else { ?>
<td>
<?php echo $row_message['full_name'];?>
</td>
<?php } ?>
<td><?php echo $row_message['subject']; ?></td>
<td><?php echo $row_message['problem']; ?></td>
</tr>
<?php } ?>