Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include 'connec.php';
- if (isset($_SESSION['username'])) {
- //query all user data
- $sql="SELECT * from user where user_id='".$_SESSION['id']."' ";
- $result=mysql_query($sql);
- $rs=mysql_fetch_array($result);
- //logout
- if (isset($_GET['act'])) {
- if ($_GET['act'] == 'logout'){
- session_destroy();
- echo " <meta http-equiv=\"refresh\" content=\"0; url=index.php\">";
- }
- }
- //echo $_SESSION['username']."<a href='?act=logout'>logout</a></br>";
- //check update data
- if (isset($_POST['value'])) {
- if ($_POST['name'] == 'name') {
- $user = $_POST['value'];
- $update = "UPDATE user SET user_fullname='".$_POST['value']."' WHERE user_id='".$_SESSION['id']."' ";
- $result_update=mysql_query($update);
- }if ($_POST['name'] == 'lastname') {
- $user = $_POST['value'];
- $update = "UPDATE user SET user_lastname='".$_POST['value']."' WHERE user_id='".$_SESSION['id']."' ";
- $result_update=mysql_query($update);
- }if ($_POST['name'] == 'tel') {
- $user = $_POST['value'];
- $update = "UPDATE user SET tel='".$_POST['value']."' WHERE user_id='".$_SESSION['id']."' ";
- $result_update=mysql_query($update);
- }
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Profile</title>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <!-- bootstrap -->
- <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
- <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
- <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
- <!-- x-editable (bootstrap version) -->
- <link href="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.4.6/bootstrap-editable/css/bootstrap-editable.css" rel="stylesheet"/>
- <script src="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.4.6/bootstrap-editable/js/bootstrap-editable.min.js"></script>
- </head>
- <body>
- <div class="container">
- <div class="controls controls-row">
- <h1 class="span4">Welcome <?php echo $_SESSION['username']; ?></h1>
- <a href="?act=logout" class="btn btn-large btn-primary span4">Logout</a>
- </div>
- <table id="user" class="table table-bordered table-striped" style="clear: both">
- <tbody>
- <tr>
- <td width="35%">fullname</td>
- <td width="65%">
- <a href="#" id="fullname" data-name="name" data-value="<?php echo $rs['user_fullname']; ?>">
- <?php if (!empty($rs['user_fullname'])) {
- echo $rs['user_fullname'];
- }else {
- echo "<font color='red'>Enter Name</font>";
- } ?>
- </a>
- </td>
- </tr>
- <tr>
- <td>LastName</td>
- <td>
- <a href="#" id="lastname" data-name="lastname" data-value="<?php echo $rs['user_lastname']; ?>">
- <?php if (!empty($rs['user_lastname'])) {
- echo $rs['user_lastname'];
- }else {
- echo "<font color='red'>Enter LastName</font>";
- } ?></a>
- </td>
- </tr>
- <tr>
- <td>Telephone</td>
- <td>
- <a href="#" id="tel" data-name="tel" data-value="<?php echo $rs['tel']; ?>">
- <?php if (!empty($rs['tel'])) {
- echo $rs['tel'];
- }else {
- echo "<font color='red'>Enter Tel</font>";
- } ?></a>
- </td>
- </tbody>
- </table>
- </div>
- <script>
- //toggle `popup` / `inline` mode
- $.fn.editable.defaults.mode = 'inline';
- //update name
- $('#fullname').editable({
- type: 'text',
- pk: 1,
- url: 'profile.php'
- });
- //update lastname
- $('#lastname').editable({
- type: 'text',
- pk: 1,
- url: 'profile.php'
- });
- //update tel
- $('#tel').editable({
- type: 'text',
- pk: 1,
- url: 'profile.php'
- });
- </script>
- </body>
- </html>
- <?php
- }else {
- echo "Please Login";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement