3 Replies Latest reply on Jun 16, 2008 8:38 AM by (shane_mosier)

    [php - mysql] how to capitalize an insert form text field?

      Hi all,
      I have an insert form on a page and I would like to correct the user
      input before inserting the data in the db.

      Example:
      the user inputs: CAR
      and Car will be inserted in the db.

      How can I do with ADDT?

      TIA

      tony
        • 1. Re: [php - mysql] how to capitalize an insert form text field?
          Günter Schenk Level 4
          Hi Tony,

          the PHP functions which will first convert a string to lowercase and then capitalize the first char would go like this:

          ucfirst(strtolower($bar));

          Please try embedding the following code in a Custom Trigger (type: BEFORE):

          $first_to_upper = ucfirst(strtolower($tNG->getColumnValue("column_name")));
          $tNG->setColumnValue("column_name", $first_to_upper);

          ...and replace "column_name" with the name of the column you´re inserting into the DB.

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: [php - mysql] how to capitalize an insert form text field?
            Level 1
            tony,

            You would need to create an ADDT Custom Trigger set to execute BEFORE the Insert Transaction on your Insert page.

            It would look some thing like this:

            function Trigger_Custom(&$tNG) {

            // This code grabs the value for the form field "first_name"
            // from the submitted form and sets it to $firstName
            $firstName = $tNG->getColumnValue("first_name");

            // Now do your data processing on this value, in this case
            // the code coverts the string $firstName to upper case letters
            $firstName = strtoupper($firstName);

            // Now update the value for the column "first_name" before
            // the data is inserted into the database
            $tNG->setColumnValue("first_name", $firstName);

            }

            Remember to be sure this Custom Trigger is set to execute BEFORE the Insert Transaction.

            Shane
            • 3. Re: [php - mysql] how to capitalize an insert form text field?
              Level 1
              thanks gunter and shane.

              it works.

              ciao ;).

              tony