Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. .controller('registerController',['$scope', '$stateParams', '$state', '$http', function($scope, $stateParams, $state, $http){
  2. var userInformation = [];
  3. $scope.registration = {};
  4. console.log($stateParams.all);
  5.  
  6. $scope.doRegister = function () {
  7. if( $scope.registration.pasword !== $scope.registration.confirmpassword){
  8. alert("Password not match");
  9. }
  10. $http({
  11. url: "http://localhost/php/chat.php",
  12. method: "POST",
  13. data: {
  14. 'username': $scope.registration.username,
  15. 'email': $scope.registration.emailaddress,
  16. 'password': $scope.registration.pasword
  17. }
  18. }).success(function(response) {
  19. console.log(response);
  20. }).error(function(response) {
  21. console.log(response);
  22. });
  23. $state.go('login', {userInformation : userInformation});
  24. };
  25. $scope.goBack = function() {
  26. $state.go('login');
  27. }
  28. }])
  29.  
  30. <?php
  31. header("Access-Control-Allow-Origin: *");
  32. header("Access-Control-Allow-Credentials: true");
  33. header("Access-Control-Allow-Methods: POST, GET, OPTIONS");
  34. header("Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With");
  35.  
  36. $postdata = file_get_contents("php://input");
  37. $request = json_decode($postdata);
  38. $user = $request->username;
  39. $email = $request->email;
  40. $pass = $request->password;
  41.  
  42. $servername = "localhost";
  43. $username = "jack";
  44. $password = "1234";
  45. $dbname = "chat";
  46. $conn = new mysqli($servername, $username, $password, $dbname);
  47.  
  48. if ($conn->connect_error) {
  49. die("Connection failed: " . $conn->connect_error);
  50. }
  51.  
  52. $sql = "INSERT INTO use_directory VALUES ('', '$user', '$email', '$pass');" ;
  53. $retval = $conn->multi_query($sql);
  54.  
  55. if( $retval === TRUE) {
  56. echo "Add successfullyn";
  57. }else {
  58. die('Could not edit data');
  59. }
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement