美好的一天
我有一个表单从前一个帖子获取案例ID,然后我用它做一个选择,所有工作100%
然后我让他们填写数据并上传文件。好的,所有的帖子应该期待caseid !!!!以下代码。
<!---<input type="submit" value="Submit">-->
<?php
require_once("../models/config.php");
if(isUserLoggedIn()) {
if (!securePage($_SERVER['PHP_SELF'])){die();}
require_once("../models/header.php");
echo "<link href='../models/site-templates/default.css' rel='stylesheet' type='text/css' />";
//$servername = "***.****.***.***";
$servername = "***.****.***.***.****";
$username = "202";
$password = "202@202";
$dbname = "*********";
$caseid = $_REQUEST['caseid'];
echo "
<body>
<div id='wrapper'>
<div id='top'><div id='logo'></div></div>
<div id='content'>
<h1>Cases</h1>
<div id='left-nav'>";
include("../left-nav.php");
echo "</div><div id='main'>";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "
SELECT
id
, case_number
, date_entered
, name
, STATUS
, description
, cust_phone_no
, claim_number_c
, contactname_c
, contact_type_c
, telephonehome_c
, telephonebusiness_c
, telephonemobile_c
, policynumber_c
, billing_address_street
, billing_address_city
, billing_address_state
, billing_address_postalcode
, billing_address_country
, customer_name
FROM
*******.sp_case_view
where id = '$caseid'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$caseid = $row["id"];
$case_number = $row["case_number"];
$date_entered = $row["date_entered"];
$name = $row["name"];
$status = $row["STATUS"];
$description = $row["description"];
$cust_phone_no = $row["cust_phone_no"];
$claim_number_c = $row["claim_number_c"];
$contactname_c = $row["contactname_c"];
$contact_type_c = $row["contact_type_c"];
$telephonehome_c = $row["telephonehome_c"];
$telephonebusiness_c = $row["telephonebusiness_c"];
$telephonemobile_c = $row["telephonemobile_c"];
$policynumber_c = $row["policynumber_c"];
$billing_address_street = $row["billing_address_street"];
$billing_address_city = $row["billing_address_city"];
$billing_address_state = $row["billing_address_state"];
$billing_address_postalcode = $row["billing_address_postalcode"];
$billing_address_country = $row["billing_address_country"];
$customer_name = $row["customer_name"];
echo "<a href='cases.php'><b>Back to Cases</b></a><br><br>";
echo "Customer Name: " . $customer_name ."<br>";
echo "<br>";
echo "Case Number: " . $case_number ."<br>";
echo "Created On: " . $date_entered ."<br>";
echo "<br>";
echo "Description: " . $description ."<br>";
echo "Phone Number: " . $cust_phone_no ."<br>";
echo "Claim Number: " . $claim_number_c ."<br>";
echo "Contact Person: " . $contactname_c ."<br>";echo "<br>";
echo "Address Details: <br>";
echo "Street: " . $billing_address_street ."<br>";
echo "City: " . $billing_address_city ."<br>";
echo "Province: " . $billing_address_state ."<br>";
//echo "Name: <input type='text' value='" . $description . "'><br>";
}
$up_id = uniqid();
require_once("../models/footer.php");
$conn->close();
}
else {
header('location: ../login.php');
}
$full_path = "c:/scott/source/";
$number_of_uploads = 4;
$allowed_file_types = array("jpg","gif","png","txt","zip","xls","doc","docx","xlsx","txt","pdf");
$upload_folder = "./uploads/";
$max_size_in_kb = 10000024;
$rename_files = 1;
echo $caseid;
function printForm()
{
global $allowed_file_types,$number_of_uploads,$max_size_in_kb;
print "<html>
<head>
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
<title></title>
<meta name='description' content='' />
<meta http-equiv='Language' content='en' />
<meta name='language' content='en' />
<!--Progress Bar and iframe Styling-->
</head>
<body>
<br><b>Enter your closure details</b>
<!--<form action='upload.php' method='post'> -->
<form enctype='multipart/form-data' action='upload.php' method='post' name='upload-form' id='upload-form'>
<table>
<tr><td>Plumber Cost including vat: </td><td><input type='text' name='plumcost'></td></tr>
<tr><td>Enter description of work done: </td><td><input type='textarea' name='descrepair'></td></tr>
<tr>
<td>Old Geyser Make: </td><td><input type='text' name='geyserold'> </td>
</tr>
<tr>
<td>Old Geyser Serial Number: </td><td><input type='text' name='geyseroldserial'> </td>
</tr>
<tr>
<td>New Geyser Serial Number: </td><td><input type='text' name='geysernew'> </td>
</tr>
</table>
\n";
for($i=0;$i<$number_of_uploads;$i++)
{
if($i == '0') {
echo "Invoice";
}
elseif($i == '1') {
echo "POD";
}
elseif($i == '2') {
echo "Stocksheet";
}
elseif($i == '3') {
echo "Pictures Zipped";
}
print "<p><input type=\"file\" name=\"file[]\" /></p>\n";
}
print "<p><input type=\"hidden\" name=\"upload\" value=\"1\" /><input type=\"submit\" value=\"Upload\" /></p>\n</form>\n";
print "<p>Allowed file types: ." . implode($allowed_file_types, " ."). "</p>\n";
}
$fileNAMES = array();
if(isset($_POST['upload']))
{
for($i=0;$i<$number_of_uploads;$i++)
{
if(strlen($_FILES['file']['name'][$i]) > 0)
{
$filearray = explode(".", $_FILES['file']['name'][$i]);
$ext = end($filearray);
if($rename_files == 1)
{
if($i==0)
{
$fileNAMES[$i] = $caseid."invoice";
}
if($i==1)
{
$fileNAMES[$i] = $caseid."stocksheet";
}
if($i==2)
{
$fileNAMES[$i] = $caseid."POD";
}
if($i==3)
{
$fileNAMES[$i] = $caseid."picture";
}
}
else
{
$xperiods = str_replace("." . $ext, "", $_FILES['file']['name'][$i]);
$fileNAMES[$i] = str_replace(".", "", $xperiods);
}
if(!in_array(strtolower($ext), $allowed_file_types))
{
print "<p class=\"error\">FAILED: ". htmlspecialchars($_FILES['file']['name'][$i]) ."<br />ERROR: File type not allowed.</p>\n";
}
elseif($_FILES['file']['size'][$i] > ($max_size_in_kb*1024))
{
print "<p class=\"error\">FAILED: ". htmlspecialchars($_FILES['file']['name'][$i]) ."<br />ERROR: File size to large.</p>\n";
}
elseif(file_exists($upload_folder.$fileNAMES[$i] .".". $ext))
{
print "<p class=\"error\">FAILED: ". htmlspecialchars($fileNAMES[$i]) .".". $ext ."<br />ERROR: File already exists.</p>\n";
}
else
{
if(move_uploaded_file($_FILES['file']['tmp_name'][$i], $upload_folder.$fileNAMES[$i] .".". $ext))
{
print "<p>UPLOADED: ". htmlspecialchars($fileNAMES[$i]) .".". $ext ."</p>\n";
}
else
{
print "<p class=\"error\">FAILED: ". htmlspecialchars($_FILES['file']['name'][$i]) ."<br />ERROR: Undetermined.</p>\n";
}
}
}
}
printForm();
}
else
{
printForm();
}
?>
</form>
</div></body>
</html>
<?php } else {
echo "0 results";
echo $caseid;
} ?>