简易表单服务器

 任务:

利用表单服务器发送一个用户名和密码,如果正确,返回欢迎您;否则返回错误。

login.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <form action="Hello/Login" method="post">//method用来隐藏密码
        用户名:<input type="text" name="name" />
        密码:<input type="text" name="pwd"  />
        <input type="submit" value="登 录"/>
    </form>
</body>
</html>

HelloController.cs 

//HelloController.cs
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ChapterOne.Controllers
{
    public class HelloController : Controller
    {
        public IActionResult Login(String name,String pwd)
        {
            if (name == "Tom" && pwd == "123")
                return Content("Hello," + name);
            else
                return Content("error");
            
        }
    }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
这里给你一个简易的HTML代码示例,包含账号密码输入框和登录/注册按钮。你可以根据需要进行修改和美化。 ``` <!DOCTYPE html> <html> <head> <title>Login/Register Form</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> form { display: flex; flex-direction: column; align-items: center; margin-top: 50px; } input[type=text], input[type=password] { width: 100%; padding: 12px 20px; margin: 8px 0; display: inline-block; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } button[type=submit] { background-color: #4CAF50; color: white; padding: 14px 20px; margin: 8px 0; border: none; border-radius: 4px; cursor: pointer; } button[type=submit]:hover { background-color: #45a049; } </style> </head> <body> <form action="login.php" method="post"> <h2>Login</h2> <label for="username"><b>Username</b></label> <input type="text" placeholder="Enter Username" name="username" required> <label for="password"><b>Password</b></label> <input type="password" placeholder="Enter Password" name="password" required> <button type="submit">Login</button> </form> <form action="register.php" method="post"> <h2>Register</h2> <label for="username"><b>Username</b></label> <input type="text" placeholder="Enter Username" name="username" required> <label for="password"><b>Password</b></label> <input type="password" placeholder="Enter Password" name="password" required> <button type="submit">Register</button> </form> </body> </html> ``` 这是一个基础的HTML表单,如果你需要在后台进行账号密码验证和注册等操作,需要编写相应的PHP或其他服务器端脚本。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值