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

PHP not Accessing Database on Server
Defining a private variable in a class
fetch data from mysql to a list view in android only show the first item from the table how to fix?
Insert a DIV Container inside a Modified Wordpress Loop
Hows authentication Sessions are maintained in laravel
Codeigniter Routes having GET variables
searchin status field through gridview in yii
How to change name of file when users uploads files(images) with the same name on ftp server
command line cURL to PHP cURL
i got Undefined index: file error in pdf php
Unserializing array of objects
Attribute value is making xhtml page to give error
socket writing message using chunks defenition
Connect to Columnar Database Using PHP
Import MySQL database to excel with all tables in separate sheets
simple regex for italian words

Categories

HOME
qt
python-2.7
macos-sierra
tomcat
windows-8.1
redmine
haproxy
nsview
filesize
hdfs
visual-studio-2010
iptables
google-search-console
heuristics
locationmanager
business-intelligence
buffer
distributed-computing
google-tasks-api
vertica
android-contacts
hidden
cocos2d-android
robolectric
string-formatting
raml
spring-shell
coreldraw
fido-u2f
cell
morris.js
sap-lumira
sendmessage
sales
fusion
windowsiot
argv
john-the-ripper
seafile-server
advanced-filter
creation
express-session
runtimeexception
android-alarms
cloudera-quickstart-vm
assert
reset
windows-store
elasticsearch-aggregation
flume-twitter
adblock
qvtkwidget
windows-media-player
.net-micro-framework
md5-file
ilrepack
spring.net
android-webservice
gtk#
patternlab.io
ptvs
connect-direct
glassfish-4.1
emf-compare
rustdoc
fuzzer
ftp-client
sharepoint-apps
flipclock
m4
servicestack-bsd
outlook.com
pythonxy
gitlab-omnibus
darwin
tidyr
findersync
password-recovery
windows-rt
neo4jphp
incognito-mode
zend-search-lucene
armv6
mongo-jackson-mapper
smartfox
jquery-dialog
arrow
chronometer
taskkill
jdom
data-dump
fgetc
firephp
data-retrieval
rtti
comment-conventions
watchpoint
community-server
rootkit

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App