Guest User

Untitled

a guest
Aug 29th, 2016
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.95 KB | None | 0 0
  1. <?php
  2.  
  3. include('connection.php');
  4. $register="register";
  5. $login="login";
  6.  
  7. //readAllTimes
  8. $inTime_All="inTime_All";
  9. $outTime_All="outTime_All";
  10.  
  11. //insert
  12. $presetDateInsert="presetDateInsert";
  13. $inTimeInsert="inTimeInsert";
  14. $outTimeInsert="outTimeInsert";
  15.  
  16. //update
  17. $presentDateUpdate="presentDateUpdate";
  18. $inTimeUpdate="inTimeUpdate";
  19. $outTimeUpdate="outTimeUpdate";
  20.  
  21. //status
  22. $presetDateStatus="presetDateStatus";
  23. $inTimeStatus="inTimeStatus";
  24. $outTimeStatus="outTimeStatus";
  25.  
  26. $all_details="all_details";
  27.  
  28. $updateOuTimeAndInsertInTime="updateOuTimeAndInsertInTime";
  29. $presetDate_InTime="presetDate_InTime";
  30.  
  31. $task=$_REQUEST['task'];
  32.  
  33.  
  34. if($task==$register){
  35. register();
  36. } else if($task==$login) {
  37. login();
  38. }else if($task==$inTimeStatus){
  39.  
  40. getStatus();
  41.  
  42. }else if($task==$outTimeStatus){
  43.  
  44. getStatusForOutTime();
  45.  
  46. }else if($task==$presetDateStatus){
  47.  
  48. getStatusForPresentDate();
  49.  
  50. }else if($task==$presetDate_InTime){
  51.  
  52. setPresetDate_InTime();
  53. }else if($task==$updateOuTimeAndInsertInTime){
  54.  
  55. setUpdateOuTimeAndInsertInTime();
  56. }
  57.  
  58. else if($task==$inTimeInsert){
  59.  
  60. inTimeInsert();
  61.  
  62. }else if($task==$outTimeInsert){
  63.  
  64. outTimeInsert();
  65.  
  66. }else if($task==$presetDateInsert){
  67.  
  68. presetDateInsert();
  69.  
  70. }else if($task==$inTimeUpdate){
  71.  
  72. inTimeUpdate();
  73.  
  74. }else if($task==$outTimeUpdate){
  75.  
  76. outTimeUpdate();
  77.  
  78. }else if($task==$presentDateUpdate){
  79.  
  80. presentDateUpdate();
  81.  
  82. }else if($task==$inTime_All){
  83.  
  84. getAll("intime_mgt",$_REQUEST['employeeId']);
  85.  
  86. }else if($task==$outTime_All){
  87. $currentDate=date("Y-m-d");
  88. getAll("outtime_mgt",$_REQUEST['employeeId']);
  89.  
  90. }else if($task==$all_details){
  91.  
  92. getAll_Details("intime_mgt",$_REQUEST['employeeId']);
  93.  
  94.  
  95. }else if($task=="all_details_present_date"){
  96.  
  97.  
  98.  
  99. getAll_Details("presetdatetable",$_REQUEST['employeeId']);
  100.  
  101. }else if($task=="all_details_out_time"){
  102.  
  103. getAll_Details("outtime_mgt",$_REQUEST['employeeId']);
  104.  
  105. }else if($task="admin_view"){
  106. adminViewAllEmployee();
  107. }
  108. function adminViewAllEmployee(){
  109.  
  110. $response = array();
  111. $result = mysql_query("SELECT * FROM userregistration");
  112. $response["employeeDetails"] = array();
  113. if(mysql_num_rows($result) >=1)
  114. {
  115. while($row = mysql_fetch_array($result))
  116. {
  117. $user = array();
  118. $response["success_code"] = 0;
  119. $response["status"]="Success";
  120. $response["message"]="All Datas Success";
  121.  
  122. $user["empName"] = $row['name'];
  123. $user["employeeId"] = $row['employeeId'];
  124. $user["empMobileNumber"] = $row['mobileNumber'];
  125.  
  126. array_push($response["employeeDetails"], $user);
  127. }
  128. }
  129. echo json_encode($response);;
  130. }
  131.  
  132. function getAll_Details($db_name,$employeeId){
  133.  
  134. /*
  135. $con= mysql_connect('localhost','root','');
  136. if(!$con)
  137. {
  138. die('could not connect;'.mysql_error());
  139. }
  140. mysql_select_db('timemanagement');
  141. */
  142. $response = array();
  143.  
  144. $result = mysql_query("SELECT * FROM $db_name WHERE employeeId='$employeeId'");
  145.  
  146. $response["all"] = array();
  147. if(mysql_num_rows($result) >=1)
  148. {
  149. $currentDate=date("Y-m-d") ;
  150.  
  151.  
  152. while($row = mysql_fetch_array($result))
  153. {
  154. $db_date;
  155. $user = array();
  156.  
  157.  
  158. if($db_name=="intime_mgt")
  159. {
  160. $response["success_code"] = 0;
  161. $response["status"]="Success";
  162. $response["message"]="All Datas Success";
  163.  
  164. $in_date= substr($row["inTime"],0,10) ;
  165.  
  166. $user["inTime"] = $in_date;
  167.  
  168. $user["timeSpent"]=$row["timeSpent"];
  169. array_push($response["all"], $user);
  170. }
  171. else if ($db_name=="outtime_mgt")
  172. {
  173. $response["success_code"] = 0;
  174. $response["status"]="Success";
  175. $response["message"]="All Datas Success";
  176.  
  177. $out_date= substr($row["outTime"],0,10) ;
  178.  
  179. $user["outTime"] = $out_date;
  180.  
  181. $user["timeSpent"]=$row["timeSpent"];
  182. array_push($response["all"], $user);
  183. }else {
  184. $response["success_code"] = 0;
  185. $response["status"]="Success";
  186. $response["message"]="All Datas Success";
  187.  
  188. $user["presentdate"] = $row["presetDate"];
  189.  
  190.  
  191. array_push($response["all"], $user);
  192. }
  193.  
  194.  
  195. }
  196. }
  197. else {
  198. $user_not_found = array();
  199. $response["success_code"] = 1;
  200. $response["status"]="not_found";
  201. $response["message"]="User not found";
  202.  
  203. }
  204. echo json_encode($response);
  205.  
  206. }
  207.  
  208. function setPresetDate_InTime(){
  209.  
  210. /* $con= mysql_connect('localhost','root','');
  211. if(!$con)
  212. {
  213. die('could not connect;'.mysql_error());
  214. }
  215. mysql_select_db('timemanagement');*/
  216.  
  217.  
  218.  
  219. presetDateInsert();
  220. inTimeInsert();
  221.  
  222.  
  223.  
  224. }
  225. function setUpdateOuTimeAndInsertInTime(){
  226.  
  227.  
  228. /* $con= mysql_connect('localhost','root','');
  229. if(!$con)
  230. {
  231. die('could not connect;'.mysql_error());
  232. }
  233. mysql_select_db('timemanagement');*/
  234.  
  235. $employeeId=$_POST['employeeId'];
  236. $id=$_POST['id'];
  237. $diffTime=$_POST['diffTime'];
  238. $updateStatus=$_POST['updateStatus'];
  239.  
  240. $inTime=$_POST['inTime'];
  241. $statusId=$_POST['statusId'];
  242. $diffMilli=$_POST['diffMilli'];
  243.  
  244.  
  245.  
  246. outTimeUpdate();
  247. inTimeInsert();
  248.  
  249.  
  250. }
  251.  
  252. function getStatusForPresentDate(){
  253.  
  254.  
  255.  
  256. $con= mysql_connect('localhost','root','');
  257. /*if(!$con)
  258. {
  259. die('could not connect;'.mysql_error());
  260. }
  261. mysql_select_db('timemanagement');*/
  262. $response = array();
  263.  
  264.  
  265. if((isset($_POST["employeeId"])) && ($_POST["employeeId"]!="") )
  266. {
  267. $employeeId=$_POST['employeeId'];
  268.  
  269. /*$sql="SELECT * FROM presetDateTable where employeeId=$employeeId";*/
  270. $sql="SELECT * FROM `presetDateTable` WHERE employeeId='$employeeId' order by id desc limit 1";
  271. /*$sql="SELECT * FROM intime_mgt where id=(select MAX(id)from intime_mgt)";*/
  272. $result = mysql_query($sql);
  273.  
  274. $response["intime_status"] = array();
  275. $user = array();
  276. if(mysql_num_rows($result) >=1){
  277. $statusId;
  278. $inTime;
  279. $id;
  280. $employeeId;
  281. while($row = mysql_fetch_array($result))
  282. {
  283.  
  284. $response["success_code"] = 0;
  285. $response["status"]="Success";
  286. $response["message"]="Fetched Datas Success";
  287.  
  288. $id=$row['id'];
  289. $date =$row['presetDate'];
  290. $employeeId=$row['employeeId'];
  291.  
  292. }
  293.  
  294. $user['id']=$id;
  295. $user['presentdate']=$date;
  296. $user['employeeId']=$employeeId;
  297. array_push($response["intime_status"], $user);
  298.  
  299. }else{
  300. $user = array();
  301. $response["success_code"] = 1;
  302. $response["status"]="Failure";
  303. $response["message"]="Not Found";
  304.  
  305.  
  306. }
  307.  
  308. }else{
  309. $user = array();
  310.  
  311. $response["success_code"] = 1;
  312. $response["status"]="Wrong";
  313. $response["message"]="Something Went Wrong";
  314.  
  315. }
  316. echo json_encode($response);
  317. }
  318.  
  319.  
  320.  
  321. function presetDateInsert(){
  322. /* $con= mysql_connect('localhost','root','');
  323. if(!$con)
  324. {
  325. die('could not connect;'.mysql_error());
  326. }
  327. mysql_select_db('timemanagement');*/
  328. $response = array();
  329. $sql = "INSERT INTO `presetDateTable` (employeeId,presetDate) VALUES ('".$_POST['employeeId']."', '".$_POST['presetDate']."')";
  330. $retval = mysql_query( $sql );
  331. if(! $retval ) {
  332. die('Could not enter data: ' . mysql_error());
  333. $json = array("status" => "failure","message" => "Invalid User","code" => "1");
  334. }
  335.  
  336.  
  337. $response["success_code"] = 0;
  338. $response["message"] = "insert preset date";
  339.  
  340.  
  341.  
  342. echo json_encode($response);
  343. }
  344.  
  345. function presentDateUpdate(){
  346.  
  347. /* $con= mysql_connect('localhost','root','');
  348. if(!$con)
  349. {
  350. die('could not connect;'.mysql_error());
  351. }
  352. mysql_select_db('timemanagement');*/
  353. $response = array();
  354. $id=$_POST['id'];
  355. $date=$_POST['date'];
  356.  
  357. $result = mysql_query("UPDATE presetDateTable SET presetDate ='$date' WHERE id = $id");
  358. $response["present_date_update_status"] = array();
  359. if ($result) {
  360.  
  361.  
  362. $response["success_code"] = 0;
  363. $response["message"] = "successfully updated present date";
  364.  
  365.  
  366. } else {
  367. $response["success_code"] = 1;
  368. $response["message"] = "not updated";
  369.  
  370.  
  371. }
  372. echo json_encode($response);
  373.  
  374. }
  375.  
  376.  
  377.  
  378. function outTimeInsert(){
  379. /* $con= mysql_connect('localhost','root','');
  380. if(!$con)
  381. {
  382. die('could not connect;'.mysql_error());
  383. }
  384. mysql_select_db('timemanagement');*/
  385. $response["out_Time_Insert_status"] = array();
  386. $sql = "INSERT INTO `outtime_mgt` (employeeId,outTime,statusId) VALUES ('".$_POST['employeeId']."', '".$_POST['outTime']."', '".$_POST['statusId']."' )";
  387. $retval = mysql_query( $sql );
  388. if(! $retval ) {
  389.  
  390. die('Could not enter data: ' . mysql_error());
  391. $json = array("status" => "failure","message" => "Invalid User","code" => "1");
  392. }
  393. $response["success_code"] = 0;
  394. $response["message"] = "OutTime Insert";
  395.  
  396. echo json_encode($response);
  397. }
  398.  
  399.  
  400. function outTimeUpdate(){
  401. /* $con= mysql_connect('localhost','root','');
  402. if(!$con)
  403. {
  404. die('could not connect;'.mysql_error());
  405. }
  406. mysql_select_db('timemanagement');*/
  407. $response = array();
  408. $id=$_POST['id'];
  409. $employeeId=$_POST['employeeId'];
  410. $updateStatus=$_POST['updateStatus'];
  411. $duration=$_POST['duration'];
  412. $timeSpent=$_POST['timeSpent'];
  413. $inTime=$_POST['inTime'];
  414. $statusId=$_POST['updateStatus'];
  415. /*echo $id." ".$employeeId." ".$updateStatus." ".$duration." ".$timeSpent." ".$inTime." ".$statusId;
  416. 47 003 1 0:0:13 13 2016-08-27 13:25:34 0*/
  417. $result = mysql_query("UPDATE outtime_mgt SET intime ='$inTime',duration='$duration',statusId=$statusId,timeSpent='$timeSpent' WHERE id = $id");
  418. $response["outTime_update_status"] = array();
  419. if ($result) {
  420.  
  421.  
  422. $response["success_code"] = 0;
  423. $response["message"] = "successfully updated OutTime";
  424.  
  425.  
  426. } else {
  427. $response["success_code"] = 1;
  428. $response["message"] = "not updated";
  429.  
  430.  
  431. }
  432. echo json_encode($response);
  433.  
  434.  
  435.  
  436.  
  437. }
  438.  
  439. function inTimeUpdate(){
  440.  
  441. /* $con= mysql_connect('localhost','root','');
  442. if(!$con)
  443. {
  444. die('could not connect;'.mysql_error());
  445. }
  446. mysql_select_db('timemanagement');*/
  447. $response = array();
  448. $statusId=$_POST['statusId'];
  449. $outTime=$_POST['outTime'];
  450. $duration=$_POST['duration'];
  451. $id=$_POST['id'];
  452. $timeSpent=$_POST['timeSpent'];
  453.  
  454. $result = mysql_query("UPDATE intime_mgt SET outTime ='$outTime',duration ='$duration',statusId ='$statusId',timeSpent='$timeSpent' WHERE id = $id");
  455. $response["intime_update_status"] = array();
  456. if ($result) {
  457. // successfully updated
  458. $response["success"] = 0;
  459. $response["message"] = "Successfully updated..";
  460. // echoing JSON response
  461. echo json_encode($response);
  462. } else {
  463. $response["success"] = 1;
  464. $response["message"] = "not updated..";
  465. echo json_encode($response);
  466. }
  467.  
  468. }
  469.  
  470.  
  471.  
  472. function inTimeInsert(){
  473.  
  474. /* $con= mysql_connect('localhost','root','');
  475. if(!$con)
  476. {
  477. die('could not connect;'.mysql_error());
  478. }
  479. mysql_select_db('timemanagement');*/
  480.  
  481. $sql = "INSERT INTO `intime_mgt` (employeeId,inTime,outTime, statusId) VALUES ('".$_POST['employeeId']."', '".$_POST['inTime']."','".$_POST['outTime']."', '".$_POST['statusId']."' )";
  482. $retval = mysql_query( $sql );
  483. if(! $retval ) {
  484. die('Could not enter data: ' . mysql_error());
  485. $json = array("status" => "failure","message" => "Invalid User","code" => "1");
  486. }
  487.  
  488. $json = array("status" => "success","message" => "Insert Intime Success","code" => "0");
  489. echo json_encode($json);
  490. }
  491.  
  492.  
  493.  
  494.  
  495. function getAll($db_name,$employeeId){
  496.  
  497. /* $con= mysql_connect('localhost','root','');
  498. if(!$con)
  499. {
  500. die('could not connect;'.mysql_error());
  501. }
  502. mysql_select_db('timemanagement');*/
  503. $response = array();
  504.  
  505. $result = mysql_query("SELECT * FROM $db_name WHERE employeeId='$employeeId'");
  506.  
  507. $response["all"] = array();
  508. if(mysql_num_rows($result) >=1)
  509. {
  510. $currentDate=date("Y-m-d") ;
  511. while($row = mysql_fetch_array($result))
  512. {
  513. $db_date;
  514. $user = array();
  515. if($db_name=="intime_mgt")
  516. {
  517. $db_date=$row["inTime"];
  518. }
  519. else if ($db_name=="outtime_mgt")
  520. {
  521. $db_date=$row["outTime"];
  522. }
  523. $in_date= substr($db_date,0,10) ;
  524. $date_Tim=$_POST['dateString'];
  525. if($date_Tim==$in_date){
  526. $response["success_code"] = 0;
  527. $response["status"]="Success";
  528. $response["message"]="All Datas Success";
  529.  
  530. $user["inTime"] = $row["inTime"];
  531. $user["outTime"] = $row["outTime"];
  532. $user["duration"] = $row["duration"];
  533. $user["timeSpent"]=$row["timeSpent"];
  534. array_push($response["all"], $user);
  535.  
  536. }
  537. }
  538. }
  539. else {
  540. $user_not_found = array();
  541. $response["success_code"] = 1;
  542. $response["status"]="not_found";
  543. $response["message"]="User not found";
  544.  
  545. }
  546. echo json_encode($response);
  547.  
  548. }
  549.  
  550.  
  551. function getStatusForOutTime(){
  552.  
  553.  
  554. /* $con= mysql_connect('localhost','root','');
  555. if(!$con)
  556. {
  557. die('could not connect;'.mysql_error());
  558. }
  559. mysql_select_db('timemanagement');*/
  560. $response = array();
  561.  
  562.  
  563. if((isset($_POST["employeeId"])) && ($_POST["employeeId"]!="") )
  564. {
  565. $employeeId=$_POST['employeeId'];
  566.  
  567. /*$sql="SELECT * FROM outtime_mgt where employeeId=$employeeId";*/
  568. $sql="SELECT * FROM `outtime_mgt` WHERE employeeId='$employeeId' order by id desc limit 1";
  569. /*$sql="SELECT * FROM intime_mgt where id=(select MAX(id)from intime_mgt)";*/
  570. $result = mysql_query($sql);
  571.  
  572. $response["outTime_status"] = array();
  573. $user = array();
  574. if(mysql_num_rows($result) >=1){
  575. $statusId;
  576. $inTime;
  577. $id;
  578. $employeeId;
  579. while($row = mysql_fetch_array($result))
  580. {
  581.  
  582. $response["success_code"] = 0;
  583. $response["status"]="Success";
  584. $response["message"]="Fetched Datas Success";
  585. $statusId=$row['statusId'];
  586. $inTime=$row['outTime'];
  587. $id=$row['id'];
  588. $employeeId =$row['employeeId'];
  589. $outTime =$row['inTime'];
  590. $timeSpentInTime =$row['timeSpent'];
  591.  
  592. $user['timeSpent']=$timeSpentInTime;
  593. $user['inTime']=$inTime;
  594. $user['id']=$id;
  595. $user['statusId']=$statusId;
  596. $user['outTime']=$outTime;
  597. $user['employeeId']=$employeeId;
  598.  
  599. array_push($response["outTime_status"], $user);
  600.  
  601. }
  602.  
  603. }else{
  604. $user = array();
  605. $response["success_code"] = 1;
  606. $response["status"]="Failure";
  607. $response["message"]="Not Found";
  608.  
  609.  
  610. }
  611.  
  612. }else{
  613. $user = array();
  614. $response["success_code"] = 1;
  615. $response["status"]="Wrong";
  616. $response["message"]="Something Went Wrong";
  617.  
  618. }
  619. echo json_encode($response);
  620. }
  621.  
  622.  
  623.  
  624. function getStatus(){
  625. /*
  626. $con= mysql_connect('localhost','root','');
  627. if(!$con)
  628. {
  629. die('could not connect;'.mysql_error());
  630. }
  631. mysql_select_db('timemanagement');*/
  632. $response = array();
  633. if((isset($_POST["employeeId"])) && ($_POST["employeeId"]!="") )
  634. {
  635. $employeeId=$_POST['employeeId'];
  636.  
  637. /*$sql="SELECT * FROM intime_mgt where employeeId=$employeeId";*/
  638. $sql="SELECT * FROM `intime_mgt` WHERE employeeId='$employeeId' order by id desc limit 1";
  639. /*$sql="SELECT * FROM intime_mgt where id=(select MAX(id)from intime_mgt)";*/
  640. $result = mysql_query($sql);
  641.  
  642. $response["intime_status"] = array();
  643. $user = array();
  644. if(mysql_num_rows($result) >=1){
  645. $statusId;
  646. $inTime;
  647. $id;
  648. $employeeId;
  649. while($row = mysql_fetch_array($result))
  650. {
  651.  
  652. $response["success_code"] = 0;
  653. $response["status"]="Success";
  654. $response["message"]="Fetched Datas Success";
  655. $statusId=$row['statusId'];
  656. $inTime=$row['inTime'];
  657. $id=$row['id'];
  658. $employeeId =$row['employeeId'];
  659. $outTime =$row['outTime'];
  660. $timeSpentInTime =$row['timeSpent'];
  661.  
  662. $user['timeSpent']=$timeSpentInTime;
  663. $user['inTime']=$inTime;
  664. $user['id']=$id;
  665. $user['statusId']=$statusId;
  666. $user['employeeId']=$employeeId;
  667. $user['outTime']=$outTime;
  668. array_push($response["intime_status"], $user);
  669.  
  670. }
  671.  
  672.  
  673. }else{
  674. $user = array();
  675. $response["success_code"] = 1;
  676. $response["status"]="Failure";
  677. $response["message"]="Not Found";
  678.  
  679.  
  680. }
  681.  
  682. }else{
  683. $user = array();
  684.  
  685. $response["success_code"] = 1;
  686. $response["status"]="Wrong";
  687. $response["message"]="Something Went Wrong";
  688.  
  689. }
  690. echo json_encode($response);
  691. }
  692.  
  693. function login()
  694. {
  695. /* $con= mysql_connect('localhost','root','');
  696. if(!$con)
  697. {
  698. die('could not connect;'.mysql_error());
  699. }
  700. mysql_select_db('timemanagement');*/
  701. $response = array();
  702.  
  703. if((isset($_POST["mobileNumber"])) && ($_POST["mobileNumber"]!="") && (isset($_POST["password"])) && ($_POST["password"]!=""))
  704. {
  705. $userid=$_POST['mobileNumber'];
  706. $password=$_POST['password'];
  707. $result = mysql_query("SELECT * FROM userregistration WHERE mobileNumber='$userid'");
  708. $response["login"] = array();
  709. if(mysql_num_rows($result) ==1)
  710. {
  711.  
  712. while($row = mysql_fetch_array($result))
  713. {
  714. $user = array();
  715.  
  716. $username=$row['mobileNumber'];
  717. $passwd=$row['password'];
  718.  
  719.  
  720.  
  721.  
  722. if(($password==$passwd) && ($userid==$username))
  723. {
  724.  
  725. $response["success_code"] = 0;
  726. $response["status"]="Success";
  727. $response["message"]="Login Success";
  728.  
  729. $user["name"] = $row["name"];
  730. $user["password"] = $row["password"];
  731. $user["mobileNumber"] = $row["mobileNumber"];
  732. $user["employeeId"] = $row["employeeId"];
  733. $user["deviceId"] = $row["deviceId"];
  734. $user["dob"] = $row["dob"];
  735. array_push($response["login"], $user);
  736.  
  737. }
  738. else
  739. {
  740. $user = array();
  741. $response["success_code"] = 1;
  742. $response["status"]="failure";
  743. $response["message"]="Invalid User";
  744.  
  745.  
  746.  
  747. }
  748. } }
  749. else {
  750.  
  751. $user_not_found = array();
  752. $response["success_code"] = 1;
  753. $response["status"]="not_found";
  754. $response["message"]="User not found";
  755.  
  756.  
  757.  
  758. }
  759.  
  760. }
  761. echo json_encode($response);
  762. }
  763.  
  764.  
  765. function register(){
  766. /*
  767. $con= mysql_connect('localhost','root','');
  768. if(!$con)
  769. {
  770. die('could not connect;'.mysql_error());
  771. }
  772. mysql_select_db('timemanagement');*/
  773.  
  774. if((isset($_POST["mobileNumber"])) && ($_POST["mobileNumber"]!="") && (isset($_POST["deviceId"])) && ($_POST["deviceId"]!=""))
  775. {
  776. $userid=$_POST['mobileNumber'];
  777. $deviceId=$_POST['deviceId'];
  778.  
  779. $result = mysql_query("SELECT * FROM userregistration WHERE deviceId='$deviceId'");
  780.  
  781. if(mysql_num_rows($result) ==0){
  782. $result1 = mysql_query("SELECT * FROM userregistration WHERE mobileNumber='$userid'");
  783. if(mysql_num_rows($result1) ==0){
  784. $sql = "INSERT INTO `userregistration` (name,mobileNumber, password, employeeId,deviceId,dob) VALUES ('".$_POST['name']."', '".$_POST['mobileNumber']."','".$_POST['password']."', '".$_POST['employeeId']."','".$_POST['deviceId']."', '".$_POST['dob']."' )";
  785.  
  786. mysql_select_db('timemanagement');
  787.  
  788. $retval = mysql_query( $sql
  789. );
  790.  
  791. if(! $retval ) {
  792. die('Could not enter data: ' . mysql_error());
  793.  
  794. $json = array("status" => "failure","message" => "Invalid User","code" => "1");
  795. }
  796.  
  797. $json = array("status" => "success","message" => "Reegistration Success","code" => "0");
  798. echo json_encode($json);
  799. }else{
  800. $json = array("status" => "failure","message" =>"Mobile Number Already Exist,Please Contact Admin!!!","code" => "1");
  801. echo json_encode($json);
  802. }
  803. }else{
  804.  
  805. $json = array("status" => "failure","message" =>"This Device Already Exist","code" => "1");
  806. echo json_encode($json);
  807. }
  808.  
  809. } else{
  810. $json = array("status" => "failure","message" =>"Enter Mobile Number","code" => "1");
  811. echo json_encode($json);
  812. }
  813. /*mysql_close($con);*/
  814. }
  815.  
  816.  
  817.  
  818. ?>
Add Comment
Please, Sign In to add comment