• Hi Guys,

    I want to create a custom Page template with a bit of my own PHP & MySQL code.

    My code’s functionality:
    • Allow someone to enter a word/phrase into a text input box
    • Connect to a totally separate database, submit the SQL query.
    • Reload the page returned results from the database.

    I know I can get custom PHP code within a Page template, but when you submit my form, it would reload the page with mydomain.com/pageName/?search=something

    This generates a WordPress 404 page saying that page doesn’t exist. If I used $_POST method, where it doesn’t show what was submitted, will it fix the problem?

    If I wanted the URL to display what was searched (bookmarkable), is there a mod_rewrite/.htaccess edit that will allow this to happen without throwing an error?

    Help is immensely appreciated. Working on a huge project for a client. 🙂

    EDIT: PS. I will be using WordPress 3.0, but if I need to use another version for some reason, it’s okay.

Viewing 1 replies (of 1 total)
  • Thread Starter Lasha

    (@lasha)

    So, I found the “WP exec PHP” which allows you to write PHP code within the [exec][/exec] shortcodes. Using $_POST[”], I managed to get a form submitted and display the said data on the same page.

    While this is great, using the $_GET[”] method would be fantastic – this way people can bookmark “search queries” and so forth. Still can’t find a way to get ?var=something to work with the WordPress query string.

Viewing 1 replies (of 1 total)

The topic ‘Custom PHP/MySQL code inside Page template’ is closed to new replies.