所以我自愿在工作中创建一个用户表单,并且认为我添加了一个有趣的小麻烦,并用HTML / CSS / PHP / mySQL而不是MS word来完成。
基本上,这是我用来从我的数据库中添加和删除用户的表单。我已经完成了初始表单,创建了一个PHP文件来保存我数据库中的所有内容并正确链接。
我的问题是,如何创建一个页面,其中包含所有姓名/姓氏/ ID的下拉列表,浏览者可以点击这些页面"提交"并获得有关用户的所有信息?
我现在一直在谷歌搜索几个小时,但似乎没有用,因为似乎有些人有类似的问题,但是我还缺少一些我需要的大型拼图。
我知道这听起来有点令人困惑,所以这里是我的代码,以便您可以获得更好的想法:
HTML:
@charset "UTF-8";
table,
th,
td {} table {
border-collapse: collapse;
}
td {
padding: 3px;
}
input[type="text"],
textarea {
background-color: #F8FCFF;
border: 2px solid #eeeeee;
color: #333333;
font-size: 0.9em;
font-style: normal;
font-weight: 400;
font-family: Tahoma;
Helvetica;
}
body {
background-color: #e6e6e6;
margin: 0 auto;
}
f {
font-style: normal;
font-weight: 550;
font-family: sans-serif;
source-sans-pro;
}
bigbold {
font-style: normal;
font-weight: bold;
font-size: 20px;
font-family: sans-serif;
source-sans-pro;
}
info {
font-style: normal;
font-weight: bold;
font-family: sans-serif;
source-sans-pro;
}
.tr-top {
border-top: 1pt solid black;
}
.tr-left {
border-left: 1pt solid black;
}
.td-left {
border-left: 1pt solid black;
width: 35%;
}
.checkboxes label {
display: block;
float: left;
padding-right: 10px;
white-space: nowrap;
}
.checkboxes input {
vertical-align: middle;
}
.checkboxes label span {
vertical-align: middle;
}
#body1 {
width: 1000px;
background: #fff;
height: 100%;
}
#wrapper {
max-width: 1000px;
height: 100%;
background: #fff;
margin: 0px auto 0;
padding: 20px;
}
#colour {
background: #C6DEFF;
}
</style>
&#13;
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled D
<!--#include file="NewUser_get.php" -->
ocument</title>
<link href="Untitled-4.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--<div id="body1">-->
<div id="wrapper">
<div id="head">
<form action="NewUser_get.php" method="POST">
<table style="width:1000px">
<tr>
<td width=90%>
<f>Request date:</f>
<br>
<input type="date" name="RequestDate">
</td>
<td width=10%>
<f>Requested by:</f>
<br>
<input type="text" style="width: 166px;" name="RequestBy">
</td>
</tr>
</table>
<br>
<div id="colour">
<info>
<center>New User Info</center>
</info>
</div>
<br>
<table style="width:100%">
<tr>
<td>
<f>Employee's last name: </f>
<input type="text" placeholder="Click to type" name="LastName">
</td>
<td>
<f>First name
<input type="text" placeholder="Click to type" name="FirstName">
</td>
<td>
<f>Middle name
<input type="text" placeholder="Click to type" name="MiddleName">
</td>
<td>
<f>Employment type
<select name="EmploymentType">
<option value="Permanent">Permanent</option>
<option value="Temporary">Temporary</option>
<option value="Contractor">Contractor</option>
<option value="Placement">Placement</option>
<option value="Other">Other</option>
</select>
</td>
<td width="80px">
<f> Gender</f>
<br>
<label for="GenderMale">
<input type="checkbox" name="GenderMale" value="Yes" /> <span>M</span>
</label>
<label for="GenderFemale">
<input type="checkbox" name="GenderFemale" value="Yes" /> <span>F</span>
</label>
</td>
</tr>
<tr>
<td>
<f>Department </f>
<br>
<input type="text" placeholder="Click to type" name="Department1">
</td>
<td>
<f>Job title </f>
<input type="text" placeholder="Click to type" name="JobTitle">
</td>
<td>
<f>Manager's name </f>
<input type="text" placeholder="Click to type" name="ManagerName">
</td>
<td>
<f>Start date </f>
<br>
<input type="date" placeholder="Click to type" name="StartDate">
</td>
<td>
<f>Finish date </f>
<input type="date" style="width: 166px;" name="FinishDate">
</td>
</tr>
</table>
<br>
<table style="width:100%">
<tr>
<td>
<f>Full address:</f>
<br>
<input type="text" style="width: 992px;" placeholder="Click to type, Address/ P.O. Box, City, Street, Post code" name="FullAddress">
</td>
</tr>
</table>
<br>
<table style="width:100%">
<tr>
<td>
<f>User Group / Profile to Use:</f>
<input type="text" style="width: 325px;" placeholder="Click to type, e.g. same as John, Accounts" name="UserGroup">
</td>
<td>
<f>Distribution Groups to be included:</f>
<input type="text" style="width: 325px;" placeholder="Click to type, e.g. Staff, Internal, External" name="DistributionGroup">
</td>
<td>
<f>Shared Drive Access:</f>
<input type="text" style="width: 325px;" placeholder="Click to type" name="SharedDriveAccess">
</td>
</tr>
</table>
<br>
<table style="width:100%">
<tr>
<td>
<f>Permissions on shared drives (in detail):</f>
<br>
<input type="text" style="width: 993px;" placeholder="Click to type, e.g. Marketing drive 'read only, Technical drive 'Full Access'" name="Permissions">
</td>
</tr>
</table>
<br>
<div id="colour">
<info>
<center>Additional Info</center>
</info>
</div>
<br>
<div class="checkboxes">
<table style="width:100%">
<tr>
<td width="%50">
<bigbold>List of required items (Tick the box next to an item):</bigbold>
</td>
<td> </td>
<td class="td-left" width="%50">
<bigbold>List of required software/drive access:</bigbold>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td class="td-left">
<info> Drives:</info>
</td>
<td>
<info> Software:</info>
</td>
</tr>
<tr>
<td>
<label for="iPad">
<input type="checkbox" name="iPad" value="Yes"> <span><f>iPad + case</f></span>
</label>
</td>
<td>
<label for="Mouse">
<input type="checkbox" name="Mouse" value="Yes"> <span><f>Mouse</f></span>
</label>
</td>
<td class="td-left">
<label for="Sales">
<input type="checkbox" name="Sales" value="Yes"><span><f>Sales</f></span>
</label>
</td>
<td>
<label for="Salesforce">
<input type="checkbox" name="Salesforce" value="Yes"> <span><f>Salesforce</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="iPhone">
<input type="checkbox" name="iPhone" value="Yes"> <span><f>iPhone + case</f></span>
</label>
</td>
<td>
<label for="Laptopb">
<input type="checkbox" name="Laptopb" value="Yes"> <span><f>Laptop bag</f></span>
</label>
</td>
<td class="td-left">
<label for="Marketing">
<input type="checkbox" name="Marketing" value="Yes"> <span><f>Marketing</f></span>
</label>
</td>
<td>
<label for="VPN">
<input type="checkbox" name="VPN" value="Yes"> <span><f>VPN</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Laptop">
<input type="checkbox" name="Laptop" value="Yes"> <span><f>Laptop</f></span>
</label>
</td>
<td>
<label for="Dphone">
<input type="checkbox" name="Dphone" value="Yes"> <span><f>Desk phone</f></span>
</label>
</td>
<td class="td-left">
<label for="General">
<input type="checkbox" name="General" value="Yes"> <span><f>General</f></span>
</label>
</td>
<td>
<label for="Terminal">
<input type="checkbox" name="Terminal" value="Yes"> <span><f>Terminal server</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Desktop">
<input type="checkbox" name="Desktop" value="Yes" /> <span><f>Desktop</f></span>
</label>
</td>
<td>
<label for="Printerw">
<input type="checkbox" name="Printerw" value="Yes"> <span><f>Printer (work)</f></span>
</label>
</td>
<td class="td-left">
<label for="CAD">
<input type="checkbox" name="CAD" value="Yes"> <span><f>CAD</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Printerh">
<input type="checkbox" name="Printerh" value="Yes"> <span><f>Printer (home)</f></span>
</label>
</td>
<td>
<label for="Dongle">
<input type="checkbox" name="Dongle" value="Yes"> <span><f>Dongle</f></span>
</label>
</td>
<td class="td-left">
<label for="Finance">
<input type="checkbox" name="Finance" value="Yes"> <span><f>Finance</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Monitor">
<input type="checkbox" name="Monitor" value="Yes"> <span><f>Monitor</f></span>
</label>
</td>
<td>
<label for="MiFi">
<input type="checkbox" name="Mifi" value="Yes"> <span><f>MiFi (Mobile Wifi)</f></span>
</label>
</td>
<td class="td-left">
<label for="Accounts">
<input type="checkbox" name="Accounts" value="Yes"> <span><f>Accounts</f></span>
</label>
</td>
<td></td>
</tr>
<tr>
<td>
<label for="Keyboard">
<input type="checkbox" name="Keyboard" value="Yes"> <span><f>Keyboard</f></span>
</label>
</td>
<td></td>
<td class="td-left"></td>
<td></td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</table>
<div id="colour">
<center>
<info>Miscellaneous:</info>
</center>
</div>
<br>
<table style="width:100%">
<tr>
<td>
<f>Should the predecessor's email be assigned to this user?</f>
</td>
<td>
<label for="Pemail">
<input type="checkbox" name="Pemail" value="Yes"> <span><f>Yes</f></span>
</label>
</td>
</tr>
<tr class="tr-top">
<td>
<f>Is the user replacing someone else from the staff or is he/she a completely new employee?</f>
</td>
<td>
<label for="Replacement">
<input type="checkbox" name="Replacement" value="Yes"> <span><f>Replacement</f></span>
</label>
</td>
<td>
<label for="NewUser">
<input type="checkbox" name="NewUser" value="Yes"> <span><f>New user</f></span>
</label>
</td>
</tr>
</table>
<br>
<textarea name="AddRequirements" style="width:1000px;" placeholder="Please continue here for any other extra requirements e.g. need of a special signature, software, hardware etc. or needed access to another user’s files and documents, or assign another user’s email profile to this user so they inherit all files and folders form the old user."></textarea>
<!--<input type='hidden' name='articleid' id='articleid' value='<? echo $_GET["id"]; ?>' /> -->
<input type="submit">
</form>
</div>
</div>
</body>
</html>
&#13;
PHP:
<?php
if( $_POST )
{
$conn = mysqli_connect("myhost","myuser","mypassword", "mydb");
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$RequestBy = $_POST['RequestBy'];
$FirstName = $_POST['FirstName'];
$MiddleName = $_POST['MiddleName'];
$LastName = $_POST['LastName'];
$Desktop = $_POST['Desktop'];
$EmploymentType = $_POST['EmploymentType'];
$GenderMale = $_POST['GenderMale'];
$GenderFemale = $_POST['GenderFemale'];
$Department1 = $_POST['Department1'];
$JobTitle = $_POST['JobTitle'];
$ManagerName = $_POST['ManagerName'];
$FullAddress = $_POST['FullAddress'];
$UserGroup = $_POST['UserGroup'];
$DistributionGroup = $_POST['DistributionGroup'];
$SharedDriveAccess = $_POST['SharedDriveAccess'];
$Permissions = $_POST['Permissions'];
$iPad = $_POST['iPad'];
$Mouse = $_POST['Mouse'];
$Sales = $_POST['Sales'];
$Salesforce = $_POST['Salesforce'];
$iPhone = $_POST['iPhone'];
$Laptopb = $_POST['Laptopb'];
$Marketing = $_POST['Marketing'];
$VPN = $_POST['VPN'];
$Laptop = $_POST['Laptop'];
$Dphone = $_POST['Dphone'];
$General = $_POST['General'];
$Terminal = $_POST['Terminal'];
$Printerw = $_POST['Printerw'];
$CAD = $_POST['CAD'];
$Printerh = $_POST['Printerh'];
$Dongle = $_POST['Dongle'];
$Finance = $_POST['Finance'];
$Monitor = $_POST['Monitor'];
$Mifi = $_POST['Mifi'];
$Accounts = $_POST['Accounts'];
$Keyboard = $_POST['Keyboard'];
$Pemail = $_POST['Pemail'];
$Replacement = $_POST['Replacement'];
$NewUser = $_POST['NewUser'];
$AddRequirements = $_POST['AddRequirements'];
}
$sql= "
INSERT INTO TestTable (RequestBy, FirstName, MiddleName, LastName, Desktop, EmploymentType, GenderMale, GenderFemale, Department1, JobTitle, ManagerName, FullAddress, UserGroup, DistributionGroup, SharedDriveAccess, Permissions, iPad, Mouse, Sales, Salesforce, iPhone, Laptopb, Marketing, VPN, Laptop, Dphone, General, Terminal, Printerw, CAD, Printerh, Dongle, Finance, Monitor, Mifi, Accounts, Keyboard, Pemail, Replacement, NewUser, AddRequirements) VALUES ('$RequestBy', '$FirstName', '$MiddleName', '$LastName', '$Desktop', '$EmploymentType', '$GenderMale', '$GenderFemale', '$Department1', '$JobTitle', '$ManagerName', '$FullAddress', '$UserGroup', '$DistributionGroup', '$SharedDriveAccess', '$Permissions', '$iPad', '$Mouse', '$Sales', '$Salesforce', '$iPhone', '$Laptopb', '$Marketing', '$VPN', '$Laptop', '$Dphone', '$General', '$Terminal', '$Printerw', '$CAD', '$Printerh', '$Dongle', '$Finance', '$Monitor', '$Mifi', '$Accounts', '$Keyboard', '$Pemail', '$Replacement', '$NewUser', '$AddRequirements');";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
?>
&#13;
基本上我想创建另一个页面,我可以在其中选择用户的名称,单击某个按钮,然后查看所有信息,例如访问&#34; sales&#34;显示驱动器,性别等。
忽略代码中缺乏安全措施,它将由极少数和值得信赖的人在本地服务器上使用。
如果有人可以指导我走上正确的道路,那么我们将非常感激。先感谢您。
答案 0 :(得分:0)
似乎需要一些AJAX才能实现这一目标。
首先,您需要创建包含选择框的php
文件。请注意,您必须在html中包含jquery。
在select_user.php
<?php
//Connection to database
$connection = mysqli_connect('localhost', 'root', 'your_password', 'your_database');
mysqli_set_charset($connection, 'utf8');
if (!$connection) {
die("Database connection failed: " . mysqli_error());
}
//Simple query to populate the select box
$query = "SELECT id, FirstName, LastName FROM TestTable ORDER BY FirstName ASC, LastName ASC, id ASC;";
$result = mysqli_query($connection, $query);
if (mysqli_num_rows($result) > 0) { //If there are records in database table
echo '<select id="user" name="user">';
while ($row = mysqli_fetch_array($result)) {
echo '<option value="'.$row['id'].'">'.$row['FirstName'].' '.$row['LastName'].'</option>';
}
echo '</select>';
} else {
echo '<p class="alert">There are no data to select from.</p>';
}
?>
<div id="results">
</div>
然后你必须编写一些AJAX,要求服务器获取具有所选id的用户(请注意,通常你必须非常小心用户输入)。
在select_user.php
<script>
$(document).ready(function(){
//Each time that the value of select box changes then make an ajax call and bring the user details
$('#user').on('change', function() {
var id = $(this).val();
$.ajax({
async: false,
url: "ajax.php",
type: "POST",
data: {id : id},
dataType: "json",
success: function(data) {
//Check if data is empty or make some other validations
var firstName = data.FirstName;
var lastName = data.LastName;
var fullAddress = data.FullAddress;
var permissions = data.Permissions;
var str = '<p>Name: '+firstName+' '+lastName+' '+fullAddress+' '+permissions+'</p>';
//Replace content at #results div
$('#results').innerHtml(str);
}
});
}
}
</script>
最后,您必须创建文件ajax.php
,其中包含带回所选用户详细信息的查询。
在档案ajax.php
<?php
//This is ajax.php
//Connection to database
$connection = mysqli_connect('localhost', 'root', 'your_password', 'your_database');
mysqli_set_charset($connection, 'utf8');
if (!$connection) {
die("Database connection failed: " . mysqli_error());
}
$id = $_POST['id'];
//Never trust input from users
//Sanitize and validate variables
//Use prepared statemends or PDO
$query = "SELECT id, FirstName, LastName, FullAddress, Permissions FROM TestTable WHERE id = '$id';";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_array($result);
$json['id'] = $row['id'];
$json['firstName'] = $row['FirstName'];
$json['lastName'] = $row['LastName'];
$json['fullAddress'] = $row['FullAddress'];
$json['permisions'] = $row['Permissions'];
echo json_encode($json);
mysqli_close($connection);
?>
答案 1 :(得分:0)
这是select_user.php
文件:
<?php
//Connection to database
$connection = mysqli_connect("****","****","****", "***");
mysqli_set_charset($connection, 'utf8');
if (!$connection) {
die("Database connection failed: " . mysqli_error());
}
//Simple query to populate the select box
$query = "SELECT id, FirstName, LastName FROM TestTable ORDER BY FirstName ASC, LastName ASC, id ASC;";
$result = mysqli_query($connection, $query);
if (mysqli_num_rows($result) > 0) { //If there are records in database table
echo '<select id="user" name="user">';
while ($row = mysqli_fetch_array($result)) {
echo '<option value="'.$row['id'].'">'.$row['FirstName'].' '.$row['LastName'].'</option>';
}
echo '</select>';
} else {
echo '<p class="alert">There are no data to select from.</p>';
}
?>
<div id="results">
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
$(document).ready(function(){
//Each time that the value of select box changes then make an ajax call and bring the user details
$('#user').on('change', function() {
var id = $(this).val();
$.ajax({
async: false,
url: "ajax.php", //Tried changing this to domainname.com/ajax.php but that didn't change anything.
type: "POST",
data: {id : id},
dataType: "json",
success: function(data) {
//Check if data is empty or make some other validations
var firstName = data.FirstName;
var lastName = data.LastName;
var fullAddress = data.FullAddress;
var permissions = data.Permissions;
var str = '<p>Name: '+firstName+' '+lastName+' '+fullAddress+' '+permissions+'</p>';
//Replace content at #results div
$('#results').innerHtml(str);
}
});
}
}
</script>
<div id="results">
</div>
这是ajax.php
:
<?php
//This is ajax.php
//Connection to database
$connection = mysqli_connect("******","******","*******", "*******");
mysqli_set_charset($connection, 'utf8');
if (!$connection) {
die("Database connection failed: " . mysqli_error());
}
$id = $_POST['id'];
//Never trust input from users
//Sanitize and validate variables
//Use prepared statemends or PDO
$query = "SELECT id, FirstName, LastName, FullAddress, Permissions FROM TestTable WHERE id = '$id';";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_array($result);
$json['id'] = $row['id'];
$json['firstName'] = $row['FirstName'];
$json['lastName'] = $row['LastName'];
$json['fullAddress'] = $row['FullAddress'];
$json['permisions'] = $row['Permissions'];
echo json_encode($json);
mysqli_close($connection);
?>
这是HTML。
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<meta charset="utf-8">
<title>Untitled D
<!--#include file="NewUser_get.php" -->
ocument</title>
<link href="Untitled-4.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--<div id="body1">-->
<div id="wrapper">
<div id="head">
<center>
<img src="http://www.rwc.com/wp-content/themes/RWC_Global/assets/images/logo.png">
</center>
<form action="NewUser_get.php" method="POST">
<table style="width:1000px">
<tr>
<td width=90%>
<f>Request date:</f>
<br>
<input type="date" name="RequestDate">
</td>
<td width=10%>
<f>Requested by:</f>
<br>
<input type="text" style="width: 166px;" name="RequestBy">
</td>
</tr>
</table>
<br>
<div id="colour">
<info>
<center>New User Info</center>
</info>
</div>
<br>
<table style="width:100%">
<tr>
<td>
<f>Employee's last name: </f>
<input type="text" placeholder="Click to type" name="LastName">
</td>
<td>
<f>First name
<input type="text" placeholder="Click to type" name="FirstName">
</td>
<td>
<f>Middle name
<input type="text" placeholder="Click to type" name="MiddleName">
</td>
<td>
<f>Employment type
<select name="EmploymentType">
<option value="Permanent">Permanent</option>
<option value="Temporary">Temporary</option>
<option value="Contractor">Contractor</option>
<option value="Placement">Placement</option>
<option value="Other">Other</option>
</select>
</td>
<td width="80px">
<f> Gender</f>
<br>
<label for="GenderMale">
<input type="checkbox" name="GenderMale" value="Yes" /> <span>M</span>
</label>
<label for="GenderFemale">
<input type="checkbox" name="GenderFemale" value="Yes" /> <span>F</span>
</label>
</td>
</tr>
<tr>
<td>
<f>Department </f>
<br>
<input type="text" placeholder="Click to type" name="Department1">
</td>
<td>
<f>Job title </f>
<input type="text" placeholder="Click to type" name="JobTitle">
</td>
<td>
<f>Manager's name </f>
<input type="text" placeholder="Click to type" name="ManagerName">
</td>
<td>
<f>Start date </f>
<br>
<input type="date" placeholder="Click to type" name="StartDate">
</td>
<td>
<f>Finish date </f>
<input type="date" style="width: 166px;" name="FinishDate">
</td>
</tr>
</table>
<br>
<table style="width:100%">
<tr>
<td>
<f>Full address:</f>
<br>
<input type="text" style="width: 992px;" placeholder="Click to type, Address/ P.O. Box, City, Street, Post code" name="FullAddress">
</td>
</tr>
</table>
<br>
<table style="width:100%">
<tr>
<td>
<f>User Group / Profile to Use:</f>
<input type="text" style="width: 325px;" placeholder="Click to type, e.g. same as John, Accounts" name="UserGroup">
</td>
<td>
<f>Distribution Groups to be included:</f>
<input type="text" style="width: 325px;" placeholder="Click to type, e.g. Staff, Internal, External" name="DistributionGroup">
</td>
<td>
<f>Shared Drive Access:</f>
<input type="text" style="width: 325px;" placeholder="Click to type" name="SharedDriveAccess">
</td>
</tr>
</table>
<br>
<table style="width:100%">
<tr>
<td>
<f>Permissions on shared drives (in detail):</f>
<br>
<input type="text" style="width: 993px;" placeholder="Click to type, e.g. Marketing drive 'read only, Technical drive 'Full Access'" name="Permissions">
</td>
</tr>
</table>
<br>
<div id="colour">
<info>
<center>Additional Info</center>
</info>
</div>
<br>
<div class="checkboxes">
<table style="width:100%">
<tr>
<td width="%50">
<bigbold>List of required items (Tick the box next to an item):</bigbold>
</td>
<td> </td>
<td class="td-left" width="%50">
<bigbold>List of required software/drive access:</bigbold>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td class="td-left">
<info> Drives:</info>
</td>
<td>
<info> Software:</info>
</td>
</tr>
<tr>
<td>
<label for="iPad">
<input type="checkbox" name="iPad" value="Yes"> <span><f>iPad + case</f></span>
</label>
</td>
<td>
<label for="Mouse">
<input type="checkbox" name="Mouse" value="Yes"> <span><f>Mouse</f></span>
</label>
</td>
<td class="td-left">
<label for="Sales">
<input type="checkbox" name="Sales" value="Yes"><span><f>Sales</f></span>
</label>
</td>
<td>
<label for="Salesforce">
<input type="checkbox" name="Salesforce" value="Yes"> <span><f>Salesforce</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="iPhone">
<input type="checkbox" name="iPhone" value="Yes"> <span><f>iPhone + case</f></span>
</label>
</td>
<td>
<label for="Laptopb">
<input type="checkbox" name="Laptopb" value="Yes"> <span><f>Laptop bag</f></span>
</label>
</td>
<td class="td-left">
<label for="Marketing">
<input type="checkbox" name="Marketing" value="Yes"> <span><f>Marketing</f></span>
</label>
</td>
<td>
<label for="VPN">
<input type="checkbox" name="VPN" value="Yes"> <span><f>VPN</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Laptop">
<input type="checkbox" name="Laptop" value="Yes"> <span><f>Laptop</f></span>
</label>
</td>
<td>
<label for="Dphone">
<input type="checkbox" name="Dphone" value="Yes"> <span><f>Desk phone</f></span>
</label>
</td>
<td class="td-left">
<label for="General">
<input type="checkbox" name="General" value="Yes"> <span><f>General</f></span>
</label>
</td>
<td>
<label for="Terminal">
<input type="checkbox" name="Terminal" value="Yes"> <span><f>Terminal server</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Desktop">
<input type="checkbox" name="Desktop" value="Yes" /> <span><f>Desktop</f></span>
</label>
</td>
<td>
<label for="Printerw">
<input type="checkbox" name="Printerw" value="Yes"> <span><f>Printer (work)</f></span>
</label>
</td>
<td class="td-left">
<label for="CAD">
<input type="checkbox" name="CAD" value="Yes"> <span><f>CAD</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Printerh">
<input type="checkbox" name="Printerh" value="Yes"> <span><f>Printer (home)</f></span>
</label>
</td>
<td>
<label for="Dongle">
<input type="checkbox" name="Dongle" value="Yes"> <span><f>Dongle</f></span>
</label>
</td>
<td class="td-left">
<label for="Finance">
<input type="checkbox" name="Finance" value="Yes"> <span><f>Finance</f></span>
</label>
</td>
</tr>
<tr>
<td>
<label for="Monitor">
<input type="checkbox" name="Monitor" value="Yes"> <span><f>Monitor</f></span>
</label>
</td>
<td>
<label for="MiFi">
<input type="checkbox" name="Mifi" value="Yes"> <span><f>MiFi (Mobile Wifi)</f></span>
</label>
</td>
<td class="td-left">
<label for="Accounts">
<input type="checkbox" name="Accounts" value="Yes"> <span><f>Accounts</f></span>
</label>
</td>
<td></td>
</tr>
<tr>
<td>
<label for="Keyboard">
<input type="checkbox" name="Keyboard" value="Yes"> <span><f>Keyboard</f></span>
</label>
</td>
<td></td>
<td class="td-left"></td>
<td></td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</table>
<div id="colour">
<center>
<info>Miscellaneous:</info>
</center>
</div>
<br>
<table style="width:100%">
<tr>
<td>
<f>Should the predecessor's email be assigned to this user?</f>
</td>
<td>
<label for="Pemail">
<input type="checkbox" name="Pemail" value="Yes"> <span><f>Yes</f></span>
</label>
</td>
</tr>
<tr class="tr-top">
<td>
<f>Is the user replacing someone else from the staff or is he/she a completely new employee?</f>
</td>
<td>
<label for="Replacement">
<input type="checkbox" name="Replacement" value="Yes"> <span><f>Replacement</f></span>
</label>
</td>
<td>
<label for="NewUser">
<input type="checkbox" name="NewUser" value="Yes"> <span><f>New user</f></span>
</label>
</td>
</tr>
</table>
<br>
<textarea name="AddRequirements" style="width:1000px;" placeholder="Please continue here for any other extra requirements e.g. need of a special signature, software, hardware etc. or needed access to another user’s files and documents, or assign another user’s email profile to this user so they inherit all files and folders form the old user."></textarea>
<!--<input type='hidden' name='articleid' id='articleid' value='<? echo $_GET["id"]; ?>' /> -->
<input type="submit">
</form>
</div>
</div>
</body>
</html>
对不起,迟到的回复,有点陷入困境。感谢所有的帮助,感觉就像我现在做不了多少,因为我真的无法理解问题所在。
答案 2 :(得分:0)
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<?php
//Connection to database
$connection = mysqli_connect("*****************","***********","****", "******");
mysqli_set_charset($connection, 'utf8');
if (!$connection) {
die("Database connection failed: " . mysqli_error());
}
//Simple query to populate the select box
$query = "SELECT id, FirstName, LastName FROM TestTable ORDER BY FirstName ASC, LastName ASC, id ASC;";
$result = mysqli_query($connection, $query);
if (mysqli_num_rows($result) > 0) { //If there are records in database table
echo '<select id="user" name="user">';
while ($row = mysqli_fetch_array($result)) {
echo '<option value="'.$row['id'].'">'.$row['FirstName'].' '.$row['LastName'].'</option>';
}
echo '</select>';
} else {
echo '<p class="alert">There are no data to select from.</p>';
}
?>
<div id="results">
</div>
<script>
$(document).ready(function(){
//Each time that the value of select box changes then make an ajax call and bring the user details
$('#user').on('change', function() {
var id = $(this).val();
$.ajax({
async: false,
url: "ajax.php",
type: "POST",
data: {id : id},
dataType: "json",
success: function(data) {
//Check if data is empty or make some other validations
var firstName = data.FirstName;
var lastName = data.LastName;
var fullAddress = data.FullAddress;
var permissions = data.Permissions;
var str = '<p>Name: '+firstName+' '+lastName+' '+fullAddress+' '+permissions+'</p>';
//Replace content at #results div
$('#results').innerHtml(str);
}
});
}
}
</script>
<div id="results">
</div>