I have the following form in a Wordpress page :
<form action="dbsearch.php" method="POST">
<input name="input" type="text"> <select name="search4" size="1">
<option selected="">option1
</option><option>option2
</option><option>option3
</option><option>option5
</option></select>
<input value="Go!" type="submit">
</form>
The form provides the user an interface to search for data stored in a database. I have created a custom page, page_dbsearch.php, by coping page.php and renaming it. There I want to put the php code to query the database and show the results. It is placed in the theme directory. In fact in the child theme directory. I have use the information from
The problem is when I use the form it shows the 404 not found page and not page_dbsearch.php. I have tried changing several things but it did not work.
I am new to Wordpress and I would appreciate it if someone can help me with this.
Thank you.
I have the following form in a Wordpress page :
<form action="dbsearch.php" method="POST">
<input name="input" type="text"> <select name="search4" size="1">
<option selected="">option1
</option><option>option2
</option><option>option3
</option><option>option5
</option></select>
<input value="Go!" type="submit">
</form>
The form provides the user an interface to search for data stored in a database. I have created a custom page, page_dbsearch.php, by coping page.php and renaming it. There I want to put the php code to query the database and show the results. It is placed in the theme directory. In fact in the child theme directory. I have use the information from https://developer.wordpress/themes/template-files-section/page-template-files/page-templates/#creating-a-custom-page-template-for-one-specific-page
The problem is when I use the form it shows the 404 not found page and not page_dbsearch.php. I have tried changing several things but it did not work.
I am new to Wordpress and I would appreciate it if someone can help me with this.
Thank you.
Share Improve this question asked Oct 4, 2015 at 11:33 SKYSKY 11 bronze badge1 Answer
Reset to default 1A helpful clue would be to look at the URL in the address bar of your 404 page. A reliable approach for form action in WP looks like the snippet below.
<form method="post" id="thisform" action="<?php bloginfo('url'); >/dbsearch/">
I would create your page in WP, ensure the page slug is 'dbsearch' as this determines your permalink (http://domain/dbsearch) and the template used. You can of course use any slug you like but match this to your form action. Rename your script 'page_dbsearch.php' to 'page-dbsearch.php'. WP will pick this up as the page template for your results page.
All of your form data will be available in the $_POST array to write your DB query with.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745544581a4632282.html
评论列表(0条)