现在我真的很困惑,现在已经在这个问题上工作了几个小时,所以我想我会在这里发帖,也许会得到一些反馈。所以我有一个程序在一个文件上运行这个搜索工具。该文件来自生成到文件中的用户输入或实际上载文件的用户。我有2个提交按钮,第一个按钮用户生成的文件,第二个按钮用于上传文件的用户。
我遇到的问题是我有第二个提交按钮的相同的确切代码(所有更改是程序获取文件的方式)但由于某种原因,第二个提交按钮不起作用。不会生成任何内容,也不会执行搜索工具。我知道这是因为没有创建输出文件。
我想知道是否有人知道为什么我的第二个按钮不像第一个按钮那样......
这是我的代码......
<form method="POST", action="/~cs4380sp15grp4/home/blast.php" class="form-inline">
<textarea id="BlastSearch" type="textarea" name="BlastSearch" class="form-control">
Database:
<select id="database" name="database" class="form-control">
<option value="Archaea">Archaea</option>
</select>
Threshold:
<select id="evalue" name="evalue" class="form-control">
<option value="0.0001">0.0001</option>
<option value="0.001">0.001</option>
</select>
Hits:
<select id="hits" name="hits" class="form-control">
<option value="50">50</option>
<option value="100">100</option>
</select>
<button id="run" type="submit" name="submit" class="btn btn-primary"><span class="glyphicon glyphicon-wrench"></span> Run BLAST</button>
<button type="reset" value="Clear" class="btn btn-info">Clear</button>
</form>
<form enctype="multipart/form-data" action="upload.php" method="POST" class="form-inline"/>
<input type="file" name="fileToUpload" id="fileToUpload" class="form-control"/>
<input type="submit" value="upload" name="upload" class="form-control"/>
<input type="reset" value="reset" name="reset" class="form-control"/>
</form>
<form method="POST", action="/~cs4380sp15grp4/home/blast.php" class="form-inline">
<input type="submit" value="submit file" name="submit2" class="form-control"/>
</form>
<?php
//connects to db
//Insert the values into the database
if(isset($_POST['submit'])){
//declare variables to what the user defines them as
$db = $_POST['database'];
$evalue = $_POST['evalue'];
$sequence = $_POST['BlastSearch'];
$hits = $_POST['hits'];
//create a new .fasta file and put the sequence the user wants to search for in that file
$file = 'uploads/'.$mysqli->insert_id.'.fasta';
$header = ">gi|129295|sp|P01013|OVAX_CHICK GENE X PROTEIN (OVALBUMIN-RELATED)\n";
$current = $header . $_POST['BlastSearch'];
file_put_contents($file, $current);
$userid = $_SESSION['uid'];
//insert the values into the database
$mysqli->query("INSERT INTO `Job` (`uid`, `input`, `status`, `start_time`, `finish_time`) VALUES ('1', '" . $sequence . "', 'running' , NOW(), NOW())");
$mysqli->query("INSERT INTO `BLAST`(`db_name`, `evalue`, `job_id`) VALUES ('" . $db . "','" . $evalue . "', '".$mysqli->insert_id."')") or die(mysqli_error($mysqli));
//execute the BLAST Tool
// Do this execute statement if the user inputs his own sequence. (Use new.fasta)
exec('/students/groups/cs4380sp15grp4/blast/blast-2.2.26/bin/blastall -p blastp -d db -i /students/groups/cs4380sp15grp4/public_html/home/uploads/'.$mysqli->insert_id.'.fasta -m'.$evalue.' -o outputSEQ -v'.$hits.' -b'.$hits);
}
if(isset($_POST['submit2'])){
//declare variables to what the user defines them as
$db = $_POST['database'];
$evalue = $_POST['evalue'];
$sequence = $_POST['BlastSearch'];
$hits = $_POST['hits'];
$userid = $_SESSION['uid'];
//insert the values into the database
$mysqli->query("INSERT INTO `Job` (`uid`, `input`, `status`, `start_time`, `finish_time`) VALUES ('1', '" . $sequence . "', 'running' , NOW(), NOW())");
$mysqli->query("INSERT INTO `BLAST`(`db_name`, `evalue`, `job_id`) VALUES ('" . $db . "','" . $evalue . "', '".$mysqli->insert_id."')") or die(mysqli_error($mysqli));
exec('/students/groups/cs4380sp15grp4/blast/blast-2.2.26/bin/blastall -p blastp -d db -i /students/groups/cs4380sp15grp4/public_html/home/uploads/sample.fasta -m '.$evalue.' -o outputFILE -v'.$hits.' -b'.$hits);
}
$mysqli->close();
?>
我不明白。基本上exec函数在第一个提交按钮中工作,但是exec函数在第二个中不起作用...我可以进入终端并运行第二个exec函数,它运行得非常好。是因为第二次提交的动作是upload.php吗?我可以看到它......
EDIT1:我刚尝试专门为该按钮创建一个新表单,并使操作与第一个提交按钮表单相同。它没有工作:(任何帮助表示赞赏!
答案 0 :(得分:0)
您的代码中粘贴的问题很少。
textarea
没有结束标记。method="Post"
答案 1 :(得分:0)
在method = POST之后那个逗号应该存在吗?我实际上无法理解为什么它会产生任何影响,但它无法提供帮助。在页面上有多个表单当然是有效的,但有时候只有一个表单并且在多个&#39; normal&#39;后面使用Javascript更好。按钮设置enctype,方法,操作集和必需的默认值,然后以编程方式提交表单。
答案 2 :(得分:-1)
在相应的表单中提供以下隐藏的输入,以便在服务器端php获取$ _POST [&#39; submit&#39;]和$ _POST [&#39; submit2&#39;]:
<input type="hidden" value="1" name="submit" />
<input type="hidden" value="1" name="submit2" />
试试这个:
<form method="POST", action="/~cs4380sp15grp4/home/blast.php" class="form-inline">
<textarea id="BlastSearch" type="textarea" name="BlastSearch" class="form-control">
Database:
<select id="database" name="database" class="form-control">
<option value="Archaea">Archaea</option>
</select>
Threshold:
<select id="evalue" name="evalue" class="form-control">
<option value="0.0001">0.0001</option>
<option value="0.001">0.001</option>
</select>
Hits:
<select id="hits" name="hits" class="form-control">
<option value="50">50</option>
<option value="100">100</option>
</select>
<input type="hidden" value="1" name="submit" />
<button id="run" type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-wrench"></span> Run BLAST</button>
<button type="reset" value="Clear" class="btn btn-info">Clear</button>
</form>
<form enctype="multipart/form-data" action="upload.php" method="POST" class="form-inline"/>
<input type="file" name="fileToUpload" id="fileToUpload" class="form-control"/>
<input type="submit" value="upload" name="upload" class="form-control"/>
<input type="reset" value="reset" name="reset" class="form-control"/>
</form>
<form method="POST", action="/~cs4380sp15grp4/home/blast.php" class="form-inline">
<input type="hidden" value="1" name="submit2" />
<input type="submit" value="submit file" class="form-control"/>
</form>
<?php
//connects to db
//Insert the values into the database
if(isset($_POST['submit'])){
//declare variables to what the user defines them as
$db = $_POST['database'];
$evalue = $_POST['evalue'];
$sequence = $_POST['BlastSearch'];
$hits = $_POST['hits'];
//create a new .fasta file and put the sequence the user wants to search for in that file
$file = 'uploads/'.$mysqli->insert_id.'.fasta';
$header = ">gi|129295|sp|P01013|OVAX_CHICK GENE X PROTEIN (OVALBUMIN-RELATED)\n";
$current = $header . $_POST['BlastSearch'];
file_put_contents($file, $current);
$userid = $_SESSION['uid'];
//insert the values into the database
$mysqli->query("INSERT INTO `Job` (`uid`, `input`, `status`, `start_time`, `finish_time`) VALUES ('1', '" . $sequence . "', 'running' , NOW(), NOW())");
$mysqli->query("INSERT INTO `BLAST`(`db_name`, `evalue`, `job_id`) VALUES ('" . $db . "','" . $evalue . "', '".$mysqli->insert_id."')") or die(mysqli_error($mysqli));
//execute the BLAST Tool
// Do this execute statement if the user inputs his own sequence. (Use new.fasta)
exec('/students/groups/cs4380sp15grp4/blast/blast-2.2.26/bin/blastall -p blastp -d db -i /students/groups/cs4380sp15grp4/public_html/home/uploads/'.$mysqli->insert_id.'.fasta -m'.$evalue.' -o outputSEQ -v'.$hits.' -b'.$hits);
}
if(isset($_POST['submit2'])){
//declare variables to what the user defines them as
$db = $_POST['database'];
$evalue = $_POST['evalue'];
$sequence = $_POST['BlastSearch'];
$hits = $_POST['hits'];
$userid = $_SESSION['uid'];
//insert the values into the database
$mysqli->query("INSERT INTO `Job` (`uid`, `input`, `status`, `start_time`, `finish_time`) VALUES ('1', '" . $sequence . "', 'running' , NOW(), NOW())");
$mysqli->query("INSERT INTO `BLAST`(`db_name`, `evalue`, `job_id`) VALUES ('" . $db . "','" . $evalue . "', '".$mysqli->insert_id."')") or die(mysqli_error($mysqli));
exec('/students/groups/cs4380sp15grp4/blast/blast-2.2.26/bin/blastall -p blastp -d db -i /students/groups/cs4380sp15grp4/public_html/home/uploads/sample.fasta -m '.$evalue.' -o outputFILE -v'.$hits.' -b'.$hits);
}
$mysqli->close();
?>