设置变量并在start.php
中正确显示所有内容。我可以在表单中的两个显示变量之间进行选择。
问题是:选中并且提交表单后,变量$projektcheck
或$projektcheckk
不会传递给nxtfile.php
。当我使用print($_POST['prjkttype']);
检查时,变量未定义且没有任何内容被打印。它会立即切换到我的echo"Data is wrong";
为什么它没有被传递到另一个文件,虽然它被设置和选择?
start.php:
<?PHP
session_start();
$projektcheck = $_SESSION['projektname'];
$projektcheckk = $_SESSION['projektnamee'];
?>
[other codestuff]
<script>
function validateForm() {
var fields = ['prjkttype']
var i, l = fields.length;
var fieldname;
for (i = 0; i < l; i++) {
fieldname = fields[i];
}
f1.method="POST";
f1.submit();
}
</script>
[other codestuff]
<form action="nxtfile.php" method="POST" name="f1">
<select class="selectstyle" name="prjkttype" form="submit">
<?PHP
if (isset($projektcheck)) {
echo"<option value='1'>$projektcheck </option>";
} else {
}
if (isset($projektcheckk)) {
echo"<option value='2'>$projektcheckk </option>";
} else {
}
?>
</select>
<input type=button name=s1 value="Insert" onClick="validateForm()">
</form>
[other codestuff]
nxtfile.php:
<?PHP
session_start();
include ("../connection.php");
$prjkttype=$_POST['prjkttype'];
print($_POST['prjkttype']);
$checkindb="SELECT * FROM projekte WHERE (projektname = '$prjkttype' )";
$dbcheckk=mysqli_query($con ,$checkindb);
$dbcheckedd=mysqli_fetch_array($dbcheckk);
if($dbcheckedd > 0){
header ("Location: xy.php");
} else {
echo "Data is wrong.";
}
?>
答案 0 :(得分:1)
您需要将值设置为您的变量,如下所示。它将传递值而不是变量。这将有效:
<template name="OneInvoice">
<p>Invoice id: {{invoice._id}}</p>
<p>Invoice total: {{invoice.total}}</p>
{{#let company=(loadCompany invoice.companyId)}}
<p>Company name: {{company.name}}</p>
<p>Company business address: {{company.businessAddress}}</p>
{{/let}}
</template>