php 登录访问有关问题

PHPz
Release: 2018-11-13 15:24:26
Original
1101 people have browsed it

php 登录访问问题

做个简单的录入网页

登录是可以了 但是 我想 一个用户 只能管理一个村的数据   现在登录进去之后 地址栏?id= 后面我可以随便修改 一样能登录···
比如 一个人用1帐号登录进来 只能管理1的数据  但是在地址栏把1 改成2 他就可以管理2的数据 怎么限制的·· 本人菜鸟 表示很蛋疼 在线跪求大手

<?php  
$conn=mysql_connect("localhost","xypi20","a16812343");
mysql_select_db("js");
mysql_query("set names &#39;gb2312&#39;");
if(isset( $_POST["user"])){
  $user=$_POST["user"];
$password=$_POST["password"];
$sql="select  * from login where user=&#39;{$user}&#39;and password=&#39;{$password}&#39;";
   $query=mysql_query($sql);
$array=mysql_fetch_array($query);
    
    
if($user==$array{&#39;user&#39;} and $password==$array{&#39;password&#39;} ){
$kind=$array{&#39;kind&#39;};
session_start();
$_SESSION[&#39;keyword&#39;]= "$kind";
echo"<script>alert(&#39;登录成功!&#39;);location.href=&#39;test.php?id=$kind&#39;;</script>";  }
else  
echo"<script>alert(&#39;请重新登录!&#39;);location.href=&#39;login.php&#39;;</script>";
}
    
?>
Copy after login

管理界面

<?php  
$conn=mysql_connect("localhost","xypi20","a16812343");
mysql_select_db("js");
mysql_query("set names &#39;gb2312&#39;");
  $kind = $_GET[&#39;id&#39;];
/*session_start();
if(!isset($_SESSION[&#39;keyword&#39;]))
   echo"<script>alert(&#39;请登录!&#39;);location.href=&#39;login.php&#39;;</script>";*/
echo $kind;
session_start();
if( isset($_SESSION[&#39;keyword&#39;]) !=$kind)
  echo"<script>alert(&#39;请登录!&#39;);location.href=&#39;login.php&#39;;</script>";
  
  
?>
  <?php
  if(isset($_POST["name"],$_POST["time"])){
   $name=$_POST["name"];
   $time=$_POST["time"];
   echo $name;
   echo $time;
   echo $kind;
   $sql="SELECT  * FROM  数据 where kind=&#39;$kind&#39; ";
      if($name)  //name不为空
  {
  $sql .="  and 姓名=&#39;$name&#39; ";
  if($time)
  $sql .=" and 录入时间=&#39;$time&#39; ";
   
  }
  elseif($time)
{
 $sql .="and 录入时间=&#39;$time&#39;";
}
Copy after login

问题就在这查询里面我 是直接  where kind='$kind' 所以不管用什么帐号登录进来 修改地址栏的kind就可以查询别的数据了···

以上就是对使用PHP实现生成HTML静态页面,php静态页面的全部介绍,如果您想了解更多有关php编程入门,请关注PHP中文网。


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template