用户详细信息不变。 PHP

时间:2014-11-24 17:30:57

标签: php

我创建了一个成员脚本。现在我试图创建一个帐户设置,用户可以更改他们的用户名,生物,全名等。但它的工作正常我更改它更改的名称,名称保留在表单中作为新名称。但问题是,当我回到profile.php页面时,其名称来自上一个会话,直到我退出并重新登录它并没有改变。我必须破坏会话吗?谢谢。 如果你们想要现场试试,我的网站是:iphone.hostei.com用户名= demo@demo.com密码= demo123

settings.php

   <?php

    ini_set('display_errors', 1); 
    error_reporting(E_ALL);
    session_start();

    include_once('php/classes/head.php');
    include_once('php/classes/db_config.php');
    include_once('php/classes/class.user.php');

    $user1 = new User($con);
    $g_id = (int)isset($_GET['uid']);

    $name_id = $_SESSION['user']['uid'];
    $name = $_SESSION['user']['uname'];
    $fullname = $_SESSION['user']['fullname'];
    $bio = $_SESSION['user']['bio'];
    @$email = $_SESSION['user']['uemail'];

    if(isset($_POST['submit'])){
        if(empty($_POST['uname'])){
            echo "Empty Username";
        }else{
            $user1 -> insert_usr($_POST['uname'], $fullname, $bio, $email);
            echo "Success";
        }   
    }

    if($name){
        $sql = ("SELECT * FROM users WHERE uid= :uid");
        $q = $con->prepare($sql);
        $q -> execute(array(':uid'=>$name_id));
        $result = $q->fetchALL(PDO::FETCH_ASSOC);

        foreach ($result as $row){

            ?>
            <form action='' method='POST'>
            Username: <input type='text' name='uname' value='<?php echo $row['uname']; ?>'/>
            <br/>
            Full Name: <input type='text' name='fname' placeholder='<?php echo $row['fullname']; ?>'/>
            <br/>
            Bio: <input type='text' name='bio' placeholder='<?php echo $row['bio']; ?>'/>
            <br/>
            Email: <input type='text' name='email' placeholder='<?php echo $row['uemail']; ?>'/>
            <br/>
            <input type='submit' name='submit' value='submit'/>
            </form>
            <?php
        }

    }else{

    }

?>  

profile.php

    <?php
    ini_set('display_errors', 1); 
    error_reporting(E_ALL);
    session_start();

    include_once('php/classes/head.php');
    include_once('php/classes/db_config.php');
    include_once('php/classes/class.user.php');

    $g_id = (int)$_GET['uid'];

    $user1 = new User($con);
    $is_loggedin = (isset($_SESSION['uid']));
    $is_uid = (!empty($g_id) && is_numeric($g_id));
    $def_uid = ($is_uid) ? $g_id : isset($_SESSION['uid']);
    $user_valid = ($is_uid == true) ? $user1->check_user($def_uid) : 1;

    $name_id = $_SESSION['user']['uid'];
    echo $name = $_SESSION['user']['uname'];
    $fullname = $_SESSION['user']['fullname'];
    $bio = $_SESSION['user']['bio'];
    $time = date("Y-m-d H:i:s");

    if (isset($_POST['logout'])) {
        session_destroy();
        header('Location: index.php');
        exit;
    }
    if (isset($_POST['area_sub'])) {
        if (empty($_POST['area'])) { ?>
            <div id='hide' style='display: none'>Error</div>
            <script>
                $('#hide').show(1000, function(){
                    $('#hide').delay(1500);
                    $('#hide').hide(1500);
                });
            </script>
<?php }else{
            $uid = $_GET['uid'];
            if ($uid == '' || $uid == 0) {
                $uid = $name_id;
            }
            $user1->post($name_id, $uid, $name, $_POST['area'], $time);
        }
    }
    if($is_loggedin){
        $sql = "SELECT * FROM follow_req WHERE user_two_req= :user_two_req";
        $query = $con->prepare($sql);
        $query->execute(array( ':user_two_req' => $name_id));
        $result = $query->fetchALL(PDO::FETCH_ASSOC);
    }
?>
    <body>
    <?php 
        if($is_loggedin !== true) { 
            include_once 'php/common/head.php'; 
        }
    ?>
    <?php
    // If there is a propper UID available
    if(($is_loggedin == true) || ($is_uid == true)) { ?>

    <?php if ($is_loggedin == true){ ?>

    <div id="menu">
        <div id="menu_wrapper">
            <div id="left_menu">
                <a href='settings.php' class='act'>Account Settings</a>
            </div>
            <div id="right_menu">
                <div id='drop-zone'><?php
                    if($result == false){
                        echo "<h4 class='request'>0</h4>";
                    }else{ 
                        echo "<a href='#' class='request_more'>".count($result)."</a>";
                    }   
                ?></div>
                <form action='' method='post'>
                    <input type='hidden' name='logout' value='true' />
                    <input type='submit' name='submit' value='Logout' id='btn'>
                </form>
            </div>
        </div>
    </div>

    <?php } ?>

    <div id="profile_wrapper">

        <div class="wrapper">

            <div id="profile">  

            <?php

            // If user is valid
            if($user_valid == true) {
                // User is logged in user
                if($def_uid == $name_id) {
                    include_once 'php/classes/profile_func.php';
                } 
                include_once 'php/classes/user_info.php';

            }else{?>
                <h2>No Such User Exists</h2>
                <h3>Please select a different user or <a href='index.php'>Login</a></h3>
                <?php if($is_loggedin == true){ ?>
                        <h3>Go Back to <a href="profile.php?uid=<?php echo $name_id;?>">My Profile</a></h3>
                    <?php
                }
            } ?>

<?php }else{?>
        <h1>Invalid User</h1>
        <h3>You must be <a href="index.php">Logged IN</a> to see your profile OR you must select a profile (uid) to view.</h3>
<?php } ?>
            </div>
        </div>
    </div>
<?php if($is_loggedin != true){ ?>
    <div id="footer">
        <h4>Per momentin vetem njerezit qe do perzgjidhen do kene akses.</h4>
        <a href="#">
            <div id="button">Kerkese Hyerje</div>
        </a>
        </div>
<?php } ?>

<script>

function LookUp(IdElem,URL){
    $("#drop-zone").html('<div class="loader"></div>');
    $.ajax({
        url: URL,
        cache: false,
        success: function(result) {
            $("#drop-zone").html(result);
        }
    });
}
$(document).ready(function() {
    $("a.request_more").click(function(){
        LookUp(this,'requests.php');
    });
});
</script>

</body>
</html>     

0 个答案:

没有答案