-
Notifications
You must be signed in to change notification settings - Fork 4
npp_usr_send_message
Jurek Muszyński edited this page Mar 28, 2024
·
4 revisions
Saves a message from user. The message is saved in users_messages table.
npp_usr_xxx functions directly read the query string / payload data.
Request must contain the following parameters:
- msg_box
and optionally:
Returns OK or one of the error codes:
- ERR_INVALID_REQUEST
- ERR_INT_SERVER_ERROR
void npp_app_main()
{
// ...
else if ( REQ("contact") )
{
// show contact form with action="do_contact"
render_contact();
}
else if ( REQ("do_contact") && REQ_POST )
{
ret = npp_usr_send_message();
if ( ret == OK )
RES_LOCATION("/contact?msg=%d", MSG_MESSAGE_SENT);
else
RES_LOCATION("/contact?msg=%d", ret);
}
}Requires NPP_USERS compilation switch.
Contact forms are typically flooded by spamming bots. See the more advanced example how to protect your application against those bots.