Validate a form field in PHP, display message to user and save submitted field to a page (visible to user and at backend)Jquery PHP form submit - How to get form inputs to display?Can I use AJAX to add SUBMIT button or hidden INPUT into PHP form?PHP validate form having different fields displayed on javascriptForm not submitting the input elements to php fileUse a php variable after an ajax callJavascript form submission validation is not workingThe most common, “best” way to sanatize and validate PHP Forms?I need to validate form data using JQuery before i can post it using PHPHow to validate form with PHP and HTML?JQuery shake effect doesn't work with php form validation

Why does lemon juice reduce the "fish" odor of sea food — specifically fish?

Given 0s on Assignments with suspected and dismissed cheating?

Do Grothendieck universes matter for an algebraic geometer?

What information exactly does an instruction cache store?

Promotion comes with unexpected 24/7/365 on-call

Can my Serbian girlfriend apply for a UK Standard Visitor visa and stay for the whole 6 months?

Automation Engine activity type not retrieving custom facet

Help understanding this line - usage of くれる

Should generated documentation be stored in a Git repository?

Who commanded or executed this action in Game of Thrones S8E5?

Is there an academic word that means "to split hairs over"?

What was the ring Varys took off?

Acronyms in HDD specification

Do we have C++20 ranges library in GCC 9?

Why doesn't Iron Man's action affect this person in Endgame?

Adding labels and comments to a matrix

Substring join or additional table, which is faster?

Can only the master initiate communication in SPI whereas in I2C the slave can also initiate the communication?

Under what charges was this character executed in Game of Thrones, The Bells?

Smooth function that vanishes only on unit cube

Source of the Wildfire?

Can I say: "When was your train leaving?" if the train leaves in the future?

Is 95% of what you read in the financial press “either wrong or irrelevant?”

Will the volt, ampere, ohm or other electrical units change on May 20th, 2019?



Validate a form field in PHP, display message to user and save submitted field to a page (visible to user and at backend)


Jquery PHP form submit - How to get form inputs to display?Can I use AJAX to add SUBMIT button or hidden INPUT into PHP form?PHP validate form having different fields displayed on javascriptForm not submitting the input elements to php fileUse a php variable after an ajax callJavascript form submission validation is not workingThe most common, “best” way to sanatize and validate PHP Forms?I need to validate form data using JQuery before i can post it using PHPHow to validate form with PHP and HTML?JQuery shake effect doesn't work with php form validation






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have a form field which is used to validate voucher codes. I want the successfully validated codes to be displayed on a page for the user as well as for the administrator.



I'm using a theme called CouponXXL, in my website I am also using FormidablePro which is very useful and I was wondering if this could be used for this purpose too.



Please help, quotes welcome too.



Don't know how to integrate the code with Formidablepro forms



The input form is included below and the code in the FUNCTIONS (excluding the generation of the code) is below that.



<div class="white-block">
<div class="white-block-content">
<form method="post">
<p><?php esc_html_e( 'In order to check for voucher input it into
the field bellow and click on Verify', 'couponxxl' ) ?></p>
<div class="input-group">
<label for="voucher_code"><?php esc_html_e( 'Voucher Code',
'couponxxl' ); ?> <span class="required">*</span></label>
<input type="text" name="voucher_code" id="voucher_code"
class="form-control" data-validation="required" data-error="<?php _e(
'Please input voucher code', 'couponxxl' ); ?>" value="">
<i class="pline-magnifier"></i>
</div>
<a href="javascript:;" class="btn submit-form ajax-return">
<?php esc_html_e( 'Verify', 'couponxxl' ); ?>
</a>
<input type="hidden" name="action" value="verify_voucher">
<input type="hidden" name="vendor_id" value="<?php echo esc_attr(
$vendor_id ) ?>">
<div class="ajax-response"></div>
</form>
</div>




FROM FUNCTIONS.PHP



/*
Check voucher and depending on the result display with not used or used
*/
if ( ! function_exists( 'couponxxl_voucher_check' ) )
function couponxxl_voucher_check( $voucher )
$used = false;
if ( $voucher->voucher_status == '1' )
$used = true;


return '<div class="voucher-wrap">' . $voucher->voucher_code . ' <a
href="javascript:;" class="update_voucher button" data-id="' . esc_attr(
$voucher->voucher_id ) . '" title="' . ( $used ? esc_attr__( 'Mark as not
used', 'couponxxl' ) : esc_attr__( 'Mark as used', 'couponxxl' ) ) . '">'
. ( $used ? '<i class="fa fa-times"></i>' : '<i class="fa fa-check"></i>'
) . '</a></div>';



/*
Update voucher to set it as used or not
*/
if ( ! function_exists( 'couponxxl_update_voucher' ) )
function couponxxl_update_voucher( $die = true )
global $wpdb;
$voucher = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->prefixvouchers WHERE voucher_id = %d", $_POST['voucher_id'] ) );

if ( ! empty( $voucher ) )
$voucher = $voucher[0];
$voucher->voucher_status = $_POST['status'];
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->prefixvouchers SET
voucher_status = %s WHERE voucher_id = %d", $_POST['status'],
$_POST['voucher_id'] ) );
if ( $die )
echo couponxxl_voucher_check( $voucher );


if ( $die )
die();



add_action( 'wp_ajax_update_voucher', 'couponxxl_update_voucher' );
add_action( 'wp_ajax_nopriv_update_voucher',
'couponxxl_update_voucher' );










