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;
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
add a comment |
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
add a comment |
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
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
javascript php
edited Mar 23 at 14:34
Magnus Eriksson
8,16141428
8,16141428
asked Mar 23 at 14:26
myheromyhero
12
12
add a comment |
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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