Hi there,
I am experiencing difficulty with my on submit before email processing. The problem is that when I evaluate a user entered value to determine if it is the same as a preset hidden value, the user entered value is ending up null after submission. Here is the block of code:
For example if the user enters "AA" for 'enteredcode_CP1', this correctly results in 'hidden_earned_points_CP1' being set to the value of 'hidden_value_CP1', however at the same time instead of getting "AA" in the DB record that is saved, the 'enteredcode_CP1' is null. I don't understand why this is happening - I only get this value, I don't set it, so why is it changing from what the user has entered??
Thanks for your assistance.
I am experiencing difficulty with my on submit before email processing. The problem is that when I evaluate a user entered value to determine if it is the same as a preset hidden value, the user entered value is ending up null after submission. Here is the block of code:
<?php
global $mainframe;
if ( JRequest::getVar('enteredcode_CP1') == JRequest::getVar('hidden_code_CP1') ) {
$cp1value = JRequest::getVar('hidden_value_CP1');
JRequest::setVar('hidden_earned_points_CP1',$cp1value);
}
?>
For example if the user enters "AA" for 'enteredcode_CP1', this correctly results in 'hidden_earned_points_CP1' being set to the value of 'hidden_value_CP1', however at the same time instead of getting "AA" in the DB record that is saved, the 'enteredcode_CP1' is null. I don't understand why this is happening - I only get this value, I don't set it, so why is it changing from what the user has entered??
Thanks for your assistance.
Hi markoadams,
Generally using JRequest in an 'if' statement gives a PHP error, this may be happening 'invisibly' with your code. Please try this slightly longer version:
Bob
Generally using JRequest in an 'if' statement gives a PHP error, this may be happening 'invisibly' with your code. Please try this slightly longer version:
<?php
$enteredcode = JRequest::getString('enteredcode_CP1', '', 'post');
$hidden_code = JRequest::getString('hidden_code_CP1', '', 'post');
$hidden_value = JRequest::getString('hidden_value_CP1', '', 'post');
if ( $enteredcode == $hidden_code ) {
JRequest::setVar('hidden_earned_points_CP1', $hidden_value);
}
?>
Bob
This topic is locked and no more replies can be posted.