Tag:增删改查

Tag (增删改查)'s result:

php+mysql's operations

基于上次实现的php+mysql实现超原始的注册登录之后,这次的故事实现在登录后以超级管理员身份进行对注册用户的增删改查操作,而以普通用户却无法实现操作数据库(这里涉及权限控制,我只是简单表示一下效果而已,还没实现真正的权限控制) 先放上连接数据库的页面(conndb.php): <?php $db = mysql_connect(“127.0.0.1″,”root”,”root”) or die(“Fail to connect db!”); mysql_select_db(“userdb”,$db) or die (“Can’t connect to userdb”.mysql_error()); ?> 以lsa超级管理员登录后页面(welcome.php)增强版: <?php $username = $_GET[‘uname’]; if($username==’lsa’){ echo ‘Welcome SuperAdmin ‘.$username.’!’; echo ‘<br/><br/>’; include(“/var/www/html/conndb.php”); //$sql = mysql_query(“select * from user order by username”); //$info = mysql_fetch_array($sql); if($_GET[‘page’]==””){ $_GET[‘page’] = 1; } if(is_numeric($_GET[‘page’])){ $page_size = 5; $query = “select count(*) as total from user order by username”; $result = mysql_query($query); $user_count = mysql_result($result,0,0); $page_count = ceil($user_count/$page_size); $offset = ($_GET[‘page’] – 1) * $page_size; $sql = mysql_query(“select * from user order by username limit $offset,$page_size”); $info = mysql_fetch_array($sql); //get a group record(5).mysql_num_rows($sql) is 5 } ?> <form name=”myform” method=”post” action=”search.php” target=”_blank” > <input name=”searchname” type=”text” id=”searchname” size=”25″> &nbsp; <input type=”submit” name=”Submit” value=”search”> </form> <a href=”add_user.php”>Add_user</a> <table width=”100%” height=”200″ border=”1″ cellpadding=”0″ cellspacing=”0″ bgcolor=”#9E7DB4″ align=”center”> <tr valign=”top” bgcolor=”#FFFFFF”> <td height=”100″> <table width=”100%” height=”100%” border=”0″ cellpadding=”0″ cellspacing=”0″> <tr> <td height=”90″ align=”center” valign=”top”> <table width=”100%” border=”0″ align=”center” cellpadding=”0″ cellspacing=”1″ bgcolor=”#625D59″> <tr align=”center” bgcolor=”#00cc00″> <td width=”70″>username</td> <td width=”200″>password</td> <td width=”20″>edit</td> </tr> <?php if($info==false){ echo “<div align=’center’ style=’color:#FF0000; font-size:18px’>Sorry,not found!</div>”;……