how do i use hook_block_view or something else to generate block view for my custom form module in drupal 7
<p>I have created a form using hook_form() in drupal 7, it can be accessed as a page for which i used hook_menu(), I need the form to be used as a block.Here is my code </p>

<pre><code>  function contact_form_form($form, &amp;$form_state) {  //     

 $form['name'] = array(
'#type' =&gt; 'textfield', //you can find a list of available types in the form api
'#title' =&gt; 'Name',
'#size' =&gt; 20,
'#maxlength' =&gt; 15,
'#required' =&gt; TRUE, //make this field required 
 );


 $form['mobileNo'] = array(
'#type' =&gt; 'textfield', //you can find a list of available types in the form api
'#title' =&gt; 'Mobile Number',
'#size' =&gt; 10,
'#maxlength' =&gt; 10,
'#required' =&gt; TRUE, //make this field required 
);

 $form['email'] = array(
'#title' =&gt; 'Email id',
'#type' =&gt; 'textfield' ,
'#required' =&gt; TRUE ,
 );

 $form['address'] = array(
'#title' =&gt; 'Address',
'#type' =&gt; 'textarea',
'#cols' =&gt; 60,
'#resizable' =&gt; TRUE,
'#rows' =&gt; 5,
'#required' =&gt; TRUE ,
  );   


 $form['image'] = array(
'#type' =&gt; 'file',
'#name' =&gt; 'custom_content_block_image',
'#title' =&gt; t('Block image'),
'#size' =&gt; 40,
'#description' =&gt; t("Upload a image.Only JPG, JPEG, PNG &amp; GIF files are allowed."),
'#upload_location' =&gt; 'public://'
 ); 

 $form['submit_button'] = array(
'#type' =&gt; 'submit',
'#value' =&gt; t('Click Here!'),
  );

 return $form;
 }
</code></pre>

<p>// the hook_submit() which i have used</p>

<pre><code>   function contact_form_form_submit($form, &amp;$form_state) {

   $target_dir = "uploads/";
   $target_file = $target_dir . basename($_FILES["custom_content_block_image"]["name"]);

   drupal_set_message('this is inside submit   
  drupal_set_message('this is inside submit 
  $fileName = $_FILES['custom_content_block_image']['name'];
  $tmpName  = $_FILES['custom_content_block_image']['tmp_name'];
  $fileSize = $_FILES['custom_content_block_image']['size'];
  $fileType = $_FILES['custom_content_block_image']['type'];

  $fp      = fopen($tmpName, 'r'); 
  $content = fread($fp, filesize($tmpName));
  $content = addslashes($content);
  fclose($fp);

  if(!get_magic_quotes_gpc())
  {
    $fileName = addslashes($fileName);
  }
</code></pre>

<p>inserting all the acquired data in the drupals database created inside .install file </p>

<pre><code>      try {
     db_insert('contact_us')
  -&gt;fields(array(
   'name' =&gt; $form_state['values']['name'],
   'mobile_no' =&gt; $form_state['values']['mobileNo'], 
   'email' =&gt; $form_state['values']['email'],
   'address' =&gt; $form_state['values']['address'],
   'image' =&gt; $content,
   'imageName' =&gt; $fileName,
   'imageSize' =&gt; $fileSize, 
   'imageType' =&gt; $fileType       
 ))
 -&gt;execute();
 }
  catch (PDOException $e) {
  //print_r($e-&gt;getMessage());
  drupal_set_message('this is after db_insert &lt;pre&gt;'.print_r($e-&gt;getMessage(),true).'&lt;/pre&gt;');
 }
</code></pre>

<p>}</p>