Beneath WordPress
-
Back in the day, books like Norton and Beneath Dos were the go to reference for advanced tech … today’s online searchable documents certainly have come a long way … except … now perhaps I am getting totally lost in the jargon (not sure what question to ask) … several years back, using Dreamweaver, MySQL, Ajax etc. I was able to quickly set up some fairly complex front to back end DB web apps … While I have certainly found WordPress simple to use, this needs to be prefaced with it is simple as long as you don’t stray from the defaults.
Case in point … looking to have one input field, one output field and one button that passes the value from the input field to a Server Side PHP script that accesses data in a table and returns the value to the output field on the WP Page
Is a WP PAGE a Server Side Wiget or is it a BROWSER/Client Side Widget?
I downloaded a number of so called form builders even paid to upgrade one of them … none of them appear to provide what I consider a simple call back option on their submit buttons
Using some PHP plugins, I have been able to get the DB function working but the issue appears to do with linking Form input to Function back to Form Output … fnGetCalc will return the correct value to a Client side PAGE but I don’t know if WP and or the PHP plugin is using AJAX behind the scenes to do this trick … Tried putting the code below in a PAGE but it doesn’t work … if I use something like VFB Pro, even though they have HOOKS, I haven’t figured out how to turn off the EMAIL feature and or link the Form Values to what I expect needs to be an AJAX callback … the page I am working on isn’t published so have nothing to link here.
<!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <?php // define Variables $Dta = $DtaError = ""; if ($_SERVER["REQUEST_METHOD"] == "POST" { if (empty($_POST["Dta"])){ $DtaError = "Dta Required"; } else { if (len($_POST["Dta"]) = 1){ $DtaError = "Need at least 2 characters for calculation"; } else { $Dta = trim($_POST["Dta"]); if (!preg_match("abcdefklnpwxyzABCDEFKLNPWXYZ"){ $DtaError = "One of your characters is not valid"; } } } } ?> <h2> Calculator </h2> <form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>"> Dta: <input type="text" name="Dta" value="<?php $Dta; ?>"> <span class="error">* <?php echo $DtaError; ?></span> <br><br> <input type="submit" name="submit" value="Calculate"> </form> <?php function fnCalc($v, $l) { global $wpdb; global $table_prefix; $t = $table_prefix . 'Data' ; $r = $wpdb->get_var("SELECT V1 FROM $t WHERE D1 = '" . $v . "' AND D2 ='" . $l . "'"); return $r; } echo "<p> $Dta </p>"; $x = $Dta; $rtn = fnCalc($x,'C'); echo "<p> Entry {$Dta} returns {$rtn} </p>"; ?> </body> </html>
- The topic ‘Beneath WordPress’ is closed to new replies.