Advertisement
tam1993

profile.php

Apr 8th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.72 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include 'connec.php';
  4. if (isset($_SESSION['username'])) {
  5.   //query all user data
  6.   $sql="SELECT * from user where  user_id='".$_SESSION['id']."' ";
  7.   $result=mysql_query($sql);
  8.   $rs=mysql_fetch_array($result);
  9.   //logout
  10.   if (isset($_GET['act'])) {
  11.     if ($_GET['act'] == 'logout'){
  12.       session_destroy();
  13.       echo " <meta http-equiv=\"refresh\" content=\"0; url=index.php\">";
  14.     }
  15.   }
  16.   //echo $_SESSION['username']."<a href='?act=logout'>logout</a></br>";
  17.   //check update data
  18.   if (isset($_POST['value'])) {
  19.     if ($_POST['name'] == 'name') {
  20.       $user = $_POST['value'];
  21.       $update = "UPDATE user SET user_fullname='".$_POST['value']."' WHERE user_id='".$_SESSION['id']."' ";
  22.       $result_update=mysql_query($update);
  23.     }if ($_POST['name'] == 'lastname') {
  24.       $user = $_POST['value'];
  25.       $update = "UPDATE user SET user_lastname='".$_POST['value']."' WHERE user_id='".$_SESSION['id']."' ";
  26.       $result_update=mysql_query($update);
  27.     }if ($_POST['name'] == 'tel') {
  28.       $user = $_POST['value'];
  29.       $update = "UPDATE user SET tel='".$_POST['value']."' WHERE user_id='".$_SESSION['id']."' ";
  30.       $result_update=mysql_query($update);
  31.     }
  32.   }
  33.   ?>
  34.  
  35.   <!DOCTYPE html>
  36.   <html lang="en">
  37.     <head>
  38.       <meta charset="utf-8">
  39.       <title>Profile</title>
  40.       <meta name="viewport" content="width=device-width, initial-scale=1.0">
  41.  
  42.       <!-- bootstrap -->
  43.       <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
  44.       <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
  45.       <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
  46.  
  47.       <!-- x-editable (bootstrap version) -->
  48.       <link href="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.4.6/bootstrap-editable/css/bootstrap-editable.css" rel="stylesheet"/>
  49.       <script src="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.4.6/bootstrap-editable/js/bootstrap-editable.min.js"></script>
  50.  
  51.     </head>
  52.  
  53.     <body>
  54.         <div class="container">
  55.           <div class="controls controls-row">
  56.             <h1 class="span4">Welcome <?php echo $_SESSION['username']; ?></h1>
  57.             <a href="?act=logout" class="btn btn-large btn-primary span4">Logout</a>
  58.           </div>
  59.  
  60.  
  61.  
  62.  
  63.  
  64.             <table id="user" class="table table-bordered table-striped" style="clear: both">
  65.                 <tbody>
  66.                     <tr>
  67.                         <td width="35%">fullname</td>
  68.                         <td width="65%">
  69.                           <a href="#" id="fullname" data-name="name" data-value="<?php echo $rs['user_fullname']; ?>">
  70.                             <?php if (!empty($rs['user_fullname'])) {
  71.                               echo $rs['user_fullname'];
  72.                             }else {
  73.                               echo "<font color='red'>Enter Name</font>";
  74.                             } ?>
  75.                           </a>
  76.                         </td>
  77.                     </tr>
  78.                     <tr>
  79.                         <td>LastName</td>
  80.                         <td>
  81.                           <a href="#" id="lastname" data-name="lastname" data-value="<?php echo $rs['user_lastname']; ?>">
  82.                             <?php if (!empty($rs['user_lastname'])) {
  83.                                 echo $rs['user_lastname'];
  84.                               }else {
  85.                                 echo "<font color='red'>Enter LastName</font>";
  86.                             } ?></a>
  87.                         </td>
  88.                     </tr>
  89.                     <tr>
  90.                         <td>Telephone</td>
  91.                         <td>
  92.                           <a href="#" id="tel" data-name="tel" data-value="<?php echo $rs['tel']; ?>">
  93.                             <?php if (!empty($rs['tel'])) {
  94.                                 echo $rs['tel'];
  95.                               }else {
  96.                                 echo "<font color='red'>Enter Tel</font>";
  97.                             } ?></a>
  98.                         </td>
  99.                 </tbody>
  100.             </table>
  101.         </div>
  102.  
  103.       <script>
  104.       //toggle `popup` / `inline` mode
  105.       $.fn.editable.defaults.mode = 'inline';
  106.       //update name
  107.       $('#fullname').editable({
  108.         type: 'text',
  109.         pk: 1,
  110.         url: 'profile.php'
  111.       });
  112.       //update lastname
  113.       $('#lastname').editable({
  114.         type: 'text',
  115.         pk: 1,
  116.         url: 'profile.php'
  117.       });
  118.       //update tel
  119.       $('#tel').editable({
  120.         type: 'text',
  121.         pk: 1,
  122.         url: 'profile.php'
  123.       });
  124.       </script>
  125.  
  126.     </body>
  127.   </html>
  128.  
  129.  
  130.  
  131. <?php
  132. }else {
  133.   echo "Please Login";
  134. }
  135.  
  136.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement