[英]What's wrong with my form?
我有一个未设置样式的表单,因此我决定对其进行样式设置。
无效的表格:
<form class="form-horizontal" role="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<div class="form-group">
<label for="username" class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="text" class="form-control" placeholder="<?php echo $_POST['username']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">API Key</label>
<div class="col-sm-10">
<p class="form-control-static"><?php if(strpos(file_get_contents("keys.php"),base64_encode($_POST['username'])) !== false) {echo "API Key already exists";} else { echo base64_encode($_POST['username']); }?></p>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Get API Key</button>
</div>
</div>
</form>
工作形式:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
Username: <input type="text" name="username" value"<?php echo $_POST['username']; ?>" /><br /><br />
Key: <input type="text" value="
<?php if(strpos(file_get_contents("./keys.php"),base64_encode($_POST['username'])) !== false) {
echo "API Key already exists";
} else { echo base64_encode($_POST['username']); }?>" readonly /><br />
<input type="submit" />
</form>
我不太确定这是怎么回事。
损坏的表单不会发布数据,因此不会显示它。
我想我终于明白了您的问题。 它不是表单不发布。 转到下一页。 不,它的价值迷失了。
那么为什么价值观会迷失呢? 因为您的输入中没有name
属性!
这个:
<input type="text" class="form-control" placeholder="<?php echo $_POST['username']; ?>">
应该:
<input type="text" name="username" class="form-control" placeholder="<?php echo $_POST['username']; ?>">
实际上, placeholder
不应该value
吗?
这行:
<input type="text" class="form-control" placeholder="<?php echo $_POST['username']; ?>">
末尾缺少/>
。
另外,在工作中,您有一个
Key: <input type="text" value="...
一个不起作用的:
<p class="form-control-static"><?php if(strpos(file_get_contents...
您缺少隐藏的输入或类似内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.