示例#1
0
/**
 *   将作文大赛的用户迁移至悠游网数据库中
 */
require 'connect.php';
set_time_limit(0);
//$sql = "SELECT * FROM `users_zuowen` ORDER BY uid ";
$sql = "SELECT * FROM `users_zuowen` ";
$rs = mysql_query($sql);
$user_fields = user_fields();
$i = 0;
while ($row = mysql_fetch_assoc($rs)) {
    if (!user_exits($row['name'])) {
        user_save($user_fields, user_insert($row));
    } else {
        $user_info = user_insert(user_info_change($row));
        user_save($user_fields, $user_info);
    }
    $i++;
}
echo $i . "个用户";
function user_save($fields, $arr)
{
    $query = "\tINSERT INTO `users` (" . implode(",", $fields) . ") VALUES (" . implode(",", $arr) . ") ";
    $rs = mysql_query($query);
    if ($rs) {
        return true;
    } else {
        return false;
    }
}
示例#2
0
    $bio = mysqli_real_escape_string($dbc, $_POST['bio']);
    $password = sha1(SHA1_SALT . $_POST['password']);
    $confirm = sha1(SHA1_SALT . $_POST['confirm']);
    if ($email == false) {
        $_SESSION['register_errors'][] = "Email is not valid";
    } else {
        if (user_email_exists($email)) {
            $_SESSION['register_errors'][] = "Email already exists";
        }
    }
    if ($password != '' && $confirm != '') {
        if ($password != $confirm) {
            $_SESSION['register_errors'][] = "Passwords don't match";
        }
    } else {
        $_SESSION['register_errors'][] = "Please complete password fields";
    }
    if (!isset($_SESSION['register_errors'])) {
        $update = user_insert($name, $email, $bio, $password);
        if ($update) {
            header('Location: index.php?controller=login');
            break;
        } else {
            $_SESSION['register_errors'][] = "Sorry! There has been an error with the database: " . mysqli_error($dbc);
        }
    }
    $_SESSION['name'] = $name;
    $_SESSION['email'] = $email;
    $_SESSION['bio'] = $bio;
    header('Location: index.php?controller=register');
}
示例#3
0
     }
     //If there are input validations, redirect back to the register form
     if ($errflag) {
         $tpl->errors = $errmsg_arr;
     } else {
         // insert to database
         unset($_POST['data']['number1']);
         unset($_POST['data']['number2']);
         unset($_POST['data']['captchatotal']);
         $data = array();
         $data["firstname"] = $first_name;
         $data["lastname"] = $last_name;
         $data["fullname"] = clean($fullname);
         $data["password"] = $n_password;
         $data["user_email"] = $user_email;
         $userdata = user_insert($database, $data);
         if ($userdata) {
             // Send password to email
             $to = $user_email;
             $subject = 'Registration Successfull at ' . site_name;
             $message = 'Hello ' . $first_name . '<br>You have successfully registered at ' . site_name . '. If you have any questions, please do reply back to the same email.' . '<br>' . 'Thanks ' . '<br>' . site_name;
             $sendmail = sendEmail($to, $subject, $message, $shortcodes = null, $from = null, $mail);
             if ($sendmail) {
                 header("Location: " . main_url . "/register/success");
                 exit;
             }
         }
     }
 } catch (Exception $e) {
     // CSRF attack detected
     $result = $e->getMessage() . ' Form ignored.';