Support » Plugins and Hacks » Inserting PHP Code in Pages

  • Hi.

    I have a problem regarding inserting a form (online booking) into my pages.

    It uses PHP language.

    The form can be found here :

    I would like to transfer the form into wordpress page since the page is in php format.

    The code is

    [That’s way too much code to post on these forums – please see the forum guidelines and use a pastebin.

    form action direct to onlinebooking2.php

    This form also call from database.

    Is there a way I can do that in pages. I am not that technical doing it in wordpress.

    Any help will be appreciated.


Viewing 10 replies - 1 through 10 (of 10 total)
  • Sorry.

    Here is the pastebin link


    I would create a custom page template: and then select that template for your form. From there, you could place this under the_content(); which might work, but without testing the code, I can’t say.

    Typically, I’d recommend that you use wp_enqueue_scripts to add the js, checking for that page template before loading.

    Thanks for the reply.

    Associated with my question, how do I connect remotely to my original database?

    When I try yo load the custom page this error show.

    Warning: mysql_connect() [function.mysql-connect]: Access denied for user ‘xxxxxx’@’localhost’ (using password: YES) in /home/xxxxxxx/public_html/xxxxx/wp-content/themes/dynamik-gen/my-templates/function.php on line 30

    Best bet is to use the $wpdb global and rewrite the queries to use it, for example:

    $result = mysql_query(“SELECT * FROM unit_size”) or die(mysql_error());


    global $wpdb;
    $sql = ‘SELECT * FROM unit_size’;
    $res = $wpdb->get_results($sql);

    Thanks again.

    I was wondering if I can use the same database that already exist in the original site.

    Like, changing the value of MySQL in function.php?

    yeah, you should be able to do that, though you’ll need to create a table and adjust the queries accordingly.

    I mean, I’ll just use the table that already exist in the original site and no need to create a new table?

    Is it possible? Like remote access to the database of the original site by changing the value in functions.php..

    I was wondering what value would i use in localhost?

    Thanks again.

    you’d need to use the IP address, db name, user, pw, etc. It’s not the most secure way.

    Last question.

    How can I know the ip address of the site or the hosting site in order to replace the localhost item in the script?

    I would like to test the script if it will appear properly in the browser.

    Thanks for helping out and for your patience Sir Nathan.

    It is highly appreciated.


    you could do a reverse IP lookup, or just ping it in your terminal and you’ll get an IP.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Inserting PHP Code in Pages’ is closed to new replies.