share|improve this question






























    0















    I have a form field which is used to validate voucher codes. I want the successfully validated codes to be displayed on a page for the user as well as for the administrator.



    I'm using a theme called CouponXXL, in my website I am also using FormidablePro which is very useful and I was wondering if this could be used for this purpose too.



    Please help, quotes welcome too.



    Don't know how to integrate the code with Formidablepro forms



    The input form is included below and the code in the FUNCTIONS (excluding the generation of the code) is below that.



    <div class="white-block">
    <div class="white-block-content">
    <form method="post">
    <p><?php esc_html_e( 'In order to check for voucher input it into
    the field bellow and click on Verify', 'couponxxl' ) ?></p>
    <div class="input-group">
    <label for="voucher_code"><?php esc_html_e( 'Voucher Code',
    'couponxxl' ); ?> <span class="required">*</span></label>
    <input type="text" name="voucher_code" id="voucher_code"
    class="form-control" data-validation="required" data-error="<?php _e(
    'Please input voucher code', 'couponxxl' ); ?>" value="">
    <i class="pline-magnifier"></i>
    </div>
    <a href="javascript:;" class="btn submit-form ajax-return">
    <?php esc_html_e( 'Verify', 'couponxxl' ); ?>
    </a>
    <input type="hidden" name="action" value="verify_voucher">
    <input type="hidden" name="vendor_id" value="<?php echo esc_attr(
    $vendor_id ) ?>">
    <div class="ajax-response"></div>
    </form>
    </div>




    FROM FUNCTIONS.PHP



    /*
    Check voucher and depending on the result display with not used or used
    */
    if ( ! function_exists( 'couponxxl_voucher_check' ) )
    function couponxxl_voucher_check( $voucher )
    $used = false;
    if ( $voucher->voucher_status == '1' )
    $used = true;


    return '<div class="voucher-wrap">' . $voucher->voucher_code . ' <a
    href="javascript:;" class="update_voucher button" data-id="' . esc_attr(
    $voucher->voucher_id ) . '" title="' . ( $used ? esc_attr__( 'Mark as not
    used', 'couponxxl' ) : esc_attr__( 'Mark as used', 'couponxxl' ) ) . '">'
    . ( $used ? '<i class="fa fa-times"></i>' : '<i class="fa fa-check"></i>'
    ) . '</a></div>';



    /*
    Update voucher to set it as used or not
    */
    if ( ! function_exists( 'couponxxl_update_voucher' ) )
    function couponxxl_update_voucher( $die = true )
    global $wpdb;
    $voucher = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->prefixvouchers WHERE voucher_id = %d", $_POST['voucher_id'] ) );

    if ( ! empty( $voucher ) )
    $voucher = $voucher[0];
    $voucher->voucher_status = $_POST['status'];
    $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->prefixvouchers SET
    voucher_status = %s WHERE voucher_id = %d", $_POST['status'],
    $_POST['voucher_id'] ) );
    if ( $die )
    echo couponxxl_voucher_check( $voucher );


    if ( $die )
    die();



    add_action( 'wp_ajax_update_voucher', 'couponxxl_update_voucher' );
    add_action( 'wp_ajax_nopriv_update_voucher',
    'couponxxl_update_voucher' );










    share|improve this question


























      0












      0








      0








      I have a form field which is used to validate voucher codes. I want the successfully validated codes to be displayed on a page for the user as well as for the administrator.



      I'm using a theme called CouponXXL, in my website I am also using FormidablePro which is very useful and I was wondering if this could be used for this purpose too.



      Please help, quotes welcome too.



      Don't know how to integrate the code with Formidablepro forms



      The input form is included below and the code in the FUNCTIONS (excluding the generation of the code) is below that.



      <div class="white-block">
      <div class="white-block-content">
      <form method="post">
      <p><?php esc_html_e( 'In order to check for voucher input it into
      the field bellow and click on Verify', 'couponxxl' ) ?></p>
      <div class="input-group">
      <label for="voucher_code"><?php esc_html_e( 'Voucher Code',
      'couponxxl' ); ?> <span class="required">*</span></label>
      <input type="text" name="voucher_code" id="voucher_code"
      class="form-control" data-validation="required" data-error="<?php _e(
      'Please input voucher code', 'couponxxl' ); ?>" value="">
      <i class="pline-magnifier"></i>
      </div>
      <a href="javascript:;" class="btn submit-form ajax-return">
      <?php esc_html_e( 'Verify', 'couponxxl' ); ?>
      </a>
      <input type="hidden" name="action" value="verify_voucher">
      <input type="hidden" name="vendor_id" value="<?php echo esc_attr(
      $vendor_id ) ?>">
      <div class="ajax-response"></div>
      </form>
      </div>




      FROM FUNCTIONS.PHP



      /*
      Check voucher and depending on the result display with not used or used
      */
      if ( ! function_exists( 'couponxxl_voucher_check' ) )
      function couponxxl_voucher_check( $voucher )
      $used = false;
      if ( $voucher->voucher_status == '1' )
      $used = true;


      return '<div class="voucher-wrap">' . $voucher->voucher_code . ' <a
      href="javascript:;" class="update_voucher button" data-id="' . esc_attr(
      $voucher->voucher_id ) . '" title="' . ( $used ? esc_attr__( 'Mark as not
      used', 'couponxxl' ) : esc_attr__( 'Mark as used', 'couponxxl' ) ) . '">'
      . ( $used ? '<i class="fa fa-times"></i>' : '<i class="fa fa-check"></i>'
      ) . '</a></div>';



      /*
      Update voucher to set it as used or not
      */
      if ( ! function_exists( 'couponxxl_update_voucher' ) )
      function couponxxl_update_voucher( $die = true )
      global $wpdb;
      $voucher = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->prefixvouchers WHERE voucher_id = %d", $_POST['voucher_id'] ) );

      if ( ! empty( $voucher ) )
      $voucher = $voucher[0];
      $voucher->voucher_status = $_POST['status'];
      $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->prefixvouchers SET
      voucher_status = %s WHERE voucher_id = %d", $_POST['status'],
      $_POST['voucher_id'] ) );
      if ( $die )
      echo couponxxl_voucher_check( $voucher );


      if ( $die )
      die();



      add_action( 'wp_ajax_update_voucher', 'couponxxl_update_voucher' );
      add_action( 'wp_ajax_nopriv_update_voucher',
      'couponxxl_update_voucher' );










      share|improve this question
















      I have a form field which is used to validate voucher codes. I want the successfully validated codes to be displayed on a page for the user as well as for the administrator.



      I'm using a theme called CouponXXL, in my website I am also using FormidablePro which is very useful and I was wondering if this could be used for this purpose too.



      Please help, quotes welcome too.



      Don't know how to integrate the code with Formidablepro forms



      The input form is included below and the code in the FUNCTIONS (excluding the generation of the code) is below that.



      <div class="white-block">
      <div class="white-block-content">
      <form method="post">
      <p><?php esc_html_e( 'In order to check for voucher input it into
      the field bellow and click on Verify', 'couponxxl' ) ?></p>
      <div class="input-group">
      <label for="voucher_code"><?php esc_html_e( 'Voucher Code',
      'couponxxl' ); ?> <span class="required">*</span></label>
      <input type="text" name="voucher_code" id="voucher_code"
      class="form-control" data-validation="required" data-error="<?php _e(
      'Please input voucher code', 'couponxxl' ); ?>" value="">
      <i class="pline-magnifier"></i>
      </div>
      <a href="javascript:;" class="btn submit-form ajax-return">
      <?php esc_html_e( 'Verify', 'couponxxl' ); ?>
      </a>
      <input type="hidden" name="action" value="verify_voucher">
      <input type="hidden" name="vendor_id" value="<?php echo esc_attr(
      $vendor_id ) ?>">
      <div class="ajax-response"></div>
      </form>
      </div>




      FROM FUNCTIONS.PHP



      /*
      Check voucher and depending on the result display with not used or used
      */
      if ( ! function_exists( 'couponxxl_voucher_check' ) )
      function couponxxl_voucher_check( $voucher )
      $used = false;
      if ( $voucher->voucher_status == '1' )
      $used = true;


      return '<div class="voucher-wrap">' . $voucher->voucher_code . ' <a
      href="javascript:;" class="update_voucher button" data-id="' . esc_attr(
      $voucher->voucher_id ) . '" title="' . ( $used ? esc_attr__( 'Mark as not
      used', 'couponxxl' ) : esc_attr__( 'Mark as used', 'couponxxl' ) ) . '">'
      . ( $used ? '<i class="fa fa-times"></i>' : '<i class="fa fa-check"></i>'
      ) . '</a></div>';



      /*
      Update voucher to set it as used or not
      */
      if ( ! function_exists( 'couponxxl_update_voucher' ) )
      function couponxxl_update_voucher( $die = true )
      global $wpdb;
      $voucher = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->prefixvouchers WHERE voucher_id = %d", $_POST['voucher_id'] ) );

      if ( ! empty( $voucher ) )
      $voucher = $voucher[0];
      $voucher->voucher_status = $_POST['status'];
      $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->prefixvouchers SET
      voucher_status = %s WHERE voucher_id = %d", $_POST['status'],
      $_POST['voucher_id'] ) );
      if ( $die )
      echo couponxxl_voucher_check( $voucher );


      if ( $die )
      die();



      add_action( 'wp_ajax_update_voucher', 'couponxxl_update_voucher' );
      add_action( 'wp_ajax_nopriv_update_voucher',
      'couponxxl_update_voucher' );







      javascript php






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 23 at 14:34









      Magnus Eriksson

      8,16141428




      8,16141428










      asked Mar 23 at 14:26









      myheromyhero

      12




      12






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55314712%2fvalidate-a-form-field-in-php-display-message-to-user-and-save-submitted-field-t%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55314712%2fvalidate-a-form-field-in-php-display-message-to-user-and-save-submitted-field-t%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현