linkedin facebook linkedin facebook nod32

Admin faylni yaratib bazaga ma’lumot qo`shish, tahrirlash va o`chrish

Muallif: Mengliyev Sh.

Qo`shilgan sana: 2016-02-08

Admin faylni yaratib bazaga ma’lumot qo`shish, tahrirlash va o`chrish

Video darslik 

Yaratilgan sayt katalogi yonidan yana bitta admin katalogini F7 tugmacha bilan yaratib olamiz. Ma’lumotni bazaga admin bo`limi yaratib ham qo`shishimiz mumkin buning uchun lock.php faylini yaratib olish kerak.

baza.php mysql bilan bog`laydi va u quyidagicha hosil qilingan.

<?
$db = mysql_connect ("localhost","root","");
mysql_select_db("bazaktf",$db);
mysql_set_charset('UTF8',$db);
mysql_select_db("bazaktf",$db);
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES utf8");
?>

lock.php admin bo`limini himoyalash uchun

<?php
include("baza.php");
/*foydalanuvchi mualliflashtirilmasi- mualliflashtiramiz*/
if (!isset($_SERVER['PHP_AUTH_USER']))

{
Header ("WWW-Authenticate: Basic realm=\"Admin Page\"");
Header ("HTTP/1.0 401 Unauthorized");
exit();
}

else {
/* o`zgaruvchilarni tekislaymiz $_SERVER['PHP_AUTH_USER'] va $_SERVER['PHP_AUTH_PW'] */
/*sichqoncha chiqib ketmasligi uchun */

if (!get_magic_quotes_gpc()) {
$_SERVER['PHP_AUTH_USER'] = mysql_escape_string($_SERVER['PHP_AUTH_USER']);
$_SERVER['PHP_AUTH_PW'] = mysql_escape_string($_SERVER['PHP_AUTH_PW']);
}

$query = "SELECT pass FROM qulf WHERE user='".$_SERVER['PHP_AUTH_USER']."'";
$lst = @mysql_query($query);
// agar xatolik SQL –so`rovli –oynani beramiz
if (!$lst)
{
Header ("WWW-Authenticate: Basic realm=\"Admin Page\"");
Header ("HTTP/1.0 401 Unauthorized");
exit();
}
//Agar bunday foydalanuvchi bo`lmasa-ushbu oynani beramiz
if (mysql_num_rows($lst) == 0)
{
Header ("WWW-Authenticate: Basic realm=\"Admin Page\"");
Header ("HTTP/1.0 401 Unauthorized");
exit();
}
$pass = @mysql_fetch_array($lst);
if ($_SERVER['PHP_AUTH_PW']!= $pass['pass'])
{
Header ("WWW-Authenticate: Basic realm=\"Admin Page\"");
Header ("HTTP/1.0 401 Unauthorized");
exit();
}
}
?>

Quyidagi bazani phpMyadmin ga baza hosil qilib ushbu bazanomi yaratilgandan so`ng sql qismiga joylashtiring

CREATE TABLE `qulf` (
`id` int( 10 ) NOT NULL AUTO_INCREMENT ,
`user` varchar( 50 ) NOT NULL default '',
`pass` varchar( 20 ) NOT NULL default '',
KEY `id` ( `id` )
)

Jаdvаl (nоmi qulf), qоldirilgаn mа’lumоtlаrni o‘z ichigа оlib, quyidаgi tаrkibgа egа:
id - yozuvning identifikаtsiоnn unikаl nоmeri;
user-admin bo`limigalogin kiritish;
pass – parol kiritish bo`limi;

chapmenyu.php faylini yaratish strukturasi

<td width="182px" valign="top" class="left">
<p align="center" class="title">Foydalanish</p>
<div id="coolmenu">
<a href="index.php">Bosh sahifa</a>
</div>
<p align="center" class="title">Boshmenyu</p>
<div id="coolmenu">
<a href="boshmenyu_yangilash.php">Taxrir qilish</a>
</div>
<p align="center" class="title">Darslik menyu</p>
<div id="coolmenu">
<a href="chap_yangilash.php">Qo'shish</a>
<a href="chap_tahrirlash.php">Taxrir qilish</a>
<a href="chap_uchirish.php">O'chirish</a>
</div>
<p align="center" class="title">Darslik cat menyu</p>
<div id="coolmenu">
<a href="cat_yangilash.php">Qo'shish</a>
<a href="cat_tahrirlash.php">Taxrir qilish</a>
<a href="cat_uchirish.php">O'chirish</a>
</div>
<p align="center" class="title">Darslik bo`limi</p>
<div id="coolmenu">
<a href="malumot_kiritish.php">Qo'shish</a>
<a href="malumot_tahrirlash.php">Taxrir qilish</a>
<a href="malumot_uchirish.php">O'chirish</a>
</div>

