How to customize the success or failure prompt information and page redirection after submitting the AnQiCMS message form?

Calendar 👁️ 65

As an experienced website operation expert, I fully understand the key role of user experience in the success of a website, and the feedback mechanism after form submission is an important part of user experience.AnQiCMS (AnQiCMS) with its excellent flexibility and customizability, provides us with great freedom to refine this process.Today, let's delve into how to customize the success or failure prompt information and page redirection strategy after submitting a message form in AnQiCMS.

Understand the submission mechanism of the AnQiCMS message form

In AnQi CMS, the function of the message form isguestbookLabel support is provided. When building a comment form, the core lies in the way of submission and the handling of backend responses.AnQiCMS provides us with two main response modes, which determine how we customize the behavior after submission:

  1. HTML mode (return=html)This is the default mode. After the form is submitted, the server will directly return an HTML page as the response.This means that if the submission is successful or fails, the server will render a complete HTML page to display the prompt information, or perform a page redirection.
  2. JSON mode (return=json)In this mode, after the form is submitted, the server will not return the complete HTML page, but a JSON-formatted data.This method is usually used for asynchronous submission (AJAX), allowing front-end JavaScript code to receive response data and dynamically handle prompts and page transitions.

Understand these two modes is the basis of customization operations, because they directly determine whether you need to modify the backend rendering template file or the JavaScript code that handles the front-end response.

Customize success/failure prompts and page redirection: HTML mode (backend processing)

In HTML mode, after the user submits the form, if not specially configured, AnQiCMS usually reloads the page submitted before and passes the success or failure status and information through some mechanism on the page (such as URL parameters or flash messages). To achieve more personalized prompts and page redirection, we can operate in two ways:

Firstly, the most direct way is to use the template file (usually used for displaying message forms)guestbook/index.html)In it, based on the backend transmitted status variable, to display different prompt information. For example, the backend may pass a variable to the template after a successful submission, and pass a variable when it fails.success_messagevariable to the template, when it fails.error_message. You can useguestbook/index.htmlInclude condition judgment:

{# guestbook/index.html 示例片段 #}
{% if success_message %}
    <div class="alert alert-success">{{ success_message }}</div>
    <meta http-equiv="refresh" content="3;url=/thank-you.html"> {# 3秒后跳转到感谢页面 #}
{% endif %}

{% if error_message %}
    <div class="alert alert-danger">{{ error_message }}</div>
    <p>请检查您的输入并重试。</p>
{% endif %}

{# ... 其他表单代码 ... #}

Here, we not only displayed the message but also through<meta http-equiv="refresh">tag to implement a simple timing jump. You need to make sure/thank-you.htmlIt is an actual page that is used to display thank you information.

Next, more advanced customization if it involves jumping to after submission.A completely different independent page.(such as a dedicated "Thank You" page or error page)

Related articles

How to perform additional client-side validation on the comment form on AnQiCMS frontend using JavaScript?

As an experienced website operations expert, I know that user experience and data security are equally important for a website.In such a flexible and efficient content management system as AnQiCMS, front-end validation is a key factor in improving user experience and reducing invalid requests.Today, we will delve into how to巧妙运用JavaScript for our comment form on the AnQiCMS frontend, adding additional client-side validation to provide users with immediate feedback before submitting information, thereby optimizing the entire interaction process.Why do we need front-end client validation? First

2025-11-06

What is the specific data structure and traversal method of the `Items` field in the AnQiCMS comment form, which includes single choice, multiple choice, and drop-down options?

As an experienced website operations expert, I know the importance of a flexible and efficient content management system for a corporate website.AnQiCMS stands out among many content management systems with its lightweight and high concurrency characteristics.Its powerful customizability is particularly commendable, including the seemingly simple yet crucial 'selection' fields in the comment form, such as radio buttons, checkboxes, and dropdown options.Today, let's delve into the `Items` data structure behind these fields in the AnQiCMS comment form and its traversal in the template

2025-11-06

How to judge and render different form elements (such as input, textarea, select) in the AnQiCMS template according to the `Type` field?

As an expert in website operations for many years, I deeply understand the importance of a flexible and efficient content management system for business development.AnQiCMS (AnQi Content Management System) leverages its high-performance architecture based on the Go language and highly customizable content model, providing us with great convenience.In daily operations, we often need to display various customized forms on the front page according to different business needs, such as in scenarios such as message boards, product inquiries, and event registration.

2025-11-06

What is the difference in the `Content` field (default form value) of AnQiCMS comment form under different input types?

AnQiCMS with its high efficiency and flexibility has become a powerful assistant for many enterprises and content operation teams.In the daily operation of the website, the message form serves as an important bridge for interaction between users and the website, and its functional design and user experience are crucial.Among them, the setting of the default value in the comment form, especially the performance difference of the `Content` field under different input types, is a topic of concern for many operators.

2025-11-06

How to build a static form using AnQiCMS form tag without backend custom fields?

As an experienced website operation expert, I know how important it is to be flexible and efficient in responding to business needs in daily work.AnQiCMS (AnQiCMS) provides us with many conveniences with its powerful functions and high customizability.However, sometimes we are faced with some simple form requirements, such as a quickly deployed contact us form, or a fixed-field event registration form, and we may not want to go to great lengths to configure a custom content model on the backend for just a few fields.

2025-11-06

Why is it recommended to use English letters for naming the `FieldName` parameter in the AnQiCMS message form?

As an experienced website operation expert, I know that every system detail may affect the long-term health and operation efficiency of the website.In AnQiCMS (AnQiCMS), we often encounter various settings, including the `FieldName` parameter naming for the message form, I strongly recommend that you name it with English letters first.This seems to be a small specification, but it actually contains many deep considerations, concerning the technical compatibility, stability, and even the future scalability of the website.

2025-11-06

Where is the data stored for the AnQiCMS message form and how to view it?

Hello!As an experienced website operation expert, I am willing to give you a detailed explanation of the storage mechanism and viewing method of AnQiCMS comment form data.In website operation, user feedback is valuable, understanding its storage and viewing methods is crucial for efficient management and utilization of these data. ### AnQiCMS form data: In-depth analysis of storage location and efficient viewing strategy In the website built with AnQiCMS, the information submitted by users through the front-end message form is an important part of the interaction between the website and users.

2025-11-06

Does AnQiCMS support setting different comment forms for different pages or content models?

As an experienced website operations expert, I fully understand your emphasis on website interactivity and personalized experience.The comment form acts as an important bridge for users to communicate with the website, and its flexibility and specificity indeed greatly enhance user experience and data collection efficiency.About whether AnQiCMS supports setting different comment forms for different pages or content models?

2025-11-06