How to add a checkbox for contact page in drupal? I added a checkbox in my register form in drupal name
"do you want a contact form?"

If the user checked it then in profile page a menu for contact is shown but if it says no then in the same page "Contact:Not Reachable " is shown.
You can do this with Drupal core Contact module and with small custom code. As Drupal 7 contact module provide personal contact form and site wide contact form. See here Working with the Contact Form. You can enable Personal contact form by default for each user and hide the Contact Settings under /user/[uid]/edit which will be enabled for all users. Then with custom code you can show and hide Contact form Based on the Checkbox you added.

The setting shown in below screenshot will be enabled for all users by default then you will hide this setting with custom code. Because there is no configuration to show this setting on user registration form.



Steps:


Enable Drupal core Contact module.
Then Goto admin/config/people/accounts and enable Enable the personal contact form by default for new users. setting.

Give the following permission to Authenticated Users


View user profiles
Use users' personal contact forms

Add the checkbox field in User profile and enable that on registration form. Assuming the field name is field_do_you_want_contact_form.
Then in custom module with hook_form_alter hide the personal contact form setting and show/hide the contact form based on the value of checkbox.

//custom.module    
function custom_form_alter(&amp;$form, &amp;$form_state, $form_id){

  // Hide the personal contact form setting under /user/[uid]/edit

  if ($form_id == 'user_profile_form') {
   $form['contact']['#access'] = FALSE;
  }

 // Show the Contact form Or custom message under contact tab based on checkbox value.
  if ($form_id == 'contact_personal_form') {
    $user = $form['recipient']['#value'];
    $wrapper = entity_metadata_wrapper('user', $user);
    $do_you_want_contact_form = $wrapper-&gt;field_do_you_want_contact_form-&gt;value();

    if (!$do_you_want_contact_form) {
    // hide all the contact form element.
        $form['name']['#access'] = FALSE;
        $form['mail']['#access'] = FALSE;
        $form['to']['#access'] = FALSE;
        $form['subject']['#access'] = FALSE;
        $form['message']['#access'] = FALSE;
        $form['copy']['#access'] = FALSE;
        $form['actions']['#access'] = FALSE;

    // Add custom message
        $form['not_rechable']['#markup'] = t('Contact: not rechable');
    }
  }
}