Insert data in wp_posts table
-
Hi
I’m trying to create custom write panel directly on my wordpress blog, without the dashbord. But I have a little problem. I use the standart INSERT statement to send data to database, but every time I do this only 0 is sent instead of the real value. I have checked several times that the variable has right value but still no successes.
This is my code:
Form:
<form id="lev-post" name="lev-post" method="post" action="?page_id=7"> <input name="lev-post-author-id" type="hidden" value="<?php echo $current_user->ID; ?>" /> <input name="lev-post-post-status" type="hidden" value="publish" /> <input name="lev-post-comment-status" type="hidden" value="open" /> <input name="lev-post-ping-status" type="hidden" value="open" /> <input name="lev-post-type" type="hidden" value="post" /> <input name="lev-post-menu-order" type="hidden" value="0" /> <input name="lev-post-post-parent" type="hidden" value="0" /> <input name="lev-post-post-cat" type="hidden" value="0" /> <label> title: <input type="text" name="lev-post-title" /> </label> <p> <label> content: <textarea name="lev-post-content"></textarea> </label> </p> <p> <label> category: <select name="lev-post-cat"> <option value="1">Cat 1</option> <option value="2">Cat 2</option> <option value="3">Cat 3</option> <option value="4">Cat 4</option> </select> </label> </p> <input name="" type="submit" value="submit" /> </form>
php code on page 7:
<?php $lev_post_author_id = $_POST["lev-post-author-id"]; ?> <?php $lev_post_status = $_POST["lev-post-post-status"]; ?> <?php $lev_comment_status = $_POST["lev-post-comment-status"]; ?> <?php $lev_ping_status = $_POST["lev-post-ping-status"]; ?> <?php $lev_post_type = $_POST["lev-post-type"]; ?> <?php $lev_menu_order = $_POST["lev-post-menu-order"]; ?> <?php $lev_post_parent = $_POST["lev-post-post-parent"]; ?> <?php $lev_post_category = $_POST["lev-post-post-cat"]; ?> <?php $lev_post_title = $_POST["lev-post-title"]; ?> <?php $lev_post_content = $_POST["lev-post-content"]; ?> <?php $lev_post_cat = $_POST["lev-post-cat"]; ?> <?php $table_name = 'wp_posts'; ?> <?php $insert = "INSERT INTO " . $table_name . " (post_author, post_content, post_title, post_category, post_status, comment_status, ping_status, post_parent, menu_order, post_type) " . "VALUES ('" . $current_user->ID . "',araperi,'" . $lev-post-title . "','" . $wpdb->escape($lev_post_category) . "','" . $wpdb->escape($lev_post_status) . "','" . $wpdb->escape($lev_comment_status) . "','" . $wpdb->escape($lev_ping_status) . "','" . $wpdb->escape($lev_post_parent) . "','" . $wpdb->escape($lev_menu_order) . "','" . $wpdb->escape($lev_post_type) . "')"; $results = $wpdb->query( $insert ); ?>
Can anyone tell me what’s wrong with this code?
Thanks in advance
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Insert data in wp_posts table’ is closed to new replies.