Using the sc_confirm macro

Using the sc_confirm macro

In this article, see a practical example of using the sc_confirm macro.

This macro can only be used on PHP buttons created in the toolbar of form and control applications, with the aim of confirming the action's excursion.
See how to create a PHP field to update your application's records, thus replacing the tool's update button.

Creating a PHP button

1. Click on the option New Button.



2. Select the PHP type and enter a name.


3. Configure the look of your button


Using the sc_confirm macro

In the PHP button event, created in the previous session, add the lines of code below

The code below serves as the basis for your use. They must be appropriate to the reality of your system.
  1. // Update the name according to the key field of the table
  2. $ UPDATE = "UPDATE clients SET name = '" . {Name} . "'WHERE id =" . {id};
  3. sc_exec_sql ($ UPDATE);
  1. // Confirms whether you really want to update therecord
  2. sc_confirm("Do you really want to update the record?");
  1. // Updates the page
  2. sc_redir (form_sample_sc_confirm);

sc_confirm macro in operation

When executing the form, change the name and click the button Save Record.
A confirmation message will appear, like the one below.

Clicking Cancel

The action will not be performed.

That is, no event command will be executed.

When you click OK

The action will be performed.

That is, the update command will be executed and the name will be changed in the database.


    • Related Articles

    • Macro sc_date

        Scriptcase provides a very useful macro for manipulating dates, which is a very laborious process, however with the use of the sc_date macro (Increments and Decrement Dates), it is much simpler, example:   sc_date (Date, format, operator, D, M, A) ...
    • Macro sc_block_display

      In this example, we will see how to use the sc_block_display macro in an Ajax event using a Radio button on a Form, this macro is intended to hide or show a block. The steps in this example: Configuring Radio type field Configuring and creating ...
    • Using the macro sc_date_dif_2

      To calculate the difference between two dates we have the macro sc_date_dif_2, in this example we will see how it works and how to use it. 1. The format with which you are keeping within the database must be taken into account: Database Format Macro ...
    • Using the sc_field_display macro

      To dynamically hide a field in this example, the macro sc_field_display is used, which is responsible for hiding or dynamically displaying a field or several. This macro has scope in the following events: In this example, it will be used within an ...
    • Using the macros sc_begin_trans, sc_commit_trans and sc_rollback_trans

      When we need to maintain a control or follow-up to a specific procedure at the time of entering, modify some procedure within the database within a form we have the macro sc_begin_trans. The macro sc_begin_trans is responsible for carrying out a ...
    • Popular Articles

    • Examples for diagrams

      This tutorial shows how you can import and use the new examples for diagrams released with Scriptpcase V9.2.16.  The applications were created using the components: Jsmind, JKanban e Orgchart.  - Sample 1: Mind Map diagram Click here to  execute the ...
    • Manual Update - Windows

      Before performing any procedure we recommend performing a backup of your projects. To back up Scriptcase: Go to Settings > Administration, in the side menu go to Services > Backup. A file (.ZIP) will be generated with all your projects, save this ...
    • PHP functions necessary for ScriptCase

      In PHP , there are some essential functions for the operation of Scriptcase .  On some servers , these functions are disabled , this makes the Scriptcase not work properly.  If you're using a shared hosting server, you'll need to contact the host ...
    • Oracle Connection - Scriptcase 9 - Linux 64 Bits

      This procedure will only work if you have a Scriptcase manual installation in your server. Installing PHP 7.0 Installing the Scriptcase Manually To connect with Oracle in a Linux System, we must follow these steps below: Step 1 -  Installing these ...
    • Using friendly URL

      The friendly URL was included from Scriptcase 7, in order to make the URL, of the applications generated by Scriptcase, cleaner and easier to associate them with applications. For example, using friendly URLs the link to a Scriptcase application ...