<%pre> #include #include #include #include #include <%session scope="global"> std::string userName; bool isAdmin; <%config> dburl; <&header title="Login">

Login

<{ tntdb::Connection conn; conn = tntdb::connect(dburl); //letting exceptions flow up and to tntnet and let it display an error message std::string post_username = qparam.param("username"); std::string post_password = qparam.param("password"); bool showForm = true; if (post_username.size() > 0 || post_password.size() > 0) { std::stringstream sql; sql << "SELECT realname,useradmin FROM users WHERE username = '" << post_username << "' AND "; sql << "password = '" << post_password << "' AND enabled=true"; tntdb::Result res = conn.select(sql.str()); if (res.size() >0) { tntdb::Row row = res[0]; userName = post_username; isAdmin = row.getBool(1); reply.setHeader("Refresh", "0; url=/dynamic/index"); } else { reply.out() << "

Login failed

\n"; } } }> <{ if (showForm) { }>
Username:
Password:
 
<{ } // end if (showForm) }> <&footer>