Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3438810
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:13:58+00:00 2026-05-18T08:13:58+00:00

<?php $submitted = $_POST[‘submit’]; $post-title= $_POST[‘post_title’]; $post-content= $_POST[‘post_content’]; $new_post = array( ‘post_title’ => ‘$post-title’,

  • 0
<?php

$submitted = $_POST['submit'];
$post-title= $_POST['post_title'];
$post-content= $_POST['post_content'];


$new_post = array(
            'post_title' => '$post-title',
            'post_content' => '$post-content',
            'post_status' => 'publish',
            'post_author' => $user_ID,

        );
if(isset($submitted)){
wp_insert_post($new_post);
}

?>

<form method="post" action=" "> 
<input type="text" name="post_title" size="45" id="input-title"/>

<textarea rows="5" name="post_content" cols="66" id="text-desc"></textarea> 


<input type="hidden" name="cat" value="7,100"/> 

<input class="subput round" type="submit" name="submit" value="Post"/>
</form>

I tested it with out the form and it worked fine. but for somereason i cant seem to get it to work with the form. any ideas?

also what is supposed to go in the action for the form?

thanks for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:13:58+00:00Added an answer on May 18, 2026 at 8:13 am

    This should work.

    <?php 
    if(isset($_POST['new_post']) == '1') {
        $post_title = $_POST['post_title'];
        $post_category = $_POST['cat'];
        $post_content = $_POST['post_content'];
    
        $new_post = array(
              'ID' => '',
              'post_author' => $user->ID, 
              'post_category' => array($post_category),
              'post_content' => $post_content, 
              'post_title' => $post_title,
              'post_status' => 'publish'
            );
    
        $post_id = wp_insert_post($new_post);
    
        // This will redirect you to the newly created post
        $post = get_post($post_id);
        wp_redirect($post->guid);
    }      
    ?>      
    
    <form method="post" action=""> 
        <input type="text" name="post_title" size="45" id="input-title"/>
        <?php wp_dropdown_categories('orderby=name&hide_empty=0&exclude=1&hierarchical=1'); ?>
        <textarea rows="5" name="post_content" cols="66" id="text-desc"></textarea> 
        <input type="hidden" name="new_post" value="1"/> 
        <input class="subput round" type="submit" name="submit" value="Post"/>
    </form>
    

    If input with name new_post and value of 0 then add the post. No action needed for the form, but you should keep the PHP part on the top of the header.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At the top of my file I have PHP Code: if (!ISSET ($_POST['submit'])) which
I have two pages apply.php and registration.php. In registration.php , i have if(isset($_POST['submitted'])){ //validation
HTML <form action='insert.php' method='POST'> <p><b>Client:</b><input type='text' name='idclient'/> <p><b>Total:</b><br /><input type='text' name='total'/> <p><input type='submit' value='Save'
For example, when you submit a post it might say submitted 1 second ago.
<?php require_once 'swift-mailer/lib/swift_required.php'; if (isset($_POST['submit'])) { //File upload // Where the file is going
I have a PHP script which users submit a post and saves in to
In PHP I have the following code that gets a file submitted through CGI:
I'm using PHP's DOMDocument to parse and normalize user-submitted HTML using the loadHTML method
if i have submitted the iphone WebApp at https://adcweb.apple.com/iphone/index.php using ADC Account. i want
I want to extract Urdu phrases out of a user-submitted string in PHP. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.