I found some code on this site for wp_insert_post and I got it working. I did find the post in the category where I would expect it to be. Then I changed the code example to include information from my form on the page and the code fails.
Here is the sample code I got from this site that does work.
<?php if(isset($_POST['new_reservation']) == '1') {
$post_title = "My Post";
//$post_category = 'reservations';
$my_post = array();
$my_post['post_title'] = "My Post";
$my_post['post_content'] = 'This is my post.';
$my_post['post_status'] = 'publish';
$my_post['post_author'] = 1;
$my_post['post_category'] = array(9);
wp_insert_post($my_post);
//update_post_meta($post_id, 'reservations', $customer);
} ?>
so then I changed things to this in order to get the name of the post from the form
<form action="" method="post" name="reservations" id="reservations" enctype="multipart/form-data">
<table width="474" border="0" cellspacing="0" cellpadding="0" id="reserve">
<tr>
<td class="formTitles"><img src="<?php bloginfo('template_directory');?>/images/name.png" alt="name" width="47" height="10" /></td>
<td class="formTitles"><img src="<?php bloginfo('template_directory');?>/images/date.png" alt="date" width="43" height="10" /></td>
</tr>
<tr>
<td class="formInput"><input type="text" id="name" name="name" /></td>
<input type="hidden" name="new_reservation" value="1" /><br />
<td><input type="submit" name="reserveSubmit" id="reserveSubmit" class="button" value="submit"/> <span class="regularText"> or <a class="clearForm" href="#" onclick="reservation.reset();">Clear Form</a> </span></td>
</tr>
</table>
<?php if(isset($_POST['new_reservation']) == '1') {
$post_title = $_POST['name'];
$post_category = 'reservations';
$my_post = array();
$my_post['post_title'] = $post_title;
$my_post['post_content'] = 'This is my post.';
$my_post['post_status'] = 'publish';
$my_post['post_author'] = 1;
$my_post['post_category'] = array(9);// Insert the post into the databasewp_insert_post( $my_post );"
wp_insert_post($my_post);
//update_post_meta($post_id, 'reservations', $customer);
} ?>
The code fails whenever I try to use the name variable as the name of the post
wp_insert_post
line as well. And, right before thewp_insert_post
, do avar_dump($my_post);
to see what is contained in the variable that you are inserting.