Created
April 10, 2015 09:14
-
-
Save LocalCommit/28354edd3b81d47f6659 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html ng-app> | |
<head> | |
<title>AngularJs Post Example: DevZone.co.in </title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script> | |
<style> | |
#dv1{ | |
border:1px solid #DBDCE9; margin-left:auto; | |
margin-right:auto;width:220px; | |
border-radius:7px;padding: 25px; | |
} | |
.info{ | |
border: 1px solid;margin: 10px 0px; | |
padding:10px;color: #00529B; | |
background-color: #BDE5F8;list-style: none; | |
} | |
.err{ | |
border: 1px solid; margin: 10px 0px; | |
padding:10px; color: #D8000C; | |
background-color: #FFBABA; list-style: none; | |
} | |
</style> | |
</head> | |
<body> | |
<div id='dv1'> | |
<form ng-controller="FrmController"> | |
<ul> | |
<li class="err" ng-repeat="error in errors"> {{ error}} </li> | |
</ul> | |
<ul> | |
<li class="info" ng-repeat="msg in msgs"> {{ msg}} </li> | |
</ul> | |
<h2>Sigup Form</h2> | |
<div> | |
<label>Name</label> | |
<input type="text" ng-model="username" placeholder="User Name" style='margin-left: 22px;'> | |
</div> | |
<div> | |
<label>Email</label> | |
<input type="text" ng-model="useremail" placeholder="Email" style='margin-left: 22px;'> | |
</div> | |
<div> | |
<label>Password</label> | |
<input type="password" ng-model="userpassword" placeholder="Password"> | |
</div> | |
<button ng-click='SignUp();' style='margin-left: 63px;margin-top:10px'>SignUp</button> | |
</form> | |
</div> | |
<script type="text/javascript"> | |
function FrmController($scope, $http) { | |
$scope.errors = []; | |
$scope.msgs = []; | |
$scope.SignUp = function() { | |
$scope.errors.splice(0, $scope.errors.length); // remove all error messages | |
$scope.msgs.splice(0, $scope.msgs.length); | |
$http.post('post_es.php', {'uname': $scope.username, 'pswd': $scope.userpassword, 'email': $scope.useremail} | |
).success(function(data, status, headers, config) { | |
if (data.msg != '') | |
{ | |
$scope.msgs.push(data.msg); | |
} | |
else | |
{ | |
$scope.errors.push(data.error); | |
} | |
}).error(function(data, status) { // called asynchronously if an error occurs | |
// or server returns response with an error status. | |
$scope.errors.push(status); | |
}); | |
} | |
} | |
</script> | |
<a href='http://devzone.co.in'>Devzone.co.in</a> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app> | |
<head> | |
<title>AngularJs Post Example: DevZone.co.in </title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script> | |
<style> | |
#dv1{ | |
border:1px solid #DBDCE9; margin-left:auto; | |
margin-right:auto;width:220px; | |
border-radius:7px;padding: 25px; | |
} | |
.info{ | |
border: 1px solid;margin: 10px 0px; | |
padding:10px;color: #00529B; | |
background-color: #BDE5F8;list-style: none; | |
} | |
.err{ | |
border: 1px solid; margin: 10px 0px; | |
padding:10px; color: #D8000C; | |
background-color: #FFBABA; list-style: none; | |
} | |
</style> | |
</head> | |
<body style="background: #F2F2F2;"> | |
<div id='dv1'> | |
<form ng-controller="FrmController"> | |
<ul> | |
<li class="err" ng-repeat="error in errors"> {{ error}} </li> | |
</ul> | |
<ul> | |
<li class="info" ng-repeat="msg in msgs"> {{ msg}} </li> | |
</ul> | |
<h2>Sigup Form</h2> | |
<div> | |
<label>Name</label> | |
<input type="text" ng-model="username" placeholder="User Name" style='margin-left: 22px;'> | |
</div> | |
<div> | |
<label>Email</label> | |
<input type="text" ng-model="useremail" placeholder="Email" style='margin-left: 22px;'> | |
</div> | |
<div> | |
<label>Password</label> | |
<input type="password" ng-model="userpassword" placeholder="Password"> | |
</div> | |
<button ng-click='SignUp();' style='margin-left: 63px;margin-top:10px'>SignUp</button> | |
</form> | |
</div> | |
<script type="text/javascript"> | |
function FrmController($scope, $http) { | |
$scope.errors = []; | |
$scope.msgs = []; | |
$scope.SignUp = function() { | |
$scope.errors.splice(0, $scope.errors.length); // remove all error messages | |
$scope.msgs.splice(0, $scope.msgs.length); | |
$http.post('post_es.php', {'uname': $scope.username, 'pswd': $scope.userpassword, 'email': $scope.useremail} | |
).success(function(data, status, headers, config) { | |
if (data.msg != '') | |
{ | |
$scope.msgs.push(data.msg); | |
} | |
else | |
{ | |
$scope.errors.push(data.error); | |
} | |
}).error(function(data, status) { // called asynchronously if an error occurs | |
// or server returns response with an error status. | |
$scope.errors.push(status); | |
}); | |
} | |
} | |
</script> | |
<a href='http://devzone.co.in'>Devzone.co.in</a> | |
</body> | |
<script> | |
(function(i, s, o, g, r, a, m) { | |
i['GoogleAnalyticsObject'] = r; | |
i[r] = i[r] || function() { | |
(i[r].q = i[r].q || []).push(arguments) | |
}, i[r].l = 1 * new Date(); | |
a = s.createElement(o), | |
m = s.getElementsByTagName(o)[0]; | |
a.async = 1; | |
a.src = g; | |
m.parentNode.insertBefore(a, m) | |
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga'); | |
ga('create', 'UA-43091346-1', 'devzone.co.in'); | |
ga('send', 'pageview'); | |
</script> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = json_decode(file_get_contents("php://input")); | |
$usrname = mysql_real_escape_string($data->uname); | |
$upswd = mysql_real_escape_string($data->pswd); | |
$uemail = mysql_real_escape_string($data->email); | |
$con = mysql_connect('localhost', 'root', ''); | |
mysql_select_db('test', $con); | |
$qry_em = 'select count(*) as cnt from users where email ="' . $uemail . '"'; | |
$qry_res = mysql_query($qry_em); | |
$res = mysql_fetch_assoc($qry_res); | |
if($res['cnt']==0){ | |
$qry = 'INSERT INTO users (name,pass,email) values ("' . $usrname . '","' . $upswd . '","' . $uemail . '")'; | |
$qry_res = mysql_query($qry); | |
if ($qry_res) { | |
$arr = array('msg' => "User Created Successfully!!!", 'error' => ''); | |
$jsn = json_encode($arr); | |
print_r($jsn); | |
} else { | |
$arr = array('msg' => "", 'error' => 'Error In inserting record'); | |
$jsn = json_encode($arr); | |
print_r($jsn); | |
} | |
} | |
else | |
{ | |
$arr = array('msg' => "", 'error' => 'User Already exists with same email'); | |
$jsn = json_encode($arr); | |
print_r($jsn); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `users` ( | |
`uid` int(11) NOT NULL AUTO_INCREMENT, | |
`name` varchar(225) DEFAULT NULL, | |
`email` varchar(225) DEFAULT NULL, | |
`pass` varchar(225) DEFAULT NULL, | |
PRIMARY KEY (`uid`) | |
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment