好的,这是交易:
<form enctype="multipart/form-data" class="pdfsub" id="pdfsub" action="" method="post">
<td>
<p>Agent Name:<input type="text" name="agentname" id="agentname" /></p>
<p>Description: <textarea cols="75" rows="10" draggable="false" name="desc" value="desc">
</textarea></p>
</td>
<td>
<p>Current Date: <input type="date" name="date" value="date" /></p>
<p> Document Name: <select name="pdf" id="pdf" class="pdf" value="pdf">
<option></option>
<?php
$x=0;
if ($handle = opendir('Users/'.$_SESSION['username'].'/uploaded/')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
echo "<option value=".$entry.">$entry\n</option>";
}
}
closedir($handle);
}
?>
</select></p>
<p>Processed: <input type="checkbox" name="options[]" onclick="checkSubmit(this, 'mySubmit')" value="y" /> Incomplete: <input type="checkbox" name="options[]" onclick="checkSubmit(this, 'mySubmit')" value="y" /></p>
<input type="submit" name="submit" value="submit" id="mySubmit" disabled="disabled" />
</td>
</form>
</table>
<script type="text/javascript">
function checkSubmit(ele, id) {
x = document.getElementById(id);
if (ele.checked == true) x.disabled = false;
else x.disabled = true;
}
</script>
<?php
error_reporting(0);
if (isset($_post['submit']['processed']))
{
$checked = $_GET['options'];
for($i=0; $i < count($checked); $i++){
echo "Selected " . $checked[$i] . "<br/>";
}
$host = "host";
$user3 = "user";
$db_name= "dbname";
$pass= "pass";
$con = mysql_connect($host, $user3, $pass);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dbname", $con);
$agent=($_POST['agentname']);
$desc=($_POST['description']);
$date=($_POST['date']);
$pdf=($_POST['filename']);
$sql ="INSERT INTO `documets` (`agentname`, `description`, `date`, `filename`, `numb`) VALUES ('$agent', '$desc', '$date', '$pdf', '1')";
if (!mysql_query($sql,$con)) {
die('Error: ' . mysql_error());
}
mysql_close($con);
$srcfile= ('Users/'.$_SESSION['username'].'/uploaded/'.$pdf);
$dstfile= ('Users/'.$_SESSION['username'].'/processed/'.$pdf);
copy($srcfile, $dstfile);
unlink($srcfile);
}
?>
<?php
error_reporting(0);
if (isset($_post['submit']['incomplete']))
{
$host = "host";
$user3 = "user";
$db_name= "dbname";
$pass= "pass";
$con = mysql_connect($host, $user3, $pass);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dbname", $con);
$agent=($_POST['agentname']);
$desc=($_POST['description']);
$date=($_POST['date']);
$pdf=($_POST['filename']);
$sql ="INSERT INTO `documets` (`agentname`, `description`, `date`, `filename`, `numb`) VALUES ('$agent', '$desc', '$date', '$pdf', '1')";
if (!mysql_query($sql,$con)) {
die('Error: ' . mysql_error());
}
mysql_close($con);
$srcfile= ('Users/'.$_SESSION['username'].'/uploaded/'.$pdf);
$dstfile= ('Users/'.$_SESSION['username'].'/incomplete/'.$pdf);
copy($srcfile, $dstfile);
unlink($srcfile);
}
?>
我需要以某种方式将所有这些结合起来,以便根据选择的复选框是文件所在的位置,但数据仍会提交到数据库。截至目前,它也没有这样做,但这是一个简单的解决方法,我只需要正确的结构。