kool_samule Posted January 20, 2010 Share Posted January 20, 2010 Hi Chaps, Need a bit of guidence with some PHP code. I have a Query that estimates a quote ($price_total) for a job. The estimate ($price_total) is the value of an input (jobquote), and the database is updated once the form is submitted (using a seperate script.php page). What I need, is to validate the entered value of 'jobquote' against the estimated value of $price_total, just incase a 'custom' price has been agreed with a customer. If the values are different, then I need an 'admin override' radio button (admin_quote enum('y','n')) to appear. If someone can help or point me in the right direction, I'd be most grateful. Cheers Quote Link to comment Share on other sites More sharing options...
Buddski Posted January 20, 2010 Share Posted January 20, 2010 Im a little confused.. You have said that estimate IS the value of the jobquote input.. Which means they should be the same and then you want to compare them.. Have I missed something? Quote Link to comment Share on other sites More sharing options...
kool_samule Posted January 20, 2010 Author Share Posted January 20, 2010 Hi, should have been a bit clearer I guess, $price_total=['calculation'] <input type='text' name='jobquote' id="count" class='price_warning' value="<?php echo number_format($price_total, 1, '.', '').'0'; ?>"/> So $price_total is the default value of the input, but it can be changed, and if changed, i need the 'admin override' option to appear.. . . Quote Link to comment Share on other sites More sharing options...
Buddski Posted January 20, 2010 Share Posted January 20, 2010 Ok you need to create a hidden field called like "original_job_quote" and submit that with the form.. So when the form is submitted get it to check the 2 values; echo '<input type="input" name="jobquote" value="'.$price_total.'" /> <input type="hidden" name="original_jobquote" value="'.$price_total.'" />'; // On Post // if ($_POST['original_jobquote'] != $_POST['jobquote']) { // They dont match } Quote Link to comment Share on other sites More sharing options...
kool_samule Posted January 21, 2010 Author Share Posted January 21, 2010 Got a bit further: <input type='text' name='jobquote' value="<?php echo $price_total; ?>"/> <input type='hidden' name='original_jobquote' value="<?php echo $price_total; ?>"/> <?php if ($_POST['original_jobquote'] != $_POST['jobquote']) { ?> <span id="spryradio1"> <input type="radio" name="jobquoteadmin" value="y" id="radio" />Confirm<br /> <span class="radioRequiredMsg">Please confirm Admin Override</span></span> <?php }; ?> Problem 1. The information is '$_POST'ed to a script file, not to the page itself and at the moment, the $_POST takes place before the PHP validation takes place. If I remove the link to the script page, the validation works. Problem 2. (link to script removed for testing) If I change the value (from the default 'original_quote'), then submit, the page reloads, the 'Confirm' radio button appears, but the value of 'job_quote' has reverted back thte default: 1. Start - job_quote = £350 2. Change - job_quote = £100 3. Submit 4. Page reloads - job_quote = £350, confirm appears Is there a way around this? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.