嵌入式开发实践的简单登录代码

#include <stdio.h>
int main() {
printf("Content-type:text/html\n\n"); //CGI的头
printf("<html>");
printf("<head>");
printf("<title>test</title>");
printf("</head>");

printf("<body>");
printf("<fieldset>");

printf("<form method ='POST' action='http://localhost:8080/test/hello.html?login=%B5%C7%C2%

BC' name='frmLogin' >");
printf("<tr>");
printf("<td>用户名:</td>");
printf("<td><input type='text' name='username' value='Your name' size='20' maxlength='20'

onfocus='if (this.value=='Your name') this.value='';' /></td>");
printf("<td > </td>");
printf("<td> </td>");
printf(" </tr>");
printf("<tr>");
printf("<td>密 码:</td>");
printf("<td><input type='password' name='password' value='Your password' size='20'

maxlength='20' onfocus='if (this.value=='Your password') this.value='';' /></td>");
printf("<td> </td>");
printf(" <td> </td>");
printf("</tr>");
printf("<tr>");
printf("<td><a href='#' onclick='shuaxin();'>刷新</a></td>");
printf("</tr>");
printf("<tr>");
printf("<td><input type='checkbox' name='zlogin' value='1'>自动登录</td>");
printf("</tr>");
printf("</table>");
printf("</td>");
printf("<tr>");
printf("<td> </td> ");
printf("<td><table>");
printf("<tr>");
printf("<td><a href='http://192.168.0.115/cgi-bin/ad' input type='submit' name='login' onClick='return validateLogin
()'/>登录</a></td>");
printf("<td><input type='reset' name='rs' value='重置'></td>");
printf("</tr></tr></table></td></table></fieldset></form>");
printf("<script language='javascript'>");
printf("function validateLogin(){");
printf("var sUserName = document.frmLogin.username.value ;");
printf("var sPassword = document.frmLogin.password.value ;");
printf("if ((sUserName =='') || (sUserName=='Your name')){");
printf("alert('请输入用户名!');");
printf("return false ;}");
printf("if ((sPassword =='') || (sPassword=='Your password')){");
printf("alert('请输入密码!');");
printf("return false ;}}");
printf(" </script></body></html>");


}

posted @ 2019-08-05 17:07  研雨之情  阅读(344)  评论(0编辑  收藏  举报