php处理表单的代码的排列问题
<?phpif($_POST['submitbutt']){echo"username:".$_POST['username']."<br/>";echo"passwor...
<?php
if($_POST['submitbutt']){
echo "username: " . $_POST['username'] . "<br />";
echo "password: " . $_POST['password'] . "<br/ >";
}
else{
?>
<form action="form2.php" method="POST">
Username <input type="text" name="username"><br/>
Password <input type="password" name="password"><br/>
<input type="Submit" name="submitbutt" value="Login!"><br/>
</form>
<?php //这里的<?php什么作用啊?为什么要放在这里呢?
}
?> 展开
if($_POST['submitbutt']){
echo "username: " . $_POST['username'] . "<br />";
echo "password: " . $_POST['password'] . "<br/ >";
}
else{
?>
<form action="form2.php" method="POST">
Username <input type="text" name="username"><br/>
Password <input type="password" name="password"><br/>
<input type="Submit" name="submitbutt" value="Login!"><br/>
</form>
<?php //这里的<?php什么作用啊?为什么要放在这里呢?
}
?> 展开
1个回答
展开全部
区分后端与前端的代码。
你的代码中,有些是php的代码,有些是html的代码,php的代码就应该在<?php ?>中包含
<?php
if($_POST['submitbutt']){
echo "username: " . $_POST['username'] . "<br />";
echo "password: " . $_POST['password'] . "<br/ >";
}
else{
?>
<form action="form2.php" method="POST">
Username <input type="text" name="username"><br/>
Password <input type="password" name="password"><br/>
<input type="Submit" name="submitbutt" value="Login!"><br/>
</form>
<!--form与/form直接都是html代码-->
<?php } ?> //这一段对应上面的else{,都是php代码
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询