html - PHP 空用户名/密码输入
问题描述
我是 PHP 新手,所以我显然不擅长它。我想要做的是给用户一个错误,如果他们点击提交而不填写输入(名称/用户名/密码)这是我到目前为止所做的:
$fullname = ($_POST['fullname']);
$username = ($_POST['username']);
$password = ($_POST['password']);
if(empty($fullname)){
echo ('Please fill the blank spaces');
}
(不确定 echo 是一个很好的警报代码)
的HTML:
<article>
<form id="signform" method="post" action="signup.php" autocomplete="off">
<input name="fullname" placeholder="Your FullName">
<input name="username" placeholder="UserName">
<input name="password" type="password" placeholder="Password">
<input class="Submit" type="button" onclick="location.href='index.html';" value="Signup" />
</form>
</article>
因此,如果我不填写任何我可以按提交和注册的输入,我不会做任何我不想发生的事情。
解决方案
请使用type="submit"
for 按钮并在 php 中验证后重定向到所需页面。
我建议你像这样使用:
<article>
<form id="signform" method="post" action="signup.php" autocomplete="off">
<input name="fullname" placeholder="Your FullName">
<input name="username" placeholder="UserName">
<input name="password" type="password" placeholder="Password">
<input class="Submit" type="submit" value="Signup" />
</form>
</article>
推荐阅读
- excel - 我的 excel vba 宏在尝试打开多个带有宏的 excel 文件时停止运行
- php - 当我在页面之间移动时:我失去了我的会话变量
- ios - 如何将可移动资产添加到 iOS 应用程序
- android - 工人类上的 ClassNotFoundException
- sql-server - SQL Server 2017 MLS 和 pip - 无法卸载
: “这是一个 distutils 安装的项目” - oracle-nosql - 如何获得有关 Oracle NoSQL 管理计划的反馈
- flutter - 颤振 | 从最顶部的屏幕更新导航器堆栈中所有屏幕上的复选框
- pyspark - 在 PySpark 中读取两个具有不同身份验证令牌的文件
- sql - BigQuery - 使用字符串和数组加入两个表
- faunadb - 如何将 q.Now() 结果转换为动物群中的字符串