File: /home/barbeatleanalyti/public_html/api.beatleanalytics.com/live/signup.php
<?php
/*
* Following code will get single department details
* A industry is identified by dept_id
*/
// array for JSON response
$response = array();
// include db connect class
require_once 'db_connect.php';
// connecting to db
$db = new DB_CONNECT();
if (isset($_GET["name"],$_GET["phoneno"],$_GET["pass"],$_GET["branchId"],$_GET["indId"],$_GET["orgID"])) {
$name = $_GET["name"];
$phoneno = $_GET['phoneno'];
$pass = $_GET['pass'];
$branchId = $_GET['branchId'];
$indId = $_GET['indId'];
$password = md5($pass);
$status = '1';
$date = date('Y-m-d H:i:s');
$uniq = rand(1,1000);
$unqId = 'END_'.$uniq;
$usertype = 'End_user';
$orgID = $_GET['orgID'];
$checkuser = mysql_query("SELECT * FROM beatle_userlogin WHERE db_phone LIKE '$phoneno'")or die(mysql_error());
//echo $checkuser;
if(!empty($checkuser)){
if (mysql_num_rows($checkuser) > 0) {
// mysql inserting a new row
// user allready exists
$response["success"] = 2;
$response["message"] = "user allready exists";
// echoing JSON response
echo json_encode($response);
}else {
$result = mysql_query("INSERT INTO beatle_userlogin(db_userRandId,db_pagepermistion,db_username,db_userLoginName,db_email,db_phone, db_password, db_valid, db_valid_from, created_date, updated_date, webprofileimage, db_usertype, BranchID, IndustryID, OrgID, db_city, db_state, db_pincode) VALUES('$unqId','','$name','','', '$phoneno', '$password', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '$date', '0000-00-00 00:00:00', '', '$usertype', '$branchId', '$indId', '$orgID', '0', '0', '0')")or die(mysql_error());
// check if row inserted or not
if ($result) {
// successfully inserted into database
$response["success"] = 1;
$response["message"] = "user successfully created.";
// echoing JSON response
echo json_encode($response);
} else {
// failed to insert row
$response["success"] = 0;
$response["message"] = "Oops! An error occurred.";
// echoing JSON response
echo json_encode($response);
}
}
}
}
else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>