我对php很新,所以这可能只是一个愚蠢的问题。有没有办法将提交按钮放入另一个表单字段,还是必须相同?如果我在其他地方创建一个新领域真的很重要吗?
不工作代码:
<div class="container">
<form method="post">
<div class="form-group">
<input type="text" class="form-control" name="emailfield" id="emailfeld2" placeholder="Emailadresse (z.B Max@Max.de)">
<input type="password" class="form-control" name="passwordfield" id="passwortfeld" placeholder="Passwort">
<input type="password" class="form-control" name="cpasswordfield" id="cpasswortfeld" placeholder="Passwort bestätigen">
</div>
</form>
<div class="form-group">
<form method="post">
<button type="submit" class="btn btn-success" name="submitgo">Sign Up!</button>
</form>
</div>
</div>
<?php
echo $_POST['emailfield']."<br>";
?>
<div class="container-opacity">
</div>
工作代码:
<div class="container">
<form method="post">
<div class="form-group">
<input type="text" class="form-control" name="emailfield" id="emailfeld2" placeholder="Emailadresse (z.B Max@Max.de)">
<input type="password" class="form-control" name="passwordfield" id="passwortfeld" placeholder="Passwort">
<input type="password" class="form-control" name="cpasswordfield" id="cpasswortfeld" placeholder="Passwort bestätigen">
<button type="submit" class="btn btn-success" name="submitgo">Sign Up!</button>
</div>
</form>
</div>
<?php
echo $_POST['emailfield']."<br>";
?>
<div class="container-opacity">
</div>
答案 0 :(得分:0)
将表单元素置于其所属表单之外通常是不好的做法。如果您只有一个<form>
标记并将其移到主要<div class="container">
之外
<form method="post">
<div class="container">
<div class="form-group">
<input type="text" class="form-control" name="emailfield" id="emailfeld2" placeholder="Emailadresse (z.B Max@Max.de)">
<input type="password" class="form-control" name="passwordfield" id="passwortfeld" placeholder="Passwort">
<input type="password" class="form-control" name="cpasswordfield" id="cpasswortfeld" placeholder="Passwort bestätigen">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success" name="submitgo">Sign Up!</button>
</div>
</div>
</form>
<?php echo $_POST[ 'emailfield']. "<br>"; ?>
<div class="container-opacity">
</div>