我有一个包含大约 100 个输入的表单,我将其发送到 php 文件以提交数据。我正在尝试找到对提交文件进行编码的最佳方法,而我不必对每个帖子值进行编码。
<?php
/*
UserFrosting Version: 0.2.0
By Alex Weissman
Copyright (c) 2014
Based on the UserCake user management system, v2.0.2.
Copyright (c) 2009-2012
UserFrosting, like UserCake, is 100% free and open-source.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
require_once("../models/config.php");
if (!securePage(__FILE__)) {
// Forward to index page
addAlert("danger", "Whoops, looks like you don't have permission to view that page.");
header("Location: 404.php");
exit();
}
setReferralPage(getAbsoluteDocumentPath(__FILE__));
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Life Medical Response Dashboard</title>
<?php require_once("includes.php"); ?>
</head>
<body>
<div id="wrapper">
<!-- Sidebar -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
</nav>
<div id="page-wrapper">
<div class="row">
<div id='display-alerts' class="col-lg-12">
</div>
</div>
<div class="row">
<div class="col-lg-12">
<h1>Dashboard <small>User Overview</small></h1>
<ol class="breadcrumb">
<li class="active"><i class="fa fa-dashboard"></i> Dashboard</li>
</ol>
</div>
</div><!-- /.row -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-ambulance"></i> Options </h3>
</div>
<div class="panel-body">
<a class="btn btn-primary" href="add_stock.php" role="button">Request Stock</a>
<a class="btn btn-primary" href="remove_stock.php" role="button">Remove Stock</a>
</div>
</div>
</div>
</div><!-- /.row -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-medkit"></i> Supplies </h3>
</div>
<div class="panel-body">
<div class="col-lg-6">
Date
</div>
<div class="col-lg-6">
Station
</div>
<div class="col-lg-6">
<form action="supply_request_submit.php">
<input type="date" class="form-control" id="date" >
</div>
<div class="col-lg-6">
<select class="form-control">
<?php
include 'connection.php';
$station = "SELECT * FROM stations";
$result_station = mysql_query($station);
while ($row_station = mysql_fetch_array($result_station)) {
;
?>
<option value="<?php echo $row_station['id'] ?>"><?php echo $row_station['station'] ?></option>
<?php }?>
</select>
</div>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Airway Supplies
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
<?php
include 'connection.php';
$airway_supplies = "SELECT * FROM supplies WHERE category = 2";
$result_airway_supplies = mysql_query($airway_supplies);
while ($row_airway_supplies = mysql_fetch_array($result_airway_supplies)) {
;
?>
<div class="col-md-2">
<?php echo $row_airway_supplies['name'] ?>
</div>
<div class="col-md-2">
<label class="sr-only" for="stock_<?php echo $row_airway_supplies['id'] ?>" form="supply">"></label>
<div class="input-group">
<div class="input-group-addon">Stock</div>
<input type="text" class="form-control" id="stock_<?php echo $row_airway_supplies['id'] ?>" form="supply" >
</div>
</div>
<div class="col-md-2">
<label class="sr-only" for="request_<?php echo $row_airway_supplies['id'] ?>" form="supply">Amount (in dollars)</label>
<div class="input-group">
<div class="input-group-addon">Request</div>
<input type="text" class="form-control" id="request_<?php echo $row_airway_supplies['id'] ?>" form="supply" >
</div>
</div>
<?php } ?>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
Trauma Equipment
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
<?php
include 'connection.php';
$airway_supplies = "SELECT * FROM supplies WHERE category = 3";
$result_airway_supplies = mysql_query($airway_supplies);
while ($row_airway_supplies = mysql_fetch_array($result_airway_supplies)) {
;
?>
<div class="col-md-2">
<?php echo $row_airway_supplies['name'] ?>
</div>
<div class="col-md-2">
<label class="sr-only" for="stock_<?php echo $row_airway_supplies['id'] ?>" form="supply">Amount (in dollars)</label>
<div class="input-group">
<div class="input-group-addon">Stock</div>
<input type="text" class="form-control" id="stock_<?php echo $row_airway_supplies['id'] ?>" form="supply">
</div>
</div>
<div class="col-md-2">
<label class="sr-only" for="request_<?php echo $row_airway_supplies['id'] ?>"></label>
<div class="input-group">
<div class="input-group-addon">Request</div>
<input type="text" class="form-control" id="request_<?php echo $row_airway_supplies['id'] ?>" form="supply">
</div>
</div>
<?php } ?>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingThree">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
IV / Medication Administration
</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
<div class="panel-body">
<?php
include 'connection.php';
$airway_supplies = "SELECT * FROM supplies WHERE category = 4";
$result_airway_supplies = mysql_query($airway_supplies);
while ($row_airway_supplies = mysql_fetch_array($result_airway_supplies)) {
;
?>
<div class="col-md-2">
<?php echo $row_airway_supplies['name'] ?>
</div>
<div class="col-md-2">
<label class="sr-only" for="stock_<?php echo $row_airway_supplies['id'] ?>" form="supply"></label>
<div class="input-group">
<div class="input-group-addon">Stock</div>
<input type="text" class="form-control" id="stock_<?php echo $row_airway_supplies['id'] ?>" form="supply">
</div>
</div>
<div class="col-md-2">
<label class="sr-only" for="request_<?php echo $row_airway_supplies['id'] ?>" form="supply"></label>
<div class="input-group">
<div class="input-group-addon">Request</div>
<input type="text" class="form-control" id="request_<?php echo $row_airway_supplies['id'] ?>" form="supply">
</div>
</div>
<?php } ?>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingFour">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseFour" aria-expanded="false" aria-controls="collapseFour">
Miscellaneous Items
</a>
</h4>
</div>
<div id="collapseFour" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingFour">
<div class="panel-body">
<?php
include 'connection.php';
$airway_supplies = "SELECT * FROM supplies WHERE category = 5";
$result_airway_supplies = mysql_query($airway_supplies);
while ($row_airway_supplies = mysql_fetch_array($result_airway_supplies)) {
;
?>
<div class="col-md-2">
<?php echo $row_airway_supplies['name'] ?>
</div>
<div class="col-md-2">
<label class="sr-only" for="stock_<?php echo $row_airway_supplies['id'] ?>" form="supply"></label>
<div class="input-group">
<div class="input-group-addon">Stock</div>
<input type="text" class="form-control" id="stock_<?php echo $row_airway_supplies['id'] ?>" form="supply">
</div>
</div>
<div class="col-md-2">
<label class="sr-only" for="request_<?php echo $row_airway_supplies['id'] ?>" form="supply"></label>
<div class="input-group">
<div class="input-group-addon">Request</div>
<input type="text" class="form-control" id="request_<?php echo $row_airway_supplies['id'] ?>" form="supply">
</div>
</div>
<?php } ?>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingFive">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseFive" aria-expanded="false" aria-controls="collapseFive">
Vital Sign Equipment
</a>
</h4>
</div>
<div id="collapseFive" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingFive">
<div class="panel-body">
<?php
include 'connection.php';
$airway_supplies = "SELECT * FROM supplies WHERE category = 6";
$result_airway_supplies = mysql_query($airway_supplies);
while ($row_airway_supplies = mysql_fetch_array($result_airway_supplies)) {
;
?>
<div class="col-md-2">
<?php echo $row_airway_supplies['name'] ?>
</div>
<div class="col-md-2">
<label class="sr-only" for="stock_<?php echo $row_airway_supplies['id'] ?>" form="supply"></label>
<div class="input-group">
<div class="input-group-addon">Stock</div>
<input type="text" class="form-control" id="stock_<?php echo $row_airway_supplies['id'] ?>" form="supply">
</div>
</div>
<div class="col-md-2">
<label class="sr-only" for="request_<?php echo $row_airway_supplies['id'] ?>" form="supply"></label>
<div class="input-group">
<div class="input-group-addon">Request</div>
<input type="text" class="form-control" id="request_<?php echo $row_airway_supplies['id'] ?>" form="supply">
</div>
</div>
<?php } ?>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingSix">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseSix" aria-expanded="false" aria-controls="collapseSix">
Splinting Equipment
</a>
</h4>
</div>
<div id="collapseSix" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingSix">
<div class="panel-body">
<?php
include 'connection.php';
$airway_supplies = "SELECT * FROM supplies WHERE category = 7";
$result_airway_supplies = mysql_query($airway_supplies);
while ($row_airway_supplies = mysql_fetch_array($result_airway_supplies)) {
;
?>
<div class="col-md-2">
<?php echo $row_airway_supplies['name'] ?>
</div>
<div class="col-md-2">
<label class="sr-only" for="stock_<?php echo $row_airway_supplies['id'] ?>"></label>
<div class="input-group">
<div class="input-group-addon">Stock</div>
<input type="text" class="form-control" id="stock_<?php echo $row_airway_supplies['id'] ?>" form="supply">
</div>
</div>
<div class="col-md-2">
<label class="sr-only" for="request_<?php echo $row_airway_supplies['id'] ?>"></label>
<div class="input-group">
<div class="input-group-addon">Request</div>
<input type="text" class="form-control" id="request_<?php echo $row_airway_supplies['id'] ?>" form="supply">
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</ul>
</div>
</div>
<div> <input type="submit" class="btn btn-primary" value="Submit" form="supply"></div>
</div>
</div><!-- /.row -->
</div><!-- /#page-wrapper -->
</div><!-- /#wrapper -->
<script>
$(document).ready(function () {
alertWidget('display-alerts');
// Load the header
$('.navbar').load('header.php', function () {
$('.navitem-dashboard').addClass('active');
});
});
</script>
</body>
</html>
<?php
$date = $_POST['date'];
$station = $_POST['station']
?>
<?php
include 'connection.php';
$supplies = "SELECT * FROM supplies";
$result_supplies = mysql_query($supplies);
while ($row_supplies = mysql_fetch_array($result_supplies)) {
;
}
?>