本文整理汇总了PHP中DbHandler::createUser方法的典型用法代码示例。如果您正苦于以下问题:PHP DbHandler::createUser方法的具体用法?PHP DbHandler::createUser怎么用?PHP DbHandler::createUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbHandler
的用法示例。
在下文中一共展示了DbHandler::createUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
* params - name, email, password
*/
$app->post('/register', function () use($app) {
// check for required params
verifyRequiredParams(array('name', 'username', 'email', 'password', 'policy'));
$response = array();
// reading post params
$name = $app->request->post('name');
$username = $app->request->post('username');
$email = $app->request->post('email');
$password = $app->request->post('password');
$policy = $app->request->post('policy');
// validating email address
validateEmail($email);
$db = new DbHandler();
$res = $db->createUser($name, $username, $email, $password, $policy);
if ($res == USER_CREATED_SUCCESSFULLY) {
$response["error"] = false;
$response["message"] = "You are successfully registered";
// email a welcome email to the new user
emailNewUser($email, $name, $username, $policy);
echoRespnse(201, $response);
} else {
if ($res == USER_CREATE_FAILED) {
$response["error"] = true;
$response["message"] = "Oops! An error occurred while registereing";
echoRespnse(200, $response);
} else {
if ($res == USER_ALREADY_EXISTED) {
$response["error"] = true;
$response["message"] = "Sorry, this username already exists";
示例2: function
* url - /register
* method - POST
* params - name, email, password
*/
$app->post('/register', function () use($app) {
// check for required params
verifyRequiredParams(array('name', 'email', 'password'));
$response = array();
// reading post params
$name = $app->request->post('name');
$email = $app->request->post('email');
$password = $app->request->post('password');
// validating email address
validateEmail($email);
$db = new DbHandler();
$res = $db->createUser($name, $email, $password);
if ($res == USER_CREATED_SUCCESSFULLY) {
$response["error"] = false;
$response["message"] = "You are successfully registered";
} else {
if ($res == USER_CREATE_FAILED) {
$response["error"] = true;
$response["message"] = "Oops! An error occurred while registereing";
} else {
if ($res == USER_ALREADY_EXISTED) {
$response["error"] = true;
$response["message"] = "Sorry, this email already existed";
}
}
}
// echo json response
示例3: verifyRequiredParams
verifyRequiredParams(array('name', 'email', 'password', 'first_name', 'last_name', 'date_of_birth', 'role', 'gender', 'city'));
$response = array();
// reading post params
$name = $app->request->post('name');
$email = $app->request->post('email');
$password = $app->request->post('password');
$first_name = $app->request->post('first_name');
$last_name = $app->request->post('last_name');
$date_of_birth = $app->request->post('date_of_birth');
$role = $app->request->post('role');
$gender = $app->request->post('gender');
$city = $app->request->post('city');
// validating email address
validateEmail($email);
$db = new DbHandler();
$res = $db->createUser($name, $email, $password, $first_name, $last_name, $date_of_birth, $role, $gender, $city);
if ($res == USER_CREATED_SUCCESSFULLY) {
$response["error"] = false;
$response["message"] = "You are successfully registered";
echoRespnse(201, $response);
} else {
if ($res == USER_CREATE_FAILED) {
$response["error"] = true;
$response["message"] = "Oops! An error occurred while registereing";
echoRespnse(200, $response);
} else {
if ($res == USER_ALREADY_EXISTED) {
$response["error"] = true;
$response["message"] = "Sorry, this email already existed";
echoRespnse(200, $response);
}
示例4: function
require_once 'include/DbHandler.php';
require_once 'include/PassHash.php';
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
/**
* User Creation
*/
$app->post('/user', function () use($app) {
$response = array();
$json = $app->request->getBody();
$input = json_decode($json, true);
// parse the JSON into an assoc. array
$db = new DbHandler();
$res = $db->createUser($input);
if ($res == USER_CREATED_SUCCESSFULLY) {
$response = array("error" => false, "message" => "You are successfully registered");
echoResponse(201, $response);
} else {
if ($res == USER_CREATE_FAILED) {
$response = array("error" => true, "message" => "Oops! An error occurred while registering");
echoResponse(200, $response);
} else {
if ($res == USER_ALREADY_EXISTED) {
$response["error"] = true;
$response["message"] = "Sorry, this email already existed";
echoResponse(200, $response);
}
}
}
示例5: function
//
//echo "please!";
$app->post('/register', function () use($app) {
// echo "testing";
// check for required params
// verifyRequiredParams(array('username', 'gender', 'email', 'password'));
$response = array();
// reading post params
$username = $app->request->post('username');
$gender = $app->request->post('gender');
$email = $app->request->post('email');
$password = $app->request->post('password');
// validating email address
// validateEmail($email);
$db = new DbHandler();
$res = $db->createUser($username, $gender, $email, $password);
if ($res == USER_CREATED_SUCCESSFULLY) {
$user = $db->getUserByEmail($email);
if ($user != NULL) {
$response["error"] = false;
$response['username'] = $user['username'];
$response['id'] = $user['id'];
$response['apiKey'] = $user['api_key'];
$response['message'] = "User successfully registered.";
} else {
// unknown error occurred
$response['error'] = true;
$response['message'] = "An error occurred. Please try again";
}
echoResponse(201, $response);
} else {
示例6: DbHandler
<?php
include './include/DbHandler.php';
$db = new DbHandler();
header('Content-Type: application/json');
$response = array();
if (isset($_POST['mobile']) && $_POST['mobile'] != '') {
$name = $_POST['name'];
$vehicle_reg_no = $_POST['vehicle_reg_no'];
$mobile = $_POST['mobile'];
$otp = rand(100000, 999999);
$res = $db->createUser($name, $vehicle_reg_no, $mobile, $otp);
if ($res == USER_CREATED_SUCCESSFULLY) {
// send sms
sendSms($mobile, $otp);
$response["error"] = false;
$response["message"] = "SMS request is initiated! You will be receiving it shortly.";
} else {
if ($res == USER_CREATE_FAILED) {
$response["error"] = true;
$response["message"] = "Sorry! Error occurred in registration.";
} else {
if ($res == USER_ALREADY_EXISTED) {
$response["error"] = true;
$response["message"] = "Mobile number already existed!";
}
}
}
} else {
$response["error"] = true;
$response["message"] = "Sorry! mobile number is not valid or missing.";
示例7: function
*/
$app->post('/register', function () use($app) {
// check for required params
$r = json_decode($app->request->getBody());
verifyRequiredParams(array('name', 'phone', 'password'), $r);
$response = array();
$password = $r->password;
$phone = $r->phone;
$name = $r->name;
$response = array('fields' => [$phone, $password, $name]);
// reading post params
// $name = $app->request->post('name');
// $phone = $app->request->post('phone');
// $password = $app->request->post('password');
$db = new DbHandler();
$res = $db->createUser($name, $phone, $password);
if ($res == USER_CREATED_SUCCESSFULLY) {
$user = $db->getUserByPhone($phone);
$response["error"] = false;
$response["message"] = "You are successfully registered";
if (!is_null($user)) {
$response["name"] = $user["name"];
$response["phone"] = $user["phone"];
$response["apiKey"] = $user["api_key"];
}
} else {
if ($res == USER_CREATE_FAILED) {
$response["error"] = true;
$response["message"] = "Oops! An error occurred while registering";
} else {
if ($res == USER_ALREADY_EXISTED) {
示例8: json_encode
<?php
include './include/DbHandler.php';
$db = new DbHandler();
$response = array();
if (isset($_POST['mobile']) && $_POST['mobile'] != '') {
$mobile = $_POST['mobile'];
$otp = rand(100000, 999999);
$res = $db->createUser($mobile, $otp);
if ($res == USER_CREATED_SUCCESSFULLY) {
// send sms
sendSms($mobile, $otp);
$response["error"] = false;
$response["message"] = "SMS request is initiated! You will be receiving it shortly.";
} else {
if ($res == USER_CREATE_FAILED) {
$response["error"] = true;
$response["message"] = "Sorry! Error occurred in registration.";
} else {
if ($res == USER_ALREADY_EXISTED) {
$response["error"] = true;
$response["message"] = "Mobile number already existed!";
}
}
}
} else {
$response["error"] = true;
$response["message"] = "Sorry! mobile number is not valid or missing.";
}
echo json_encode($response);
function sendSms($mobile, $otp)
示例9: echoRespnse
// api key is missing in header
$response["error"] = true;
$response["message"] = "Api key is misssing";
echoRespnse(400, $response);
$app->stop();
}
}
$app->post('/register', function () use($app) {
// check for required params
verifyRequiredParams(array('login', 'password'));
$response = array();
// reading post params
$login = $app->request->post('login');
$password = $app->request->post('password');
$db = new DbHandler();
$res = $db->createUser($login, $password);
if ($res == USER_CREATED_SUCCESSFULLY) {
$response["error"] = false;
$response["message"] = "You are successfully registered";
} else {
if ($res == USER_CREATE_FAILED) {
$response["error"] = true;
$response["message"] = "Oops! An error occurred while registereing";
} else {
if ($res == USER_ALREADY_EXISTED) {
$response["error"] = true;
$response["message"] = "Sorry, this email already existed";
}
}
}
// echo json response
示例10: function
* method - POST
* params - name, email, password
*/
$app->post('/register', function () use($app) {
// check for required params
verifyRequiredParams(array('name', 'email', 'password', 'gender'));
$response = array();
// reading post params
$name = $app->request->post('name');
$email = $app->request->post('email');
$password = $app->request->post('password');
$gender = $app->request->post('gender');
// validating email address
validateEmail($email);
$db = new DbHandler();
$res = $db->createUser($name, $email, $password, $gender);
if ($res == USER_CREATED_SUCCESSFULLY) {
$response["error"] = false;
$response["message"] = "You are successfully registered";
echoResponse(201, $response);
} else {
if ($res == USER_CREATE_FAILED) {
$response["error"] = true;
$response["message"] = "Oops! An error occurred while registereing";
echoResponse(200, $response);
} else {
if ($res == USER_ALREADY_EXISTED) {
$response["error"] = true;
$response["message"] = "Sorry, this email already existed";
echoResponse(200, $response);
}
示例11: function
* method - POST
* params - 'nome', 'endereco', 'telefone', 'email', 'empresa', 'tipo_entrega'
*/
$app->post('/create-user', function () use($app, $log) {
// check for required params
verifyRequiredParams(array('nome', 'endereco', 'telefone', 'tipo_entrega'));
$response = array();
// reading post params
$nome = $_REQUEST["nome"];
$endereco = $_REQUEST["endereco"];
$telefone = $_REQUEST["telefone"];
$email = $_REQUEST["email"];
$empresa = $_REQUEST["empresa"];
$tipo_entrega = $_REQUEST["tipo_entrega"];
$db = new DbHandler();
$res = $db->createUser($nome, $endereco, $telefone, $email, $empresa, $tipo_entrega);
if ($res > 0) {
$response["error"] = false;
$response["cd_usuario"] = $res;
echoResponse(201, $response);
} else {
$response["error"] = true;
echoResponse(200, $response);
}
});
/**
* Create user
* url - /update-user
* method - POST
* params - 'nome', 'endereco', 'telefone', 'email', 'empresa', 'tipo_entrega'
*/
示例12: DbHandler
$password2 = strip_tags($_POST['password2']);
} else {
$reg_errors['password2'] = 'Your password did not match the confirmed password!';
}
} else {
$reg_errors['password1'] = 'Password must be between 6 and 20 characters long, with
at least one lowercase letter, one uppercase letter,
and one number.!';
}
$user_name = $_POST['user_name'];
/* end validation */
if (empty($reg_errors)) {
//Validation OK:
require_once './classes/DbHandler.php';
$db = new DbHandler();
$data = $db->createUser($first_name, $last_name, $email, $user_name, $password2);
if ($data['message'] == 'USER_SUCCESSFULLY_CREATED') {
echo '<div class="content-main-wrap">
<div class="content-main opacity">
<section class="content-section contact-section">
<div class="wrap content-contact">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">';
//user registered success -test activation
$y = $data['active'];
//1. prepare and send email
include './includes/helpers.php';
$replyToEmail = 'daniel.bujold.0719@gmail.com';
$replyToName = 'BingeTunes';
$mailSubject = 'BingeTunes Registration';
示例13: function
* method - POST
* @params - first_name, last_name, email, password
*/
$app->post('/register.php', function () use($app) {
// check for required params
verifyRequiredParams(array('first_name', 'last_name', 'email', 'password'));
$response = array();
// reading post params
$first_name = $app->request->post('first_name');
$last_name = $app->request->post('last_name');
$email = $app->request->post('email');
$password = $app->request->post('password');
// validating email address
validateEmail($email);
$db = new DbHandler();
$res = $db->createUser($first_name, $last_name, $email, $password);
if ($res == USER_CREATED_SUCCESSFULLY) {
$response["error"] = false;
$response['error_id'] = 200;
$response['error_title'] = 'User Registered';
$response['error_message'] = 'You are successfully registered';
// echo json response
echoRespnse(200, $response);
} else {
if ($res == USER_CREATE_FAILED) {
$response["error"] = true;
$response['error_id'] = 400;
$response['error_title'] = 'Registration Error';
$response['error_message'] = 'Oops! An error occurred while registereing';
// echo json response
echoRespnse(400, $response);
示例14: function
*/
$app->post('/register', function () use($app) {
// check for required params
verifyRequiredParams(array('email', 'password', 'name', 'deviceToken', 'deviceType', 'profileImage'));
$response = array();
// reading post params
$email = $app->request->post('email');
$password = $app->request->post('password');
$name = $app->request->post('name');
$deviceToken = $app->request->post('deviceToken');
$deviceType = $app->request->post('deviceType');
$profileImage = $app->request->post('profileImage');
// validating email address
validateEmail($email);
$db = new DbHandler();
$res = $db->createUser($email, $password, $name, $deviceToken, $deviceType, $profileImage);
if ($res == USER_CREATED_SUCCESSFULLY) {
$response["error"] = false;
$response["message"] = "You are successfully registered";
echoRespnse(201, $response);
} else {
if ($res == USER_CREATE_FAILED) {
$response["error"] = true;
$response["message"] = "Oops! An error occurred while registering";
echoRespnse(200, $response);
} else {
if ($res == USER_ALREADY_EXISTED) {
$response["error"] = true;
$response["message"] = "Sorry, this email already existed";
echoRespnse(200, $response);
}
示例15: function
<?php
require_once '../include/dbhandler.php';
require_once '../include/passhash.php';
require_once '../libs/slim/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
//$student_number = NULL;
$app->post('/register', function () use($app) {
$response = array();
$student_id = $app->request->post('student_id');
$pass = $app->request->post('pass');
$db = new DbHandler();
$result = $db->createUser($student_id, $pass);
if ($result == USER_CREATED_SUCCESSFULLY) {
$response["error"] = false;
$response["message"] = "You are successfully registered";
} else {
if ($result == USER_CREATE_FAILED) {
$response["error"] = true;
$response["message"] = "Ooops ! Failed to register!";
} else {
if ($result == USER_ALREADY_EXISTED) {
$response["error"] = true;
$response["message"] = "User already existed";
}
}
}
echoRespnse(201, $response);
});
$app->post('/login', function () use($app) {