php


How to display currently ogged in user details in another page using angularjs and php?


I have created login form. posting data to database to check combination of email and password , if it is satisfied then logged in successfully.
now i am redirecting to profile page after logged in.
i want to display currently logged in user details stored in database in this profile page..
i use ui-router for navigation.
my login.html
<div class="col-lg-6 col-lg-offset-3 well " style="margin-top:1em; background-color:black; ">
<h4 style="color:white; text-align:center;"> <strong> LOGIN </strong> </h4>
</div>
<div class="col-lg-6 col-lg-offset-3 well" style="margin-bottom:13em;">
<form name="login" ng-app="TempleWebApp" ng-controller="logCtrl" ng-submit="signin(login.$valid)" novalidate>
<div class="form-group col-lg-12" ng-class="{ 'has-error' : login.email.$invalid && (login.email.$dirty || submitted)}">
<label>Email</label>
<input class="form-control" type="text" name="email" ng-model="useremail" placeholder="Email" ng-pattern="/^[^\s#]+#[^\s#]+\.[^\s#]{2,}$/" ng-required="true">
<span class="help-block" ng-show="login.email.$invalid && login.email.$error.required && (login.email.$dirty || submitted)">
Email is required.</span>
<span class="help-block" ng-show="login.email.$error.pattern">
Enter Valid Email .</span>
</div>
<div class="form-group col-lg-12" ng-class="{ 'has-error' : login.password.$invalid && (login.password.$dirty || submitted)}">
<label>Password</label>
<input class="form-control" type="password" name="password" ng-model="userpassword" placeholder="Password" ng-required="true">
<span class="help-block" ng-show="login.password.$invalid && login.password.$error.required && (login.password.$dirty || submitted)">
Password is required.</span>
</div>
<div class="col-lg-12 well " ng-repeat="error in errors" style="background-color:red; margin-top:0.5em;"> {{ error}} </div>
<div class="col-lg-12 well" ng-repeat="msg in msgs" style="margin-top:0.5em;">
<h5 style="color:green;">{{ msg}} </h5>
</div>
<button type="submit" class="btn btn-success col-lg-12">
<span ng-show="searchButtonText == 'REDIRECTING TO PROFILE PAGE'"><i class="glyphicon glyphicon-refresh spinning"></i></span>
{{ searchButtonText }}
</button>
</form>
</div>
my angular controller for login
app.controller('logCtrl', function($scope, $location, $http, $timeout) {
$scope.errors = [];
$scope.msgs = [];
$scope.searchButtonText = "LOGIN";
$scope.test = "false";
$scope.signin = function(isValid) {
// Set the 'submitted' flag to true
$scope.submitted = true;
$scope.errors.splice(0, $scope.errors.length); // remove all error messages
$scope.msgs.splice(0, $scope.msgs.length);
if (isValid) {
$http.post('php/login.php', {
'email': $scope.useremail,
'pswd': $scope.userpassword
})
.success(function(data, status, headers, config) {
if (data.msg != '') {
$scope.msgs.push(data.msg);
$scope.test = "true";
$scope.searchButtonText = "REDIRECTING TO PROFILE PAGE";
var goTopayment = function() {
$scope.searchButtonText = "LOGIN";
$location.path('/profile');
};
$timeout(goTopayment, 3000);
} 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);
});
} // closing bracket for IF(isvalid)
} // closing bracket for $scope.SIGNUP = function
});
login.php
<?php
$data = json_decode(file_get_contents("php://input"));
$uemail = mysql_real_escape_string($data->email);
$upswd = mysql_real_escape_string($data->pswd);
$con = mysql_connect('localhost', 'root', '');
mysql_select_db('registraion', $con);
$qry_em = 'select Email,Password,Status from users where Email ="' . $uemail . '" and Password ="' . $upswd . '" ';
$qry_res = mysql_query($qry_em);
$res = mysql_fetch_assoc($qry_res);
if ( $res ['Email']==$uemail && $res ['Password']==$upswd && $res['Status']=='active')
{
$arr = array('msg' => "Logged in Successfully!!!", 'error' => '');
$jsn = json_encode($arr);
print_r($jsn);
}
else
{
$arr = array('msg' => "", 'error' => 'Email And Password Miss Match Or Your Account Is Not Activated Yet. Please Activate Account.');
$jsn = json_encode($arr);
print_r($jsn);
}
?>
profile.html
<div ng-controller="logCtrl" class="col-lg-12 well">
<h4 style="text-align:center;">DETAILS</h4>
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>city</th>
<th>gender</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in data ">
<td>{{user.Firstname}}</td>
<td>{{user.City}}</td>
<td>{{user.Gender}}</td>
</tr>
</tbody>
</table>
</div>
How do i get that currently logged in user data in profile.html page.

Related Links

Where, best, should I place my add_action and function codes in the function.php file?
MySQL script retrieves Steam ID and nothing else
How to load wordpress child theme css after parent theme css
Why I'm getting this error “SQLSTATE[HY093]: Invalid parameter number: parameter was not defined”?
Does PHP mysqli query and fetch_(row/assoc) use real time data?
PHP function suggestion need
Design pattern for one controller and many services
Wrong php email form
Elequoent relationship is not selecting releated rows
Laravel routes not working on production
Update with wp_update_post in WordPress
PHP Check if string is in table
How to use Now() with PDO
where to store the php connection file?
How to mask id passed through URL in PHP?
FPDF dont want extra generated page

Categories

HOME
rust
class
xcode
functional-programming
activex
antd
risk-management
whmcs
elisp
elk-stack
dji-sdk
phpmqtt
native-base
reportviewer
yeoman-generator-angular
cqrs
jquery-file-upload
mpu6050
spring-jpa
mahout-recommender
google-tasks-api
string-formatting
cloudsim
clr
gitkraken
el
backtracking
amazon-sns
websphere-portal
software-packaging
tracing
introspection
npoi
ninject
basic-authentication
splunk-query
dotcms
tightvnc
argv
python-2.x
mongodb-3.4
nsmutablearray
plantuml
appcode
directfb
android-canvas
rails-postgresql
buildforge
orchardcms-1.8
des
textmate2
jslint
ng-repeat
microsoft-ui-automation
tidal-scheduler
selenide
google-now
praat
spring-restcontroller
oauth2
fiware-wirecloud
music21
viewmodel
cordova-ios
comm
htmlspecialchars
dtd
front-camera
instafeedjs
wildfly-9
bpms
xmlbeans
android-sdcard
piping
textblock
m4
godeps
highest
screen-orientation
android-studio-import
supercomputers
embeddedwebserver
clarion
deque
phonegap-facebook-plugin
sunos
famo.us
hp-idol-ondemand
multivariate-testing
quantify
ecos
otl
network-printers
git-reset
tabletools
armv6
pbkdf2
progress-db
acitree
quickgraph
ember-table
pacman
microformats
chartfx
delphi-xe4
examine
gitx
server-name
jdom
pcspim
background-repeat
mvcrecaptcha
server-variables
play2-mini
office-automation
gaelyk
spring-modules

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App