You do not have sufficient permissions to access this data.You do not have sufficient permissions to access this data.{"id":680,"date":"2012-03-18T22:05:37","date_gmt":"2012-03-19T02:05:37","guid":{"rendered":"http:\/\/cfdbplugin.com\/?p=680"},"modified":"2014-10-18T19:15:18","modified_gmt":"2014-10-18T23:15:18","slug":"creating-a-form-to-search-the-database","status":"publish","type":"page","link":"https:\/\/cfdbplugin.com\/?page_id=680","title":{"rendered":"Creating a form to search the database"},"content":{"rendered":"<p>What to create a form to that can be used to search your form entries? Follow this example:<\/p>\n<p>&nbsp;<\/p>\n<pre lang=\"html\" line=\"1\" escaped=\"true\">\r\n<form action=\"\" method=\"POST\">\r\nFirst Name: <input type=\"text\" name=\"fname\" \/> \r\nLast Name: <input type=\"text\" name=\"lname\" \/> \r\n<input type=\"submit\" \/>\r\n<\/form><\/pre>\n<pre lang=\"html\" line=\"1\" escaped=\"true\"><\/pre>\n<p>In the form, put whatever fields you wish to search on. You can name these form fields by any name.<\/p>\n<p>Use a short code with the filter attribute. Here we use <a href=\"http:\/\/cfdbplugin.com\/?page_id=116\" target=\"_blank\">filter variable substitution<\/a>. $_POST(fname) and $_POST(lname) will be substituted with the values of the form post.<\/p>\n<p>For the filter in the short code, string together regular expressions of the form <code>database_form_field_name~~\/.*$_POST(posted_field_name).*\/i<\/code>. The &#8220;.*&#8221; at the front and end of the regex allow the user to just type in part of a word and find a match. The &#8220;i&#8221; makes it case-insensitive.<\/p>\n<p>Chain all the regex&#8217;s together with logical AND (&amp;&amp;). If a user leaves an entry blank in the search form like fname in the example above then <code>fname~~\/.*$_POST(fname).*\/i<\/code> will become <code>fname~~\/.*.*\/i<\/code> after substituting an empty string. This regex will match all entries. The effect is as if this contraint did not exist. So this means that a user can fill in only those elements on the search form that he wants to constrain. Those that are not filled out are effectively unconstrained.<\/p>\n<p>When you first load a page with the above form and short code, it displays all the values. If you want the short code to show no results when the page is loaded, added a hidden form field to the form and short code. In this case there is a hidden INPUT named &#8220;x&#8221; in the form and we add to the short code filter &#8220;&#038;&#038;submit_time>$_POST(x)&#8221;<\/p>\n<pre lang=\"html\" line=\"1\" escaped=\"true\">\r\n<form action=\"\" method=\"POST\">\r\nFirst Name: <input type=\"text\" name=\"fname\" \/> \r\nLast Name: <input type=\"text\" name=\"lname\" \/> \r\n<input type=\"hidden\" name=\"x\" value=\"1\"\/>\r\n<input type=\"submit\" \/>\r\n<\/form><\/pre>\n<pre lang=\"html\" line=\"1\" escaped=\"true\"><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>What to create a form to that can be used to search your form entries? Follow this example: &nbsp; First Name: Last Name: In the form, put whatever fields you wish to search on. You can name these form fields by any name. Use a short code with the filter attribute. Here we use filter [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":102,"menu_order":7,"comment_status":"closed","ping_status":"closed","template":"page-without-sidebar.php","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"class_list":["post-680","page","type-page","status-publish","hentry"],"jetpack_shortlink":"https:\/\/wp.me\/P1mptf-aY","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=680"}],"version-history":[{"count":25,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/680\/revisions"}],"predecessor-version":[{"id":1216,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/680\/revisions\/1216"}],"up":[{"embeddable":true,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/102"}],"wp:attachment":[{"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}