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

Login

<{ tntdb::Connection conn = tntdb::connectCached(dburl); std::string post_username = qparam.param("username"); std::string post_password = qparam.param("password"); if (post_username.size() > 0 || post_password.size() > 0) { std::string sql; sql += "SELECT realname,useradmin FROM users WHERE username = :username AND "; sql += "password = :password AND enabled=true"; tntdb::Statement st = conn.prepare(sql); st.setString("username", post_username).setString("password", post_password); tntdb::Result res = st.select(); if (res.size() >0) { tntdb::Row row = res[0]; userName = post_username; isAdmin = row.getBool(1); reply.setHeader("Location", "index"); return HTTP_MOVED_TEMPORARILY; //code 302 } else { reply.out() << "

Login failed

\n"; } } }>
Username:
Password:
 
<&footer>