I can’t comment yet, so I’ll tell you here what you can change immediately:
$countryinfo = $wpdb->get_row("SELECT * FROM wp_num_countries WHERE countryID = ".$country_id);
to
$countryinfo = $wpdb->get_row($wpdb->prepare("SELECT * FROM wp_num_countries WHERE countryID = %d", $country_id));
because you directly use $_POST variable, so $wpdb->prepare will format and prepare your query string. But that code looks fine for me (you should only use indents as they are expected, because of easier reading 🙂 )
If I were you, I would make a page and put this code in it. For example, page-countries.php, and page with title Countries, slug ‘countries’. In that form put submit button and that’s it. Also, I would test for if(isset($_POST['country'])) instead of if($_POST['country']).
Related Posts:
- WordPress form submit to custom page template does not work
- Contact Form on WordPress Sites?
- Page returns 404 with POST variables, but not without
- Custom templates not showing up in template dropdown
- Conditional tag to check if ‘page.php’ is being used?
- A check for if is parent page, if has children, if has grandchildren
- WordPress page edit does not save selected template
- Set page template automatically based on parent
- Is there a default template file for child pages / subpages?
- How to display code if it is not certain pages?
- Multiple areas of dynamic content in a page
- How do I set and list page_template with wpcli?
- How do I modify this page template to show subpage excerpts (not post excerpts)?
- Limit number of pages that use a specific template?
- How to inject custom url path for page ?
- Dynamically Load Styles and Scripts from Theme Functions.php
- Add custom admin menu item for pages using a certain template
- Different “Text Widgets” in Sidebar on Many Different Pages?
- What’s the most minimal way in which a page can be hooked into WP?
- How do I create multiple page while active a theme
- How to make certain page templates visible to admin only
- How to dynamically save a selected option from page “Templates” selectbox?
- How to add meta boxes to Pages
- Form action redirect to the same page
- Custom page template not working
- Dynamically change page that loads
- Creating a form contact page?
- How do I pass data from page content to the underlying PHP template
- load common thank you template with different content for different pages
- Password Protected Page Title
- Send mail from page using wp_mail
- Removing the TinyMCE editor for a given page template
- Determine page content based on page parent
- Displaying page content in category archive (archive.php)
- Location-Based Pages displaying results near customer
- Missing ‘Page Attributes’ in page edit
- Could be a namespace conflict (?) with login form and register form on the same page
- Pass data from one page to anothe file/page in wordpress
- Custom page template for multiple pages
- My custom template page not loading content inside it?
- Get parent of current page
- How to edit a HTML list in WordPress?
- Custom page with queries returns 404
- How to capture GET argument on static page
- JQuery Plugins in WordPress
- the_content of template page
- Remove comment section from new page
- WordPress theme: Add page content to the bottom of the Contact form
- Dynamic href link to Contact Page
- Create page template with some static contents
- WordPress 3.2 – removed ability to select a page template in the page attributes when adding a new page?
- Use same page-mypage.php template for several pages
- Avoid pages losing template association on site re-deploy
- How do you implement a page template automatically being applied to a page?
- How do I edit text displayed on my browser tab?
- How to create different template designs for different pages in WordPress [closed]
- Different css file not working for the page template I created
- require_once not working
- Custom form not showing in correct place on page
- Displaying posts on homepage – Template Page
- Page templates in subdirectories and auto generator
- WordPress Page doesn’t load the template selected
- Use page template for custom $_GET content
- How to bypass 404 for certain pages/posts?
- Print page content with formatting when doing custom SQL query
- Outputting content from page
- Custom folder for wordpress page templates
- Authors posts on a author created page
- Static Website No Titles But Still Nav
- custom page templating in WordPress
- page template – undefined structure in source code
- Suggestions: Customizable header image and style colors that are different for each page
- My pages are using my Index.php and not my page.php
- WordPress custom pages in a folder
- Create page template
- WordPress blog posts template bug [closed]
- Adding styles/scripts to specific page
- How to detect if some page template has been selected
- Using external DB within wordpress
- What’s the best way to manage sections on a page?
- WordPress Page All Content In Template Good Or Bad Convention?
- How do you assign custom template for Posts page (under Front page displays setting)
- Content template when adding a new page
- custom page or standalone page?
- Avada Theme – Display results from a specific category [closed]
- How to display time when page is created and edited
- Call a function on every wordpress pages only
- Specify parent page template
- WP Template Hierarchy – Need help choosing the correct templates
- Custom Filter using meta_value in wordpress admin list not working
- how bbPress and buddypress add their own page templates to the page template drop down on the page editing screen
- Showing certain page without redirection
- Page template with custom html fields inside a content
- link a custom page into menu
- How to get from sql query page id and retrieve it url and title
- Load new Posts on Scroll on Page
- exclude page element from specific pages
- Edit the text location of a form
- May I know where to edit the tax rate?
- Site Library issue