Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
141 views
in Technique[技术] by (71.8m points)

html - I Want to Check Text Field

I am a beginner in HTML and ASP and I should write a program that when username and password are admin and user click on the button, the program opens a new ASP page in otherwise the program shows invalid username or password in table.

I write this code but always when I click on the Button, the program shows new ASP page! I write this code in notepad.

<html>
<body>

<form method="post" action="Exam1.asp">
    <table cellpadding="20" border="1" align="center" style="text-align:left;">
        <colorgroup>
        <col style="background-color:pink">
            <col style="background-color:pink">
        </colorgroup>

        <tr>
            <td>
                <p>UserName:</p>
                <p>Password:</p>
            </td>
            <td>
                <input type="text" name="Username">
                <br>
                <br>
                <input type="password" name="Password">
            </td>
        </tr>
        <tr>
            <td><input type="submit" value="Button"></td>
            <td>
                <%If Session("Username")="admin"&Session("Password")="admin" Then%>
                    <form method="post" action="Exam1.asp">
                    </form>
                <%Else%>
                    Invalid username or password.
                <%End If%>
            </td>
        </tr>
    </table>
</form>

</body>
</html>

Thanks for help. Cheers

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

When you click on the submit button named Button, it will take you to Exam1.asp and send it the information the user typed into the form. Sesson("Username") and Sesson("Password") are not yet defined in your code, but in Exam1.asp they will hold the data that the user typed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...