变量状态是未定义的,但确实如此

时间:2018-03-15 00:14:57

标签: php html

所以我有一个数据表,允许人们看到某些信息,虽然当我尝试调用$ data(用户名)时,它声明它是未定义的 未定义的变量:第80行的数据

我试图更改名称数据以及名称和表名等信息中的名称,但我没有成功

<?php
ob_start();
include('auth.php');
include('admin-auth.php');
include('header.php');
 if(isset($_GET['uid']) && $_GET['uid'] != ''){
    $query = "SELECT * FROM players WHERE uid='".$_GET['uid']."'";
	$res = $con->query($query);
	if($res->num_rows != 0){
	$data = $res->fetch_assoc();
	}else{
		header("Location: all-users-game.php");
	} 
 }
	if(isset($_POST['uid'])){
		$name = $_REQUEST['name'];
		$pid = $_REQUEST['pid'];
		$cash = $_REQUEST['cash'];
		$bankacc = $_REQUEST['bankacc'];
		$coplevel = $_REQUEST['coplevel'];
		$mediclevel = $_REQUEST['mediclevel'];
		$query = "UPDATE players SET name = '".$name."', cash = '".$cash."', bankacc = '".$bankacc."', coplevel = '".$coplevel."', mediclevel = '".$mediclevel."', pid = '".$pid."' WHERE uid = '".$_REQUEST['uid']."'";
		$result = $con->query($query);
		if($result){
			echo "<script>alert('Data Updated.')</script>";
			header('location:all-users-game.php');
		}
	}
	
	?>
<style>
.profile_details textarea {
    width: 100%;
    height: 50px;
    border: 1px solid #fff;
    background: none;
    padding: 0 20px;
    font-size: 18px;
    font-weight: 300;
    color: #fff;
    border-radius: 10px;
    font-family: 'Roboto', sans-serif;
}
.update-edit button { 

background: rgba(88,134,23,1);
background: -moz-linear-gradient(left, rgba(88,134,23,1) 0%, rgba(139,190,72,1) 53%, rgba(88,134,23,1) 100%);
background: -webkit-gradient(left top, right top, color-stop(0%, rgba(88,134,23,1)), color-stop(53%, rgba(139,190,72,1)), color-stop(100%, rgba(88,134,23,1)));
background: -webkit-linear-gradient(left, rgba(88,134,23,1) 0%, rgba(139,190,72,1) 53%, rgba(88,134,23,1) 100%);
background: -o-linear-gradient(left, rgba(88,134,23,1) 0%, rgba(139,190,72,1) 53%, rgba(88,134,23,1) 100%);
background: -ms-linear-gradient(left, rgba(88,134,23,1) 0%, rgba(139,190,72,1) 53%, rgba(88,134,23,1) 100%);
background: linear-gradient(to right, rgba(88,134,23,1) 0%, rgba(139,190,72,1) 53%, rgba(88,134,23,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#588617', endColorstr='#588617', GradientType=1 );

padding: 7px 40px;
    border: 0px;
    font-size: 20px;
    text-align: center;
    color: #fff;
    margin: 0 10px;
    border-radius: 10px;
    text-transform: uppercase;
    display: inline-block;
    font-family: 'Audiowide', cursive;
}
</style>
<div class="title">
    	<h1>Update User</h1>
		
    </div>
    <div class="profile_details">
    <div class="profile_info">
    	<h1>Update User Detail</h1>
		<form method="post" >
        <div class="row">

            <div class="col-md-12">
            <div class="pro_row">
                	<label>Username</label>
                    <input type="text" name="username" placeholder="Username" readonly value="<?php echo $data['name']; ?>">
				<input type="hidden" name="uid"
				value="<?php echo $data['uid']; ?>">
                </div>
            </div>

我知道那里有一些我不需要的东西,这也不是整个页面。

0 个答案:

没有答案