|  |  | 
          
            | ของเดิมของมัน Step 1
 
  
 Step 2
 
  
 Step 3
 
  
 
 แต่อยากให้เป็นแบบนี้ครับต้องแก้ยังไงครับ
 
 Step 1
 
  
 Step 2
 
  
 
 Controller
 Code (PHP)
 
 <?php
defined('BASEPATH') OR exit('No direct script access allowed');
class cApiGoogle extends CI_Controller {
	public function index(){
		
		if($this->session->userdata('login') == true){
			redirect('cApiGoogle/wprofile');
			
		}
		
		if (isset($_GET['code'])) {
			
			$this->googleplus->getAuthenticate();
			$this->session->set_userdata('login',true);
			$this->session->set_userdata('user_profile',$this->googleplus->getUserInfo());
			redirect('cApiGoogle/wprofile');
			
		} 
			
		$contents['login_url'] = $this->googleplus->loginURL();
		$this->load->view('welcome_message',$contents);
	}
	
	public function wprofile(){
		
		if($this->session->userdata('login') != true){
			redirect('');
		}
		
		$contents['user_profile'] = $this->session->userdata('user_profile');
		$this->load->view('wprofile',$contents);
	}
	
	public function logout(){
		$this->session->sess_destroy();
		$this->googleplus->revokeToken();
		redirect('cRegister');
		
	}
}
 หน้า View
 
 Welcome_message.php
 Code (PHP)
 
 <!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>Sign In With Google+</title>
	<link href="<?php echo base_url();?>assets/AdaCss/AdaApi.css" rel="stylesheet">
</head>
<body>
<div id="container">
	<h1>Sign In With Google+</h1>
	<div id="body">
		<p><a href="<?php echo $login_url;?>"><img src="./assets/Adaimg/sign_in.jpg" width="300"></a></p>
		
	</div>
	<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds. <?php echo  (ENVIRONMENT === 'development') ?  'CodeIgniter Version <strong>' . CI_VERSION . '</strong>' : '' ?></p>
</div>
</body>
</html>
 wprofile.php
 
 Code (PHP)
 
 <!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Sign In With Google+</title>
	<style type="text/css">
	::selection{ background-color: #E13300; color: white; }
	::moz-selection{ background-color: #E13300; color: white; }
	::webkit-selection{ background-color: #E13300; color: white; }
	body {
		background-color: #fff;
		margin: 40px;
		font: 13px/20px normal Helvetica, Arial, sans-serif;
		color: #4F5155;
	}
	a {
		color: #003399;
		background-color: transparent;
		font-weight: normal;
	}
	h1 {
		color: #444;
		background-color: transparent;
		border-bottom: 1px solid #D0D0D0;
		font-size: 19px;
		font-weight: normal;
		margin: 0 0 14px 0;
		padding: 14px 15px 10px 15px;
	}
	code {
		font-family: Consolas, Monaco, Courier New, Courier, monospace;
		font-size: 12px;
		background-color: #f9f9f9;
		border: 1px solid #D0D0D0;
		color: #002166;
		display: block;
		margin: 14px 0 14px 0;
		padding: 12px 10px 12px 10px;
	}
	#body{
		margin: 0 15px 0 15px;
	}
	
	p.footer{
		text-align: right;
		font-size: 11px;
		border-top: 1px solid #D0D0D0;
		line-height: 32px;
		padding: 0 10px 0 10px;
		margin: 20px 0 0 0;
	}
	
	#container{
		margin: 10px;
		border: 1px solid #D0D0D0;
		-webkit-box-shadow: 0 0 8px #D0D0D0;
	}
	</style>
</head>
<body>
<div id="container">
	<h1>Get member from Google+</h1>
	<div id="body">
		<p>My Profile</p>
		<table>
			<tr>
				<td>ID</td>
				<td>:</td>
				<td><?php echo @$user_profile['id'];?></td>
			</tr>
			<tr>
				<td>Name</td>
				<td>:</td>
				<td><?php echo @$user_profile['name'];?></td>
			</tr>
			<tr>
				<td>First Name</td>
				<td>:</td>
				<td><?php echo @$user_profile['given_name'];?></td>
			</tr>
			<tr>
				<td>Last Name</td>
				<td>:</td>
				<td><?php echo @$user_profile['family_name'];?></td>
			</tr>
			<tr>
				<td>Email</td>
				<td>:</td>
				<td><?php echo @$user_profile['email'];?></td>
			</tr>
			<tr>
				<td>Gender</td>
				<td>:</td>
				<td><?php echo @$user_profile['gender'];?></td>
			</tr>
			<tr>
				<td>Photo</td>
				<td>:</td>
				<td><img src="<?php echo $user_profile['picture'];?>" width="200"></td>
			</tr>
		</table>
		
		<p><a href="<?php echo site_url('cApiGoogle/logout');?>">Sign Out</a></p>
	
	</div>
	<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds</p>
</div>
</body>
</html>
 
 
 Tag : PHP, MySQL, HTML, CSS, HTML5, JavaScript
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2018-07-30 10:38:54 | By :
                          witsarut_bell | View :
                          689 | Reply :
                          6 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |