Submit drupal form & node_save using hook_submit_form in Drupal 7

function user_identity_form_submit($form, &$form_state) {
  global $user;
  global $base_url;
  //variable_set('identity_image', $form_state['values']['identity_image']);
  $file = file_load($form_state['values']['identity_image']);
  if($file){
    $file->status = FILE_STATUS_PERMANENT;
    file_save($file);
    file_usage_add($file, 'user_identity', 'user_identity', $file->uid);

    //create node identity
    $node = new stdClass();
    $node->type = 'user_identity';
    node_object_prepare($node);
    $node->title = 'Identity: '.$user->name;
    $node->field_photo_document['und'][] = (array)$file;
    $node->language = LANGUAGE_NONE;
    $node->uid = $user->uid;
    $node->status = 0;
    node_save($node);
...

Display image after upload using managed_file in Drupal 7

function MODULE_NAME_theme() {
    return array(
      'MODULE_NAME_image' => array(
        'render element' => 'form',
      ),
    );
}

function theme_MODULE_NAME_image($variables) {
    $form = $variables['form'];
    if(isset($form['#file']->uri))
        $form['identity_image']['#markup'] = theme('image_style', array('style_name' => 'thumbnail', 'path' => file_build_uri(file_uri_target($form['#file']->uri))));
    $output = drupal_render_children($form);
    return $output;
}

function MODULE_NAME_form($form, &$form_state) {
    $form = array();
        $form = array();
        $form['identity_image'] = array(
          '#title' => t('Upload photo document'),
          '#type' => 'managed_file',
          '#required' => true,
          '#upload_location' => 'public://identity/'.$order->uid.'/',
          '#upload_validators' => array(
            'file_validate_extensions' => array('jpg png jpeg'),
          ),
          '#theme' => 'MODULE_NAME_image',
        );
        $form['submit'] = array(
          '#type' => 'submit',
          '#value' => t('Approved'),
        );
return $form;
}

Drupal Custom php file

define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

// Now you can use drupal database with drupal's dbal:
// Unlock user admin if blocked
db_query("UPDATE {users} set status = 1 where uid = 1");

$nid = db_insert('table')
->fields(array(
  'numbers' => ('23456')
  ))
->execute();
drupal_set_message(t('Content was added'));

Fields setting stored in drupal 7

Base field data is in field_config, and instance data is in field_config_instance. Rather than modifying them manually, though, you can always use the API:

$field = field_info_field('field_name');
$field['key'] = $new_value;
field_update_field($field);

Or for an instance

$instance = field_info_instance('node', 'field_name', 'article');
$instance['key'] = $new_value;
field_update_instance($instance);

Using the API will clear the appropriate caches, and it’s just a better idea than editing the data manually.

Either way, make sure to backup the database first in case something goes horribly wrong.

Fix Restore databases from Backup & Migrate module with Autoslave module Drupal

In file: /sites/all/modules/third-party/backup_migrate/includes/sources.db.mysql.inc

/**
* Backup the databases to a file.
*/
function _restore_db_from_file($file, $settings) {
$num = 0;

#++
include_once("/var/www/html/drupal/includes/database/autoslave/database.inc");

#--
// if ($file->open() && $conn = $this->_get_db_connection()) {
#++
if ($file->open() && $conn = $this->_get_db_connection()->getMasterConnection()) {

// Read one line at a time and run the query.
while ($line = $this->_read_sql_command_from_file($file)) {
if (_backup_migrate_check_timeout()) {
return FALSE;
}

if ($line) {
// Prepeare and exexute the statement instead of the api function to avoid substitution of '{' etc.
$stmt = $conn->prepare($line);
$stmt->execute();
$num++;
}
}
// Close the file with fclose/gzclose.
$file->close();
}
else {
drupal_set_message(t("Unable to open file %file to restore database", array("%file" => $file->filepath())), 'error');
$num = FALSE;
}
return $num;
}

Onclick copy to clipboard javascript

<input type="text" id="copyTarget" value="Text to Copy"> <button id="copyButton">Copy</button><br><br>
<input type="text" placeholder="Click here and press Ctrl-V to see clipboard contents">

document.getElementById("copyButton").addEventListener("click", function() {
copyToClipboard(document.getElementById("copyTarget"));
});

function copyToClipboard(elem) {
// create hidden text element, if it doesn't already exist
var targetId = "_hiddenCopyText_";
var isInput = elem.tagName === "INPUT" || elem.tagName === "TEXTAREA";
var origSelectionStart, origSelectionEnd;
if (isInput) {
// can just use the original source element for the selection and copy
target = elem;
origSelectionStart = elem.selectionStart;
origSelectionEnd = elem.selectionEnd;
} else {
// must use a temporary form element for the selection and copy
target = document.getElementById(targetId);
if (!target) {
var target = document.createElement("textarea");
target.style.position = "absolute";
target.style.left = "-9999px";
target.style.top = "0";
target.id = targetId;
document.body.appendChild(target);
}
target.textContent = elem.textContent;
}
// select the content
var currentFocus = document.activeElement;
target.focus();
target.setSelectionRange(0, target.value.length);

// copy the selection
var succeed;
try {
succeed = document.execCommand("copy");
} catch(e) {
succeed = false;
}
// restore original focus
if (currentFocus && typeof currentFocus.focus === "function") {
currentFocus.focus();
}

if (isInput) {
// restore prior selection
elem.setSelectionRange(origSelectionStart, origSelectionEnd);
} else {
// clear temporary content
target.textContent = "";
}
return succeed;
}