带验证码的注册页面

和登录页面一样通过html页面的表单来提交信息

<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<form method="post" action="./server/doregister.php">
  <input type="text" placeholder="用户名" name="username"><br><br>
  <input type="password" placeholder="密码" name="password"><br><br>
  <input type="password" placeholder="确认密码" name="repassword"><br><br>
  <input type="text" placeholder="验证码" name="verifycode" class="captcha"><br><br>
  <img id="captcha_img" src="./server/captcha.php?r=<?php echo rand();?>" alt="验证码">
  <label><a href="javascript:void(0)" rel="external nofollow" onclick="document.getElementById('captcha_img').src='./server/captcha.php?r='+Math.random()">换一个</a> </label><br>
  <button type="submit">注册</button>
</form>
</body>
</html>

在php后台里与登录不同的是增加一个插入的方法,以及去除自动保存改为判断两次密码是否相同。在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
页面展示:
在这里插入图片描述

js提示信息代码:

echo '<html><head><Script Language="JavaScript">alert("错误信息");</Script></head></html>' . "<meta http-equiv=\"refresh\" content=\"0;url=../"你的注册页面"\">";

登录页面网址
验证码php编写方法

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
以下是一个验证码的 HTML 注册页面的示例代码: ```html <!DOCTYPE html> <html> <head> <title>注册页面</title> </head> <body> <h1>欢迎注册</h1> <form action="register.php" method="post"> <label for="username">用户名:</label> <input type="text" id="username" name="username" required><br><br> <label for="password">密码:</label> <input type="password" id="password" name="password" required><br><br> <label for="email">邮箱:</label> <input type="email" id="email" name="email" required><br><br> <label for="phone">手机号:</label> <input type="tel" id="phone" name="phone" required><br><br> <label for="captcha">验证码:</label> <input type="text" id="captcha" name="captcha" required> <img src="captcha.php" alt="验证码"><br><br> <input type="submit" value="注册"> </form> </body> </html> ``` 在上面的示例代码中,我们使用了 `input` 元素来创建文本框和密码框,使用 `label` 元素来标识输入框的名称,并使用 `required` 属性来标记必填项。同时,我们还添加了一个验证码的图片,用于防止机器人恶意注册。验证码图片的地址为 `captcha.php`,你需要创建一个 `captcha.php` 文件来生成验证码图片。在 `captcha.php` 中,你可以使用 PHP 的 GD 库来生成验证码并输出图片。 在 `register.php` 中,你可以获取用户提交的表单数据,并进行验证和保存。同时,你需要验证验证码是否正确,以确保注册是由人类用户完成的。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值