html旅游登录注册界面代码

瑜舒涵 2周前 14浏览 0评论

HTML 旅游登录注册界面代码示范:

<html>
  <head>
    <title>旅游网站</title>
  </head>
  <body>
    <h1>欢迎来到旅游网站</h1>
    <form action="login.php" method="post">
      <fieldset>
        <legend>登录</legend>
        <p>
          <label>用户名:</label>
          <input type="text" name="username" required>
        </p>
        <p>
          <label>密码:</label>
          <input type="password" name="password" required>
        </p>
        <p>
          <input type="submit" value="登录">
        </p>
      </fieldset>
    </form>
    <form action="register.php" method="post">
      <fieldset>
        <legend>注册</legend>
        <p>
          <label>用户名:</label>
          <input type="text" name="username" required>
        </p>
        <p>
          <label>密码:</label>
          <input type="password" name="password" required>
        </p>
        <p>
          <label>确认密码:</label>
          <input type="password" name="confirm_password" required>
        </p>
        <p>
          <label>电子邮件:</label>
          <input type="email" name="email" required>
        </p>
        <p>
          <input type="submit" value="注册">
        </p>
      </fieldset>
    </form>
  </body>
</html>

在上面的示例代码中,我们使用了 HTML 中的 form 元素来创建登录和注册表单。通过设置 action 属性为所需的 PHP 文件,我们可以让表单提交到后端进行验证和处理。

其中注意到 input 元素的类型,比如 text、password 和 email,这些对应了不同的输入类型,并且我们可以使用 required 属性表示必填字段。

另外,fieldset 和 legend 元素用来为表单创建一个框架和标题,能够更好地组织和显示表单内容。