Quyidagi misolni ko’ramiz
$db = mysql_connect("localhost", "gost");
mysql_select_db(“Xodim,",$db);
$result = mysql_query("SELECT * FROM xodim",$db);
if ($myrow = mysql_fetch_array($result))
{
echo "\n";
echo " Name | Holat | \n";
do
27
{
printf(" %s %s | %s | \n", $myrow["first"], $myrow["last"],
$myrow["address"]);
}
o’hile ($myrow = mysql_fetch_array($result));
echo " \n";
}
else
{
echo "Satr mavjud emas";
}
?>
if ($submit) {
// process form
o’hile (list($name, $value) = each($HTTP_POST_VARS)) {
echo "$name = $value
\n";
}
} else{
// display form
?>
} // end if ?>
if ($submit) {
// kiritish formasi
$db = mysql_connect("localhost", "gost"); mysql_select_db("mydb",$db);
$sql = "INSERT INTO xodim(nomi,last,address,ish) VALUES ('$nomi','$last','$address','$ish')";
$result = mysql_query($sql);
echo "Raxmat!Ma’lumotlar kiritildi.\n";
} else{
}
?>
Magazinga tashrif buyurganlarni ro’yxatdan o’tkazish
echo "
";
if (!$nomi ||!$familiya || !$sharifi || ! $manzil || !$e_mail || !$tel ||!$parol)
{
echo "Siz ma’lumotlarni to’liq kiritmadingiz.
"
."Iltimos orqaga qayting."; exit;
}
$nomi = addslashes($nomi); $familiya = addslashes($familiya); $sharifi = addslashes($sharifi) ; $manzili = addslashes($manzil); $e_mail = addslashes($e_mail); $tel = addslashes($tel);
$parol = addslashes($parol); echo "
";
$db = mysql_connect("localhost", "anvar"); if (!$db)
{
echo "Xatolik:Bazaga ulanib bo’lmadi."; exit;
} else
{
mysql_select_db("magazin") ;
$query ="insert into mijoz(nomi , familiya, sharifi, manzil, e_mail, tel, parol) values ('$nomi' , '$familiya','$sharifi','$manzili','$e_mail','$tel',password('$parol'))";
$result = mysql_query($query) ; if ($result)
echo "$nomi $familiya haqidagi ma’lumotalar bazaga kiritildi"; echo password('$parol');
echo "To’lovni amalga oshirish";
}
?>
|