本文整理汇总了PHP中DB_Functions::addUser方法的典型用法代码示例。如果您正苦于以下问题:PHP DB_Functions::addUser方法的具体用法?PHP DB_Functions::addUser怎么用?PHP DB_Functions::addUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_Functions
的用法示例。
在下文中一共展示了DB_Functions::addUser方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
// json response array
$response = array("error" => FALSE);
if (isset($_POST['name']) && isset($_POST['email']) && isset($_POST['password'])) {
// receiving the post params
$name = $_POST['name'];
$email = $_POST['email'];
$password = $_POST['password'];
// check if user is already existed with the same email
if ($db->isUserExisted($email)) {
// user already existed
$response["error"] = TRUE;
$response["error_msg"] = "User already existed with " . $email;
echo json_encode($response);
} else {
// create a new user
$user = $db->addUser($name, $email, $password);
if ($user) {
// user stored successfully
$response["error"] = FALSE;
$response["uid"] = $user["unique_id"];
$response["user"]["name"] = $user["name"];
$response["user"]["email"] = $user["email"];
$response["user"]["created_at"] = $user["created_at"];
$response["user"]["updated_at"] = $user["updated_at"];
echo json_encode($response);
} else {
// user failed to store
$response["error"] = TRUE;
$response["error_msg"] = "Unknown error occurred in registration!";
echo json_encode($response);
}
示例2: array
require_once 'include/DB_Functions.php';
$db = new DB_Functions();
// json response array
$response = array("error" => 0);
if (isset($_POST['name']) && isset($_POST['email']) && isset($_POST['phoneno']) && isset($_POST['passHash'])) {
// receiving the post params
$name = $_POST['name'];
$passHash = $_POST['passHash'];
$email = $_POST['email'];
$phoneno = $_POST['phoneno'];
if ($db->isUserExisted($phoneno) == true) {
$response["error"] = 1;
$response["error_msg"] = "User already exists!";
echo json_encode($response);
} else {
if ($db->addUser($name, $passHash, $phoneno, $email)) {
$user = $db->getUserDetails($phoneno);
if ($user != NULL) {
$response["error"] = 0;
$response["error_msg"] = "Register successfully done! ";
echo json_encode($response);
} else {
$response["error"] = 2;
$response["error_msg"] = "User not registered! DB Error!";
echo json_encode($response);
}
}
}
} else {
// required post params is missing
$response["error"] = 3;
示例3:
$name = $_POST['name'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
$empid = $_POST['empid'];
$department = $_POST['department'];
$designation = $_POST['designation'];
if ($db->isUserExisted($username) == true) {
$response["error"] = 1;
$response["error_msg"] = "User already exists!";
echo '<script language="javascript">';
echo 'alert("User already exists!")';
echo '</script>';
echo "<script>setTimeout(\"location.href = 'registration.html';\",0);</script>";
} else {
if ($db->addUser($name, $email, $username, $password, $empid, $department, $designation)) {
$user = $db->getUserDetails($username);
if ($user != NULL) {
$response["error"] = 0;
$response["error_msg"] = "Register successfully done! ";
echo '<script language="javascript">';
echo 'alert("Register done successfully")';
echo '</script>';
echo "<script>setTimeout(\"location.href = 'index.html';\",0);</script>";
} else {
$response["error"] = 2;
$response["error_msg"] = "User not registered! DB Error!";
echo '<script language="javascript">';
echo 'alert("User not registered! DB Error!")';
echo '</script>';
echo "<script>setTimeout(\"location.href = 'registration.html';\",0);</script>";
示例4: array
<?php
require_once 'include/DB_Functions.php';
$db = new DB_Functions();
// json response array
$response = array("error" => FALSE);
if (isset($_POST['uname']) && isset($_POST['uage']) && isset($_POST['uemailID']) && isset($_POST['upwd'])) {
// receiving the post params
$fullName = $_POST['uname'];
$age = $_POST['uage'];
$emailID = $_POST['uemailID'];
$pwd = $_POST['upwd'];
// create a new event
$user = $db->addUser($fullName, $age, $emailID, $pwd);
if ($user) {
// user stored successfully
$response["error"] = FALSE;
$response["uid"] = $user["userID"];
$response["user"]["fullName"] = $user["fullName"];
$response["user"]["age"] = $user["age"];
$response["user"]["emailID"] = $user["emailID"];
$response["user"]["pwd"] = $user["pwd"];
echo json_encode($response);
} else {
// user failed to store
$response["error"] = TRUE;
$response["error_msg"] = "User is already registered";
echo json_encode($response);
}
} else {
$response["error"] = TRUE;
示例5: json_encode
<?php
if (isset($_POST["gcm_token"])) {
$gcm_token = $_POST["gcm_token"];
// Store user details in db
include_once 'db_functions.php';
$db = new DB_Functions();
$res = $db->addUser($gcm_token);
if ($res) {
$response['message'] = 'Utilisateur enregistré !';
$response['success'] = 1;
} else {
$response['message'] = 'Utilisateur non enregistré !';
$response['success'] = 0;
}
} else {
$response['message'] = "Je crois que tu t'es planté mon gars...";
$response['success'] = 0;
}
echo json_encode($response);