更新时间:2022-04-09 23:40:12
.ajax()函数发送
a请求登录页面然后返回带有2个字段的json响应:错误(失败)和msg(用户/传递确定)。当ajax结束时,success函数必须在页面上显示来自msg的值,如果没有错误重定向到主页。
i假设在某种程度上我需要验证用户/传递我在数据库中有什么,我只是不知道该怎么做。
i目前使用会话进行我的身份验证,它运行得很好,但现在我的新任务是更改它。
i尝试下面的问题是我不知道如何使用数据库进行验证,看看用户和密码是否正确。
请帮我一些想法。
谢谢
我尝试过:
.ajax() function who sends
a request to the login page and then return a json response with 2 fields: error(failed) and msg(user/pass ok). When the ajax ends, the success function must display on the page the value from msg and if there is no error redirect to home page.
i suppose that in some way i need to verify the user/pass with what i have in the database, i just don't know how to do it.
i currently use sessions for my authentications and it works just fine but now my new task is to change it.
i tried something below the problem is i don't know how to do the validation with the database to see if the user and password are correct.
please help me with some ideas.
Thank you
What I have tried:
This is my table
<table style="background-color:#f1f1f1">
<tr>
<td><asp:Label runat="server" ID="lbl1" Font-Bold="true" ForeColor="Red"/></td>
</tr>
<tr>
<td><asp:Label runat="server">Username</asp:Label></td>
<td><asp:TextBox runat="server" ID="txtUser" placeholder="Username"/></td>
<td><asp:RequiredFieldValidator ID="rfvUser" runat="server" ControlToValidate="txtUser" ErrorMessage="*" ForeColor="Red" Font-Bold="true" ValidationGroup="LoginInfo"/></td>
</tr>
<tr>
<td><asp:Label runat="server">Password</asp:Label></td>
<td><asp:TextBox runat="server" ID="txtPass" TextMode="Password" placeholder="Password"/></td>
<td><asp:RequiredFieldValidator ID="rfvPass" runat="server" ControlToValidate="txtPass" ErrorMessage="*" ForeColor="Red" Font-Bold="true" ValidationGroup="LoginInfo"/></td>
</tr>
<tr >
<td></td>
<td><asp:Button runat="server" Text="Login" ID="btnLogin" CssClass="button" Width="210" OnClick="btnLogin_Click" ValidationGroup="LoginInfo"/></td>
</tr>
</table>
这里我一直在尝试:
Here what i have been trying :
<script>
(document).ready(function myfunction(){
(document).ready(function myfunction () {
(' #btLogin')。click(function(){
var user =
('#btnLogin').click(function () { var user =