Accidentally, I discovered that whenever there is a backslash at the end of a search, the page after clicking submit will return a broken search form.
In my case, the submit button turned into a text area.
Using google chrome’s “inspect element” I saw that my search form turned into this:
<form method="get" action=""> <input type="hidden" name="type" value="books"> <input type="text" name="search" value="\"> <input type="> </form> </div></div></div><div id=" sidebar"="" class="sidebar widget-area"></form>
The following code is my form. I am guessing that I need to sanitize/escape the value from the input type text? But why isn’t esc_attr() working? I am very new at this. Please help. I will extremely appreciate it!
<form action="" method="get"> <input type="text" name="search" value="<?php echo esc_attr(stripslashes($_GET['search'])); ?>"> <input type="submit" value="Search"> <input type="checkbox" name="title"> </form>
P.S. I am using this custom search form to search custom fields and display the resulting custom post types using Pods Plugin. It doesn’t appear that this is a Pods plugin issue though.
Also, this doesn’t appear to be a conflict from another theme or plugin.
- The topic ‘Backslash at the end of searchword breaks custom search form’ is closed to new replies.