Php 如果(isset($_POST[“提交”])不起作用
isset函数在此页上不起作用,但在另一页上起作用。 我想编辑我的数据库,这就是为什么我创建了这个,但我不能得到文本字段的值,因为isset不工作 这是密码Php 如果(isset($_POST[“提交”])不起作用,php,Php,isset函数在此页上不起作用,但在另一页上起作用。 我想编辑我的数据库,这就是为什么我创建了这个,但我不能得到文本字段的值,因为isset不工作 这是密码 <?php $link = mysqli_connect("localhost","root","","officedb"); if(!$link) { echo"Not connected"; } $query = "SELECT * from items"; $result = mysqli_query($l
<?php
$link = mysqli_connect("localhost","root","","officedb");
if(!$link)
{
echo"Not connected";
}
$query = "SELECT * from items";
$result = mysqli_query($link,$query);
if(!$result)
{
echo"Not selected";
}
if(isset($_POST["submit"])){
echo "Hello";
}
?>
<html>
<head>
<link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.min.css" >
<style>
.lb
{
background-color:#ADD8E6;
text-align: center;
}
.tl
{
text-align: center;
}
.disapp
{
display:none;
}
</style>
<script>
function divshow(){
if(document.getElementById("entryname").value == "Name")
{
document.getElementById("nameed").style.display = 'block';
document.getElementById("nsned").style.display = 'none';
document.getElementById("quned").style.display = 'none';
}
if(document.getElementById("entryname").value == "NSN/Part")
{
document.getElementById("nameed").style.display = 'none';
document.getElementById("nsned").style.display = 'block';
document.getElementById("quned").style.display = 'none';
}
if(document.getElementById("entryname").value == "Quantity")
{
document.getElementById("nameed").style.display = 'none';
document.getElementById("nsned").style.display = 'none';
document.getElementById("quned").style.display = 'block';
}
};
</script>
</head>
<body>
<div class="container">
<table class="table table-hover">
<tr>
<th class="lb" >Serial #</th>
<th class="lb" >Name</th>
<th class="lb" >NSN/part</th>
<th class="lb" >Quantity</th>
<?php
while($row = mysqli_fetch_array($result))
{
?>
<tr>
<td class="tl"><?php echo $row["S.NO"]; ?></td>
<td class="tl"><?php echo $row["Name"]; ?></td>
<td class="tl"><?php echo $row["NSN/Part"]; ?></td>
<td class="tl"><?php echo $row["Quantity"]; ?></td>
</tr>
<?php } ?>
</table>
<div class="border" style="border:1px solid grey;border-radius:6px;width:50%;margin-left:25%">
<div class="row" style="margin-top:7%;">
<div class="col-lg-4 col-lg-offset-3" style="margin-left:33%;">
<form method="POST">
<label>Select Item Serial #:</label>
<select class="form-control">
<?php
$sql = "SELECT * from items";
$newar=mysqli_query($link,$sql);
while($edit = mysqli_fetch_array($newar)){ ?>
<option value = <?php $edit[0]; ?> > <?php echo $edit[0]; } ?> </option>
</select>
<label style="margin-top:7%;">Select entry</label>
<select class="form-control" name="entryname" onchange="divshow()">
<option value="Name">Name</option>
<option value="NSN/Part">NSN/Part</option>
<option value="Quantity">Quantity</option>
</select>
<div id="nameed" >
<input type="text" placeholder="Enter New Name" class="form-control" required name="namtxt" style="margin-top:16%;" />
</div>
<div id="nsned" class="disapp" >
<input type="text" placeholder="Enter New NSN/Part" class="form-control" required name="nsntxt" style="margin-top:16%;" />
</div>
<div id="quned" class="disapp" >
<input type="text" placeholder="Enter New Quantity" class="form-control" required name="quntxt" style="margin-top:16%;" />
</div>
<div class="text-center">
<input type="submit" name="submit" style="width:70%;margin-top:20%;" class="btn btn-success btn-md" value="Edit" />
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
这里的问题是这是必填字段,但它没有显示在前端,当您提交表单时,from没有提交,它会在代码中产生java脚本错误,所以首先解决这个问题
<div id="nsned" class="disapp" >
<input type="text" placeholder="Enter New NSN/Part" class="form-control" required name="nsntxt" style="margin-top:16%;" />
</div>
<div id="quned" class="disapp" >
<input type="text" placeholder="Enter New Quantity" class="form-control" required name="quntxt" style="margin-top:16%;" />
</div>
如果你打印文章?你得到一个数组吗?是的,我得到了它确实显示了一个数组,数组空数组还是一个包含提交的数组?只是一个空数组这是一个非常难看的代码-尝试添加一个适当的确定,让我试试,在你的代码中,这段代码使用了display:none site,所以首先删除你会在代码中看到两个额外的字段