linkedin facebook linkedin facebook nod32

Elektron virtual qabulxona saytni php va MySql da yaratish usuli

Muallif: Mengliyev Sh.

Qo`shilgan sana: 2017-01-10

Elektron virtual qabulxona saytni php va MySql da yaratish usuli

Video darslik 

Qadam1 –Saytda ma’lumot qoldirish uchun mysql tizimida jadval yaratish

PHP tilida ma’lumot yoki xabar qoldirish uchun bazada jadval yaratib olamiz. Buning uchun http://localhost/openserver/phpmyadmin/index.php Базы данных bo`limidan evq baza yaratib sql bo`limiga quyidagi kodni joylashtiramiz.
CREATE TABLE `data` (
  `id` int(11) NOT NULL auto_increment,
  `cat` int(2) NOT NULL,
  `fish` varchar(60) NOT NULL,
  `mail` varchar(60) NOT NULL,
`manzil` varchar(80) NOT NULL,
  `ty` varchar(60) NOT NULL,
`jinsi` varchar(10) NOT NULL,
  `tel` varchar(60) NOT NULL,
`fayl_manzili` varchar(60) NOT NULL,
`yashrin` varchar(4) NOT NULL,
  `mt` varchar(60) NOT NULL,
  `text` varchar(500) NOT NULL,
  `date` varchar(18) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

Bazani izohlaymiz:
id – Ma’lumot yuboruvchining tartib raqani
cat – Ma’lumot yuboruvchining manzili.
fish – Ma’lumot qoldiruvchining familiya, ismi va sharifi .
mail – Ma’lumot yuboruvchining e-mail manzili.
manzil – Ma’lumot yuboruvchining yashash manzili.
ty – Ma’lumot yuboruvchining tug ‘ulgan yili.
jinsi – Ma’lumot yuboruvchining jinsi.
tel – Ma’lumot yuboruvchining telefon raqami.
fayl_manzili – Ma’lumot yuboruvchining fayl manzili ariza papkaga yuborish.
yashrin – Ma’lumot yuboruvchining telefon raqami.
mt – Ma’lumot yuboruvchining ma’lumot turi misol: ariza shikoyat va taklif.
text – Ma’lumot qoldiruvchining mavzu matni.
date – Ma’lumot qoldiruvchining sanasini qayt etadi: misol uchun 10.01.2017 ! 14:03.

Qadam2. baza.php fayli baza bilan ma`lumotlarni bog`lydi.

Quyida kodi keltirilganbaza.php

Baza.php mysql bilan bog`laydi va u quyidagicha hosil qilingan.
<?
$db = mysql_connect ("localhost","root","");
mysql_select_db("evq",$db);
mysql_set_charset('UTF8',$db);
mysql_select_db("evq",$db);
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES utf8");
?>
Qadam3. index.php faylini yaratib olamiz.

Index.php

<?php
include ("baza.php");
if (isset($_POST['fish'])) {$fish = $_POST['fish']; if ($fish == '') {unset($fish);}}
if (isset($_POST['manzil'])) {$manzil = $_POST['manzil']; if ($manzil == '') {unset($manzil);}}
if (isset($_POST['ty'])) {$ty = $_POST['ty']; if ($ty == '') {unset($ty);}}
if (isset($_POST['mail'])) {$mail = $_POST['mail']; if ($mail == '') {unset($mail);}}
if (isset($_POST['fayl_manzili'])) {$fayl_manzili = $_POST['fayl_manzili']; if ($fayl_manzili == '') {unset($fayl_manzili);}}
if (isset($_POST['text'])) {$text = $_POST['text']; if ($text == '') {unset($text);}}
if (isset($_POST['tel'])) {$tel = $_POST['tel']; if ($tel == '') {unset($tel);}}
if (isset($_POST['mt'])) {$mt = $_POST['mt']; if ($mt == '') {unset($mt);}}
if (isset($_POST['jinsi'])) {$jinsi = $_POST['jinsi']; if ($jinsi == '') {unset($jinsi);}}
if (isset($_POST['cat'])) {$cat = $_POST['cat']; if ($cat == '') {unset($cat);}}
if (isset($_POST['yashrin'])) {$yashrin = $_POST['yashrin']; if ($yashrin == '') {unset($yashrin);}}
$fayl_manzili = 'ariza/fayl.ico';
$dat = date('d.m.Y ! H:i');
?>
<html>
<style type="text/css">
.file-upload {
position: relative;
overflow: hidden;
width: 30%;
height: 20px;
background: #6da047;
border-radius: 3px;
padding: 8px 4px;
color: #fff;
text-align: center;
}
.file-upload:hover {
background: #7aad55;
}
.file-upload input[type="file"]{
display: none;

.s10 {color: #000000}
.s11 {color: #f10f0f}
.s14 {font-size: 14,5}
.s15 {color: #FF0000}
.s16 {
font-size: 12px;
font-family: "Times New Roman", Times, serif;
}
.s17 {font-size: 14px}
.s18{font-size: 18px}
.s19{
font-size: 18px;
color: #0033FF;
font-weight: bold;
}
.s20 {font-size: 24px; color: #0033FF; font-weight: bold; font-family: "Times New Roman", Times, serif; }
.s21 {color: #0033FF}
.s23 {color: #000000; font-family: "Times New Roman", Times, serif; }
.s25 {color: #FF0000; font-size: 16px; }
</style>
<body>
<head>
<meta charset="UTF-8" />
<meta name="robots" content="index,qabul" />
<title>Elektron virtual qabulxona</title>
</head>
<div class="wrapper">
<tr>
<td width="17%">

<div class="col-sm-4" style="text-align:right ">
<div class="row">
<p align="right"><img src="lotinbayroquzb.png" width="300" height="168" style="width:40px; height:20px;" onClick="window.location.href='index.php'"> <img src="kirilbayroquzb.png" width="284" height="177" style="width:40px; height:20px;" onClick="window.location.href='index1.php'"></p>
</div>
</div>
<table width="1180" class="form">
<tr>
<th width="166" height="117"><div align="center"><span class="s19"><img src="rasm1.png" alt="rasm1.png" width="126" height="55" longdesc="rasm2.png"></span></div></th>
<th width="598"><div align="left">
<p align="center" class="s20 s18"><span class="s10"><span class="s21">Tashkilot </span>tashkilot rahbari F.I.Sh. <span class="s21">VIRTUAL QABULXONASI</span></span></p>
</div></th>
<td width="400"><div align="center"><span class="s19"><img src="rasm1.jpg" alt="rasm1.jpg" width="400" height="115" longdesc="rasm2.jpg"></span></div></td>
</tr>
</table>
<p align="center" class="s19"><span class="s25"><var>Sizda hal etilmagan masalalar, muammolar, ariza, shikoyat yoki takliflar bormi? U holda murojaatingizni to‘g‘ridan-to‘g‘ri Tashkilotga yuborishingiz mumkin</var><var></var></span><span class="s18"><var>. </var></span></p>
<div align="center"></div>
<form name="form1" method="post" action="index.php" enctype="multipart/form-data">
<div>
<p class="s15"><img src="rasmlogo.jpg" alt="rasmlogo.jpg" width="1200" height="60" longdesc="rasmlogo.jpg" /></p>
</div>
<table width="1180" class="form">
<tr>
<th colspan="2"><div align="left"><span class="media s10 s16">Yulduzcha bilan belgilangan satrlar to‘ldirilish talab etiladi</span></div></th>
<td>&nbsp;</td>
<td><span class="s17">Ommaviy oferta</span></td>
</tr>
<tr>
<th width="161"><div align="left"><span class="s12">F.I.Sh.<span class="s11"><span class="s10">.</span>*</span></span></div></th>
<th width="371"><div align="left">
<input class="input_full" type="text" id="fish" name="fish" required="required" />
</div></th>
<td>&nbsp;</td>
<td width="579" rowspan="12"><p align="justify" class="s10">Hurmatli foydalanuvchi!</p>
<p align="justify" class="s10">Sizga Tashkilotga bevosita elektron tarzda murojaatlarni yuborish imkoniyati taqdim etilmoqda. Shu bilan birga, Sizning yuborayotgan murojaatingiz rasmiy maqomga ega ekanligini ham eslatib qo‘ymoqchimiz.
Shu sababli, Sizdan quyidagilarni unutmasligingizni so‘raymiz</p>
<p align="justify" class="s10">1. Jismoniy shaxs sifatida murojaat yo‘llasangiz familiyangiz (ismingiz, otangizning ismi), yashash joyingiz to‘g‘risidagi ma’lumotlar ko‘rsatilgan va murojaatingiz mohiyati bayon etilgan bo‘lishi shart. Yuridik shaxs sifatida murojaat yo‘llasangiz yuridik shaxsning to‘liq nomi, uning joylashgan joyi (pochta manzili) to‘g‘risidagi ma’lumotlar ko‘rsatilgan va murojaatning mohiyati bayon etilishi talab etiladi. </p>
<p align="justify" class="s10">2. Alohida e’tibor bering! Tuhmat, haqorat so‘zlar ishlatilgan va yolg‘on xabar beruvchi murojaatlarni taqdim etish mumkin emas. </p>
<p align="justify" class="s10">3. Shuningdek, quyidagi holatlarda murojaatlaringiz rad etilishi mumkinligini eslatib o‘tmoqchimiz: </p>
<p align="justify" class="s10">• Odobsizlik mazmunidagi murojaatlar (uyatsiz yoxud haqoratli iboralar, tahdidlar, mantiq va ma’nosi bo‘lmagan takliflar va shunga o‘xshash murojaatlar); </p>
<p align="justify" class="s10">• Murojaat matnida tushunarsiz qisqartirishlar yoki reklama materiallari mavjud bo‘lgan, tarkibida aniq arizalar, shikoyatlar yoki takliflar bo‘lmagan murojaatlar </p>
<p align="justify" class="s10">4.Shuningdek, foydalanuvchining bir necha bor bitta masala bo‘yicha javob berilgan murojaatini qayta yuborilganda agar unda yangi vajlar yoki holatlar keltirilmagan bo‘lsa, ko‘rib chiqilmaydi. </p>
<p align="justify" class="s10">Mazkur shartlarning barchasi O‘zbekiston Respublikasining amaldagi qonunchiligidan kelib chiqqan holda belgilangan.</p>
<p align="justify" class="s10"> <strong>
<input id="Agree2" name="Agree2" type="checkbox" value="1" />
</strong><span class="s23">Tanishdim</span></p></td>
</tr>
<tr>
<th><div align="left"><span class="s12">Hudud<span class="s11">*</span></span></div></th>
<th><div align="left">
<select name="cat">
<option value="">Tanlang...</option>
<option value="1k_2k">Hudud 1</option>
<option value="2k_3k">Hudud2</option>
<option value="3k_4k">Hudud3</option>
<option value="4k_5k">Hudud4</option>
<option value="1k_2k">Hudud5</option>
<option value="2k_3k">Hudud6</option>
<option value="3k_4k">Hudud7</option>
<option value="4k_5k">Hudud8</option>
<option value="1k_2k">Hudud9</option>
<option value="2k_3k">Hudud10</option>
<option value="3k_4k">Hudud11</option>
<option value="4k_5k">Hudud12</option>
</select>
</div></th>
</tr>
<tr>
<th><div align="left"><span class="s12">Manzil<span class="s11">*</span></span></div></th>
<th><div align="left">
<input class="input_full" type="text" id="manzil" name="manzil" required="required" />
</div></th>
<td>&nbsp;</td>
</tr>
<tr>
<th><div align="left"><span class="s12">Elektron pochta</span><span class="s11">*</span></div></th>
<th><div align="left">
<input class="input_full" type="email" id="mail" name="mail" required="required" />
</div></th>
<td>&nbsp;</td>
</tr>
<tr>
<th><div align="left"><span class="s12">Telefon<span class="s11">*</span></span></div></th>
<th><div align="left">
<input class="input_full" type="tel" id="tel" name="tel" required="required" />
</div></th>
<td>&nbsp;</td>
</tr>
<tr>
<th><div align="left"><span class="s12">Jinsi<span class="s11">* </span></span></div></th>
<th><div align="left"><span class="s28">
<input type="radio" name="jinsi" id="jinsi" value="Erkak">
<label for="priority_urgent"><span class="s10"> Erkak </span></label>
&nbsp;
&nbsp;
<input type="radio" name="jinsi" id="jinsi" value="Ayol">
<label for="priority_normal"> <span class="s10">Ayol</span></label>
</span>
<label for="priority_normal"></label>
</div></th>
<td>&nbsp;</td>
</tr>
<tr>
<th><div align="left"><span class="s12">Tug‘ulgan yilingiz<span class="s11">*</span></span></div></th>
<th><div align="left">
<input class="input_full" type="text" id="ty" name="ty" required="required" />
</div></th>
<td>&nbsp;</td>
</tr>
<tr>
<th><div align="left"><span class="s12">Murojaat turi<span class="s11">* </span></span></div></th>
<th><div align="left"><span class="s12">
<input id="mt" name="mt"
type="radio" value="Ariza" />
Ariza</span> <span class="s28">
<input id="mt" name="mt" type="radio" value="Shikoyat" />
<span class="s10">Shikoyat</span>
<input id="mt" name="mt" type="radio" value="Taklif" />
<span class="s10">Taklif</span></span></span><span class="s28">
</label>
</span></div></th>
<td>&nbsp;</td>
</tr>
<tr>
<th colspan="2"><div align="justify"><span class="s12">Murojaatingiz tezkor ravishda hal etilishini istasangiz, har bir masala bo‘yicha alohida murojaat yo‘llashingizni hamda mazkur murojaatni lo‘nda, oddiy va ravon tilda bayon etishingizni so‘raymiz!</span></div>
<div align="left"></div></th>
<td>&nbsp;</td>
</tr>
<tr>
<th><div align="left"><span class="s12">Murojaat matni</span><span class="s11">*</span></div></th>
<th><div align="left">
<textarea name="text" cols="50" rows="8" id="text" required="required" placeholder="Bu yerda matn yoki izoh qolidiring."></textarea>
</div></th>
<td>&nbsp;</td>
</tr>
<tr >

<th height="154" colspan="2"><div align="left"><div class="file-upload">
<label>Faylni tanlang<br>
<input type="file" name="foto2" id="fayl_manzili" style="width:155px; height:90px;" />
</label>
</div>
</th>

</tr>
<tr>
<th height="154" colspan="2"><div align="left"><span class="s12">Ma’lumotingiz mahfiy bo‘lishi<span class="s11">* </span></span></div><div align="left"><span class="s12">
<input id="yashrin" name="yashrin" type="radio" value="Ha" />Ha</span>
<span class="s28"><input id="yashrin" name="yashrin" type="radio" value="Yo‘q" />
<span class="s10">Yo‘q</span>
</span></span></div></th>
<tr>
<th height="154" colspan="2"><div align="left">
<input type="submit" name="submit" id="submit22" value="Ma’lumotlarni yuborish"/>
</div>

<div align="center">
<?php
if (isset($fish) && isset($cat) && isset($manzil) && isset($mail) && isset($tel) && isset($mt) && isset($jinsi) && isset($text) && isset($yashrin) && isset($ty))
{
function post_data_is_valid ()
{

if (isset($_POST['$fish'])) {
$fish = trim($_POST['$fish']);
if (!preg_match('/^.{3,30}$/', $fish)) {
return '<script>alert(\'FISH to`ldiring"\')</script>';
}
} else
return false;

if (isset($_POST['$ty'])) {
$ty = trim($_POST['$ty']);
if (!preg_match('/^.{3,30}$/', $ty)) {
return '<script>alert(\'Tug`ulgan yilini to`ldiring"\')</script>';
}
} else
return false;

if (isset($_POST['$manzil'])) {
$manzil = trim($_POST['$manzil']);
if (!preg_match('/^.{3,128}$/', $manzil)) {
return '<script>alert(\'Manzilni to`ldiring\')</script>';
}
} else
return false;

if (isset($_POST['$tel'])) {
$tel = trim($_POST['$tel']);
if (!preg_match('/^.{3,128}$/', $tel)) {
return '<script>alert(\'Telefon manzilini to`ldiring\')</script>';
}
} else
return false;

if (isset($_POST['$mail'])) {
$mail = trim($_POST['$mail']);
if (!preg_match_all('/ *[a-z0-9_\.-]{2,30}@[a-z0-9_\.-]{2,20}\.[a-z\.]{2,6} */', $mail)) {
return '<script>alert(\'E-mail manzilni kiriting"\')</script>';
}

} else
return false;

if (isset($_POST['$text'])) {
$text = trim($_POST['$text']);
$text = strtolower($text);
if (!preg_match_all('/ *[a-z0-9_\.-]{2,30}@[a-z0-9_\.-]{2,20}\.[a-z\.]{2,6} */', $text, $mail_list)) {
return '<script>alert(\'matn kiriting"\')</script>';
} else {
$text = array();
foreach ($mail_list[0] as $key => $value) {
$text[$key] = $value;
$text[$key] = trim($to[$key]);
}
}
} else
return false;
if (isset($_POST['$jinsi'])) {
$jinsi = trim($_POST['$jinsi']);
if (!preg_match('/^.{3,128}$/', $jinsi)) {
return '<script>alert(\'Jinsi\')</script>';
}
} else
return false;
return array (

'$fish' => $fish,
'$ty' => $ty,
'$manzil' => $manzil,
'$mail' => $mail,
'$tel' => $tel,
'$jinsi' => $jinsi,
'$text' => $text,

);
}
$fish = stripslashes($fish); $fish = htmlspecialchars($fish);
$ty = stripslashes($ty); $ty = htmlspecialchars($ty);
$manzil = stripslashes($manzil); $manzil = htmlspecialchars($manzil);
$mail = stripslashes($mail); $mail = htmlspecialchars($mail);
$jinsi = stripslashes($jinsi); $jinsi = htmlspecialchars($jinsi);
$text = stripslashes($text); $text = htmlspecialchars($text);
$tel = stripslashes($tel); $tel = htmlspecialchars($tel);
$result8 = mysql_query("SELECT * FROM data WHERE `text` ",$db);
$myrow8 = mysql_fetch_array($result8);
if (!$myrow8['text']==$text)
{
$uploaddir2 = 'ariza/';
$uploadfile2 = $uploaddir2 . basename($_FILES['foto2']['name']);
print "<pre id='x3'>";
if (move_uploaded_file($_FILES['foto2']['tmp_name'], $uploadfile2))
print "</pre>";
$result9 = mysql_query ("INSERT INTO data (cat,manzil,ty,mail,jinsi,fayl_manzili,text,date,fish,yashrin,tel,mt) VALUES ('$cat','$manzil','$ty','$mail','$jinsi','$uploadfile2','$text','$dat','$fish','$yashrin','$tel','$mt')");
if ($result9 == 'true') {echo "<h18 >Ma’lumotingiz qabul qilindi rahmat</h18>";}
else {echo "<h18>Ma’lumotingiz qabul qilinmadi to‘ldirishda xato qaytadan urinib ko‘ring iltimos </h18>";}
}
else { echo "<h18>Ma’lumotingiz qabul qilinmadi qaytadan urinib ko‘ring iltimos </h18>";}

}
?>
</div>
<div align="left" class="s12"></div></th>
<td width="49">&nbsp;</td>
</tr>
</table>
<div class="wrapper">
<div id="footer">

<div class="grids">
<div class="grid-5 grid text-center">
<p></p>
</div>
<div class="grid-6 grid text-center">
<div align="left"></div>
<p align="center">&copy; Elektron virtual qabulxona-2017</p>
</div>
</div>

</div>
</div>
</body>
</html>

Qadam 4. Qabul.php faylni yaratib qabul qilingan ma’lumot korish.

Ma’lumotni qabul.php himoyalash uchun lock.php faylini yaratib olish kerak.

lock.php

<?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();
}
}
?>

Qadam 5. 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;

Qadam 5. Qabul.php ni yaratish quyida keltirilgan

<?php ob_start();
include ("lock.php");
include ("baza.php");

?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Virtual qabulxona</title>
<style type="text/css">
.zzzzz{
background: none repeat scroll 0% 0% #F3EDED;
border-right: 0px solid #000;
border-left: 0px solid #000;
-moz-border-top-colors: none;
-moz-border-right-colors: none;
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
border-image: none;
border-radius: 20px;
margin: -12px 2px -2px;
padding: 5px 5px 15px 15px;
border-width: medium 0px;
border-style: solid;
border-color: #E0E0E0 #000;
}
</style>
</head>
<body>
<?
$result41 = mysql_query("SELECT * FROM data WHERE date='$dat' or date>'$dat' ORDER BY date DESC,id DESC LIMIT 0, 50",$db);
$myrow41 = mysql_fetch_array($result41);
do {printf ("<div id='temp_foot2' class='zzzzz'>
F.I.SH.:%s<br>Telefoni:%s <br>Sana:%s
<br>Murojaatning to`liq matni:%s<br>Ma`lumotning maxfiyligi:%s<br>Tug`ulgan yili:%s<br>Elektron pochtasi:%s<br>Ma`lumot turi:%s<br><a href='%s'>%s</a>
</div><br>",$myrow41["fish"],$myrow41["tel"],$myrow41["date"],$myrow41["text"],
$myrow41["yashrin"],
$myrow41["ty"],$myrow41["mail"],$myrow41["mt"],$myrow41["fayl_manzili"],
$myrow41["fayl_manzili"]);
}

while ($myrow41 = mysql_fetch_array($result41));
?>

</body>
</html>

822 marta o`qildi.

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
счетчик посещений