Title: Inserting PHP Code in Pages
Last modified: August 21, 2016

---

# Inserting PHP Code in Pages

 *  [coated_pill](https://wordpress.org/support/users/coated_pill/)
 * (@coated_pill)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/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 : [http://www.melbourneministorage.com.au/onlinebooking.php](http://www.melbourneministorage.com.au/onlinebooking.php)
 * 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.
 * Thanks.
    Pill

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Thread Starter [coated_pill](https://wordpress.org/support/users/coated_pill/)
 * (@coated_pill)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/inserting-php-code-in-pages/#post-3995273)
 * Sorry.
 * Here is the pastebin link
 * [http://pastebin.com/SgrrpmaT](http://pastebin.com/SgrrpmaT)
 * Thanks
    Pill
 *  [Nathan Hangen](https://wordpress.org/support/users/nhangen/)
 * (@nhangen)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/inserting-php-code-in-pages/#post-3995288)
 * I would create a custom page template: [http://codex.wordpress.org/Page_Templates](http://codex.wordpress.org/Page_Templates)
   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.
 *  Thread Starter [coated_pill](https://wordpress.org/support/users/coated_pill/)
 * (@coated_pill)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/inserting-php-code-in-pages/#post-3995312)
 * 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
 *  [Nathan Hangen](https://wordpress.org/support/users/nhangen/)
 * (@nhangen)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/inserting-php-code-in-pages/#post-3995362)
 * 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);
 *  Thread Starter [coated_pill](https://wordpress.org/support/users/coated_pill/)
 * (@coated_pill)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/inserting-php-code-in-pages/#post-3995380)
 * 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?
 *  [Nathan Hangen](https://wordpress.org/support/users/nhangen/)
 * (@nhangen)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/inserting-php-code-in-pages/#post-3995383)
 * yeah, you should be able to do that, though you’ll need to create a table and
   adjust the queries accordingly.
 *  Thread Starter [coated_pill](https://wordpress.org/support/users/coated_pill/)
 * (@coated_pill)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/inserting-php-code-in-pages/#post-3995384)
 * 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.
 *  [Nathan Hangen](https://wordpress.org/support/users/nhangen/)
 * (@nhangen)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/inserting-php-code-in-pages/#post-3995386)
 * you’d need to use the IP address, db name, user, pw, etc. It’s not the most secure
   way.
 *  Thread Starter [coated_pill](https://wordpress.org/support/users/coated_pill/)
 * (@coated_pill)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/inserting-php-code-in-pages/#post-3995420)
 * 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.
 * Pill
 *  [Nathan Hangen](https://wordpress.org/support/users/nhangen/)
 * (@nhangen)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/inserting-php-code-in-pages/#post-3995437)
 * 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.

 * 10 replies
 * 2 participants
 * Last reply from: [Nathan Hangen](https://wordpress.org/support/users/nhangen/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/inserting-php-code-in-pages/#post-3995437)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
