WordPress.org

Ready to get started?Download WordPress

Forums

Inserting PHP Code in Pages (11 posts)

  1. coated_pill
    Member
    Posted 1 year ago #

    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

    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

  2. coated_pill
    Member
    Posted 1 year ago #

    Sorry.

    Here is the pastebin link

    http://pastebin.com/SgrrpmaT

    Thanks
    Pill

  3. Nathan Hangen
    Member
    Posted 1 year ago #

    I would create a custom page template: 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.

  4. coated_pill
    Member
    Posted 1 year ago #

    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

  5. Nathan Hangen
    Member
    Posted 1 year ago #

    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);

  6. coated_pill
    Member
    Posted 1 year ago #

    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?

  7. Nathan Hangen
    Member
    Posted 1 year ago #

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

  8. coated_pill
    Member
    Posted 1 year ago #

    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.

  9. Nathan Hangen
    Member
    Posted 1 year ago #

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

  10. coated_pill
    Member
    Posted 1 year ago #

    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

  11. Nathan Hangen
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.