WordPress.org

Support

Support » How-To and Troubleshooting » HTML Form to > New Post

HTML Form to > New Post

  • I am looking to have a form I have created, use the field values and submit them into a new post..

    I actually want them to create a new topic in bbpress, but it appears bbpress is using the wordpress wp_posts tables anyways. It looks like only the post_type is the difference.

    I have got the form fields to post like this, with 1,2,3,4,5 being the element names.. Although, it will not create a new post or topic doing it this way, so I must be missing something. Any help would be very much appreciated!

    Thanks

    <?php
    $dbhost  = 'localhost';
    $dbname  = '***';
    $dbuser  = '***';
    $dbpass  = '***'; 
    
    $con = mysql_connect($dbhost, $dbuser, $dbpass);
    
    if($con == FALSE)
    {
        echo 'Cannot connect to database' . mysql_error();
    }
    else
    {
        echo 'Connected to database';
    }
    
    mysql_select_db($dbname, $con);
    
    $sql="INSERT INTO wp_posts (post_type, post_parent, post_title, post_content, post_author)
    VALUES
    ('$_POST[2]','$_POST[2]','$_POST[3]','$_POST[4]','$_POST[5]')";
    
    if (!mysql_query($sql, $con))
    {
        die('Error: ' . mysql_error());
    }
    echo "Form Submitted";
    
    mysql_close($con)
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘HTML Form to > New Post’ is closed to new replies.
Skip to toolbar