|
|
|
สอบถามวิธีเเสดงข้อมูล User ที่ login โดยข้อมูลมาจาก proxy |
|
|
|
|
|
|
|
ทำระบบภายในสำนักงานโดยที่ทำงาน ให้ code เเบบนี้มาเพื่อให้ user login คำถามคือ เมื่อ user login เข้ามา ผมจะสามารถเรียกข้อมูลของ user ที่ login มาเเสดงในหน้า homepage ได้ยังไงครับช่วยเเนะนำด้วยครับ ขอบคุณครับ
index.php (PHP)
<?php
session_start();
?>
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title>Log in</title>
<!--link rel="icon" href="images/RAS_logo.png"-->
<link rel="stylesheet" href="css/reset.min.css">
<link rel='stylesheet prefetch' href='css/font-awesome.min.css'>
<link rel="stylesheet" href="css/style.css">
<script src='js/jquery.min.js'></script>
<script>
function trimStr(str)
{
return str.replace(/^\s+|\s+$/g, '');
}
function randString(x)
{
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < x; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
</script>
</head>
<body>
<style>
p.a {
font-family: "Quick Argani";
}
</style>
<div class="container">
<div class="info" style="margin-top:15%;"> </div>
</div>
<div class="form">
<p class="a">EUA Sell System !</p><br>
<div id="tenor" align="center"><img src="img/aaa.png" height="155" width="162"></div><br>
<div id="text_area"></div>
<form id="login_form" method="GET" class="login-form" onSubmit="return false" action="index1.php">
<input type="text" id="input_username" name="input_username" value="" placeholder="username" style="text-align:center;" maxlength="10" required/>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("input_username").value;
}
</script>
<input type="password" id="input_password" name="input_password" placeholder="Password" style="text-align:center;" maxlength="30" required/>
<button type="submit" id="login_btn">Login</button>
<p class="message"><span>กรุณาล็อคอินด้วย <strong>Account LAN</strong></span></p>
</form>
<!-- First Name: <input type="text" id="myText" value=" "> -->
<!--<br><button onclick="myFunction()">Try it</button>-->
</div>
<!--script src="js/index.js"></script-->
<script>
$(document).ready(function(e) {
$('#input_username').focus();
localStorage.clear();
//--------------------- STARTUP ----------------------------//
$('#login_form').submit(function()
{
var serializeData = $(this).serialize();
//alert(serializeData);
$.ajax({url: 'php/proxy.php', crossDomain: true, type: 'post', data: serializeData,
success: function(employee) {
var emp_info = JSON.parse(employee);
if(emp_info.description == 'Success' && emp_info.code == '200')
{
var userlan = localStorage['userlan'];
if (!userlan) {
// open popup
localStorage['userlan'] = document.getElementById("input_username").value;
localStorage['userlan'] = document.setAttribute("userlan").value;
s
}
//var userlan1 = document.getElementById("input_username").value;
//alert(userlan1);
//$('#text_area').html(emp_info.data.token);
var hours = 0.5;
var now = new Date().getTime();
var setupTime = localStorage.getItem('setupTime');
if (setupTime == null) {
localStorage.setItem("eus_token", emp_info.data.token);
localStorage.setItem('setupTime', now);
}
else {
location.href = 'index.php';
}
$('#login_form').hide();
//$('#text_area').html('<h5 style="margin-top:40px;"><h3 style="margin-bottom:20px;font-size:14px;font-weight:bold;"><small>Login success..</small></h3></h5>');
$('#tenor').removeAttr('class');
$('#tenor').html('<img src="img/tenor.gif" style="margin-bottom:100px; height="255" width="262"">');
setTimeout(function()
{
location.href = 'home/homepage.php';
},5000);
}
else
{
alert('!! Login fail !!');
location.href = 'index.php';
}
}
});
});
});
//var stx4 = randString(2)+btoa($('#input_password').val())+randString(4); var format1 = "json";
</script>
</body>
</html>
Proxy.php(PHP)
<?php
header('Access-Control-Allow-Origin: *');
$keys1 = "90955ef0602a994af9cfac5238790e7e";
$param1 = mysql_real_escape_string(htmlspecialchars(addslashes(strip_tags(trim($_POST['input_username'])))));
$param2 = mysql_real_escape_string(htmlspecialchars(addslashes(strip_tags(trim($_POST['input_password'])))));
$param3 = mysql_real_escape_string(htmlspecialchars(addslashes(strip_tags(trim($_POST['input_capcha'])))));
$param4 = mysql_real_escape_string(htmlspecialchars(addslashes(strip_tags(trim($_POST['hiddenVal'])))));
//var sobrano="http://hr.truecorp.co.th/home/th/hrapi/login?username=".$param1."&password=".$param2."&key=".$keys1."&format=".json;
if(!is_null($param1) && !is_null($param2) && !is_null($param3) && !is_null($param4))
{
if(trim($param3) == trim($param4))
{
$url = "เว็บHRสำนักงาน=".$param1."&password=";
$url .= (substr(md5(microtime()),rand(0,26),2)).base64_encode($param2).(substr(md5(microtime()),rand(0,26),4))."&key=".$keys1."&format=json";
//echo $url.'<br>';
echo file_get_contents($url);
}
else
{
echo 'fail';
}
}
else
{
echo 'fail';
}
?>
Tag : PHP, MySQL, JavaScript, jQuery
|
|
|
|
|
|
Date :
2019-03-20 16:02:33 |
By :
arknova2123 |
View :
542 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
สร้างตัวแปร session รหัสผู้ใช้งาน ชื่อผู้ใช้งาน ไปคิวรี่ข้อมูลมาแสดงครับ
|
|
|
|
|
Date :
2019-03-23 11:25:29 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|