Use code to automatically fill the form of a content type I have a content type called Event. I advertise events on my website using this form.
I want to advertise automatically using code.
I have this code which when I run automatically add content. But at the moment it adds the title and the body. 

ini_set('display_errors','1');
ini_set('memory_limit', '512M');
define('DRUPAL_ROOT', getcwd());
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
module_load_include('inc', 'node', 'node.pages');
$node = new stdClass();
//print_r($node);
$title          =  "test post 3";// html_entity_decode($_POST['title']);
// $summary     =   "summarry";//$_POST['summary'];      
$body           =  "This is testing of Automated Script";// $_POST['body']; 
$node-&gt;uid      = '0'; //author
$node-&gt;type     = 'event';    //content type
// $node-&gt;created  = time() - (rand( 1,240) * 60); 
$node-&gt;created  = strtotime("now");
$node-&gt;changed  = strtotime("now"); 
$node-&gt;field_location = 'Oxford';
$node-&gt;title    = $title;
$node-&gt;status   = 0;
$node-&gt;promote  = 0;
$node-&gt;sticky   = 0;
$node-&gt;language = 'und';
$node-&gt;body['und'][0]['value']   = $body;
// $node-&gt;body['und'][0]['summary'] = $summary;
$node-&gt;body['format']  = 'full_html';
node_submit($node);
node_save($node);
print "ok";


How do I add remaining inputs like City, Country, Event Date, Duration, Email Address using code?
You need to do something similar to what you do to set the body of the note for each of your additional field (City, Country, Event Date, Duration, Email Address). The exact data structure for each filed depends on its type.

The general pattern is

$node-&gt;{$field_machine_name}[$language][0] = array(...);


The hard part if figuring the content of the array(...) which is the value of the field. The value of a field is actually always an associative array. Its keys (also called columns) depend on the type of the field. A text field, for instance, as only one value key/column. A taxonomy term reference field has also only one key/column, but named tid.

For instance your city and duration field are a simple text fields whose machine names are field_location and field_duration you can set their values with

$node-&gt;field_location['und'][0] =  array('value' =&gt; 'Oxford');
$node-&gt;field_duration['und'][0] =  array('value' =&gt; '2');


You country field is a Taxonomy Term Reference field, its value can be set with

$node-&gt;field_country['und'][0] = array('tid' =&gt; 1);


Where 1 is the ID of a term in the proper taxonomy vocabulary.

If you were using an single address field name field_location to store the location, the code should be something like

$node-&gt;field_location['und'][0] = array(
  'country' =&gt; 'GB',
  'locality' =&gt;  'Oxford',
);


The structure to set a date field depends on the date format. If the field uses the ISO format, you can set it with something like

$node-&gt;field_date['und'][0] =  array(
  // The start date.
  'value' =&gt; '2014-04-02T10:00:00',
  // The end date.
  'value2' =&gt; '2014-04-02T11:00:00',
);


To discover the structure of a field, I suggest to use the Devel module. It provides a devel tab on node that let you explore the structure of the $node object for an existing node. You can also check the hook_field_schema() implementation of the module defining the field type.