emsApplication/applications/WebConfigure/cgiCommon/handleLoginRequest.cpp

77 lines
1.4 KiB
C++

#include <string>
#include <iostream>
#include <cgicc/CgiDefs.h>
#include <cgicc/Cgicc.h>
#include <cgicc/HTTPHTMLHeader.h>
#include <cgicc/HTMLClasses.h>
#include <opdatabase.h>
#include "handleHeader.h"
using namespace cgicc;
// 登录请求处理函数
void handleLoginRequest(cgicc::Cgicc& cgi)
{
#if 0
handleHtmlHeader();
std::cout << std::endl;
// Start the HTML body
std::cout << body() << std::endl;
std::cout << h1("Login Successful!") << std::endl;
// Close the document
std::cout << body() << html();
#endif
#if 1
handleHtmlHeader();
// Start the HTML body
std::cout << body() << std::endl;
std::string username;
std::string passwd;
// Get username and password from form parameters
cgicc::form_iterator fi = cgi.getElement("Username");
if (!fi->isEmpty() && fi != (*cgi).end())
{
username = **fi;
std::cout << "Username:" << **fi << std::endl;
}
std::cout << "<br/>\n";
fi = cgi.getElement("Password");
if (!fi->isEmpty() && fi != (*cgi).end())
{
passwd = **fi;
std::cout << "Password:" << **fi << std::endl;
}
std::cout << "<br/>\n";
// 处理登录逻辑...
std::cout << "<br/>\n";
std::cout << username.c_str() << std::endl;
std::cout << "<br/>\n";
std::cout << passwd.c_str() << std::endl;
std::cout << "<br/>\n";
std::cout << h1("Login Successful!") << std::endl;
// Close the document
std::cout << body() << html();
#endif
}