Update an iframe with a custom form
-
Hello,
I have a very basic html form that queries a local database and returns the result to an iframe on the same page. The form works perfectly in preview mode, but once the page is published the form returns a theme generated 404 page to the iframe instead of the found result or default “code not found message”. Any thoughts as to why this may be? I have already tried clearing the browser and server cache. I do not use a plugin cache or CDN for this site.
Here is the form’s HTML:
<form action="wp-includes/keyLookup.php" method="post" target="hidden_code_frame">5 Digit Key Number: <input height="150px" name="input_keyNum" type="search" width="150px" /><input type="submit" value="Find Codes" /></form> <iframe name="hidden_code_frame" width="800" height="150" frameborder="0"></iframe>Here is the KeyLookup.php file with the connection credentials redacted:
<?php //define connection variables $dbHost = *** $dbName = *** $dbUser = *** $dbPass = *** // Create host connection $conn = new mysqli($dbHost, $dbUser, $dbPass, $dbName); //test connection if ($conn->connect_error) { die("Connection failed :" . $conn->connect_error); } $value = $_POST["input_keyNum"]; //echo $value; $sql = "SELECT serverCode FROM tbl_codes WHERE keyNumber = " . $value; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "<h1>" . $row["serverCode"] . "</h1>"; //echo $row["serverCode"] } } else { echo "<h1>Codes Not Found</h1>"; } $conn->close(); ?>The page I need help with: [log in to see the link]
The topic ‘Update an iframe with a custom form’ is closed to new replies.