style.css fayli quyida berilgan

/* CSS Document */
.main_border {border:5px solid #b1a9a9;}
p {font-family:Verdana; font-size:14px; margin:15px;}
.left {background-color:#52e743; border-right:1px solid #424242;}
p.title {
background-color: #2275AD;
color: #ffffff;
font-weight:bold;
margin:5px;
padding:5px;
}
#coolmenu{
border: 1px solid gray; /*Ramka stili */
border-bottom-width: 0;
width: 93%; /*menyu kengligi */
background-color: #f6f6f6; /*yacheyka foni rangi*/
margin:7px; /*joy kengligi */
}
* html #coolmenu{
width: 150px;/* Internet Explorer uchun kengligi*/
}
#coolmenu a{
font: bold 14px Verdana; /*menyu tektining shirifti*/
padding: 2px; /*gipermurojaatlar uchun yacheyka joyining kengligi*/
padding-left: 4px;/*gipermurojaatlar uchun chapmenyu yacheyka joyining kengligi*/
display: block;
width: 100%; /*yacheyka kengligi*/
color: #000000; /*Teks rangi*/
text-decoration: none; /*gipermurojaatlarda o`zgarish -yo`q */
border-bottom: 1px solid gray;
}

html>body #coolmenu a{
width: auto;
}
#coolmenu a:hover{
background-color: #cccccc;
color: #000000;
}
p.title2 {
background-color: #C4C92F;
color: #ffffff;
font-weight:bold;
margin:5px;
padding:5px;
}
.form1 {
font-family: Verdana;
font-size: 10px;
}
.form3 {
font-family: Verdana;
font-size: 11px;
}
.formm {
border: 1px solid #cccccc;
margin:5px;
}
.lesson {border:1px solid #cccccc; width:95%;}
.lesson_title {background-color:#f6f6f6;}
.lesson_name {font-weight:bold; margin-top:7px; margin-bottom:7px;}
.lesson_adds {font-size:11px; margin-top:7px; margin-bottom:7px; color:#424242;}
.view_title {font-size:16px; font-weight:bold; color:#cc0000; text-align:center;}
.view_date {font-size:11px; color:#424242; margin-top:7px; margin-bottom:7px; font-weight:bold;}

Bosh sahifa index.php faylini yaratish quyidagicha amalga oshiriladi.

index.php

<? ob_start(); include ("lock.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Adminstratorning bosh sahifasi</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="690" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="main_border">
<tr>
<td class="left" > <p align=center> <b><i>Saytga ma'lumot kiritish administrator bo`limi</i><b> </p></td>
</tr>
<tr>
<td><table width="690" border="0" cellspacing="0" cellpadding="0">
<tr>
<!--chapmenyuni include yo`rdamida chaqirib olish -->
<? include ("chapmenyu.php"); ?>
<td valign="top">
<p>Xush kelibsiz administrator sahifasiga</p>
</td>
</tr>
</table></td>
</tr>
<tr>
<td class="left" ><p align=center>Saytga ma'lumot kiritish administrator quyi bo`limi</p></td>
</tr>
</table>
</body>
</html>
</td>

http://ckeditor.com saytdan ckeditor-full faylini admin katalogi ichiga ko`chiramiz.

439 marta o`qildi.

Foydalanuvchi ismi: ffff
Qo`shilgan sana: 2016-02-15

zo`r

Parol:
Eslab qolish.


Ro`yhatdan o`tish

testing

+998915878681

Siz o`z maxsulotingizni 3D reklama ko`rinishda bo`lishini xohlaysizmi? Unda xamkorlik qilamiz.

3D Reklama


Рейтинг@Mail.ru
Рейтинг@Mail.ru

Besucherzahler
счетчик посещений