I have two php websites, I have a form in one custom page which simply inserts data in one database ….all I want is to insert this same data in my second site which is wordpress..to be inserted as a new post.
Ex: in the form i fill title, date, etc in my 1st databse which is a simple php site, now i want is same post gets inserted in my wordpress databse…title as title and data as date.
Don’t want to use XML etc..as i have both database under same hosting so i have access to both database with single php form…all i want to know is dependent tables for wordpress entry but with an example 🙂
Thanks
Luckyy
You can use
WordPress
‘s functionality outside ofWordPress
, just create a subfolder in your site’s root directory, i.e.http://yoursite.com/blog
and uploadWordPress
in yourblog
sub-folder. For more read this on Codex.Then, in order to transform regular
PHP
pages into ones that utilize WordPress, you need to add either of the following code snippets to the start of each page.Now look at the wp_insert_post function on
Codex
to know that how you can insert post intoWordPress
pragmatically, Also another simplified article if it helps. Now, you know how to useWordPress
‘s functions/functionality out side ofwordpress
and also you know how you can usewp_insert_post
, now just setup aPHP
page with a form and submit the form usingPOST
methos and the prepare the data for the post to be inserted into theWordPress
database (validate inputs) and finally insert usingwp_insert_post
function. Please read this on codex for more information.You need to create a PHP script on the WordPress site that accepts a $_POST from the non-Wordpress site’s form.
WordPress site
/_static/receiver.php (I always put scripts like this in a folder named _static in the WP root folder):
Non-Wordpress site form: