2
- Qoşuldu
- 6 Sen 2022
- Mesajlar
- 143
- Reaksiya hesabı
- 27
- Xallar
- 28
salam bu kodda komek lazimdi
burda mene gelen mesajlari nece alim?
$me=$db->query("select id from users where login='{$_COOKIE["login"]}'")->fetch_assoc();
$sql=$db->query("select * from mesaj where kim_id='{$me["id"]}' order by tarix");
foreach($sql as $user){
echo $user["kim_id"];
echo $user["kime_id"]."<br>";
echo $user["mesaj"]."<hr>";
echo $user["tarix"]."<hr>";
//print_r($user);
}
buda obwi mesaj.php
<?php
include("head.php");
switch($_GET["mess"]){
default:
$me=$db->query("select id from users where login='{$_COOKIE["login"]}'")->fetch_assoc();
$sql=$db->query("select * from mesaj where kim_id='{$me["id"]}' order by tarix");
foreach($sql as $user){
echo $user["kim_id"];
echo $user["kime_id"]."<br>";
echo $user["mesaj"]."<hr>";
echo $user["tarix"]."<hr>";
//print_r($user);
}
break;
case "show":
$id=$_GET["id"];
$me=$db->query("select id from users where login='{$_COOKIE["login"]}'")->fetch_assoc();
if(empty($id)){
echo "ERROR istifadeci tapilmadi";
exit("<a href=\"main.php\">Geri</a>");
}
if(isset($_POST["form"])){
$mesaj=$_POST["mesaj"];
$date=date("d/m/y H:i:s");
$tkn=$_FILES["fayl"]["name"];
if(move_uploaded_file($_FILES["fayl"]["tmp_name"],$tkn)){
echo "Fayl yuklendi";
}
if(strlen($mesaj)<2){
echo "sehv oldu en az 2 reqem yazin";
exit("<a href=\"mesaj.php?id={$id}\">Geri</a>");
}
$add=$db->query("INSERT INTO `mesaj`(`kim_id`, `kime_id`, `mesaj`, `tarix`,`fayl`) VALUES ('{$me["id"]}','{$id}','{$mesaj}','{$date}','{$tkn}')");
if($add){
echo "Mesaj getdi";
}
}
?>
<a href="mesaj.php?id=<?php echo $id;?>¥ile=<?php echo rand(2,999); ?>">Yenile</a><br>
<form method="POST" enctype="multipart/form-data" action=""><textarea name="mesaj" rows="4" cols="40" autocomplete="on" minlength="2" maxlength="250"></textarea><br><input type="file" name="fayl"><br><input type="submit" class="w3-btn-black" name="form" value="Yaz"></form>
<?php
$sql=$db->query("select * from mesaj where kim_id='{$me["id"]}' and kime_id='{$id}' or kime_id='{$me["id"]}' and kim_id='{$id}' order by tarix desc");
foreach($sql as $mes){
if($mes["kim_id"]==$me["id"]){
$n=explode(" ",$mes["tarix"]);
if($n[0]==date("d/m/y")){
$mes["tarix"]="Bu gun {$n[1]}";
}
if($n[0]<date("d/m/y")){
$mes["tarix"]="Dunen {$n[1]}";
}
//print_r($n);
echo "<div class=\"w3-border-light\" style=\"border:2px solid gray; width:360px; height:200px; margin:2px; background-color:lightgray;\"><span style=\"color:green\"><strong>{$mes["mesaj"]}</strong></span><br>{$mes["tarix"]}</div>";
}
else {
if(!empty($mes["fayl"])){
$mes["fayl"]=$mes["fayl"];
}
else {
$mes["fayl"]="";
}
echo "<div class=\"w3-border-light\" style=\"border:2px solid gray; width:360px; height:200px; margin:0px; background-color:lightsilver;\"><b></b></span> <strong> Gelen mesaj: {$mes["kim_id"]}</strong><hr><br> {$mes["mesaj"]} /<br>
<img src=\"{$mes["fayl"]}\" width=\"280\" height=\"175\" alt=\"imgs\"> <br> {$mes["tarix"]}</div>";
}
//print_r($mes);
if($_GET["clear"]=="chat"){
$mesaj_id=$_GET["mesaj_id"];
echo $mesaj_id;
$sil=$db->query("DELETE FROM mesaj where id='{$mesaj_id}'");
echo "Silindi";
}
}
echo "<a href=\"mesaj.php?id={$id}&clear=chat&mesaj_id={$mes["id"]}\">Sil</a>";
break;
}
?>
burda mene gelen mesajlari nece alim?
$me=$db->query("select id from users where login='{$_COOKIE["login"]}'")->fetch_assoc();
$sql=$db->query("select * from mesaj where kim_id='{$me["id"]}' order by tarix");
foreach($sql as $user){
echo $user["kim_id"];
echo $user["kime_id"]."<br>";
echo $user["mesaj"]."<hr>";
echo $user["tarix"]."<hr>";
//print_r($user);
}
buda obwi mesaj.php
<?php
include("head.php");
switch($_GET["mess"]){
default:
$me=$db->query("select id from users where login='{$_COOKIE["login"]}'")->fetch_assoc();
$sql=$db->query("select * from mesaj where kim_id='{$me["id"]}' order by tarix");
foreach($sql as $user){
echo $user["kim_id"];
echo $user["kime_id"]."<br>";
echo $user["mesaj"]."<hr>";
echo $user["tarix"]."<hr>";
//print_r($user);
}
break;
case "show":
$id=$_GET["id"];
$me=$db->query("select id from users where login='{$_COOKIE["login"]}'")->fetch_assoc();
if(empty($id)){
echo "ERROR istifadeci tapilmadi";
exit("<a href=\"main.php\">Geri</a>");
}
if(isset($_POST["form"])){
$mesaj=$_POST["mesaj"];
$date=date("d/m/y H:i:s");
$tkn=$_FILES["fayl"]["name"];
if(move_uploaded_file($_FILES["fayl"]["tmp_name"],$tkn)){
echo "Fayl yuklendi";
}
if(strlen($mesaj)<2){
echo "sehv oldu en az 2 reqem yazin";
exit("<a href=\"mesaj.php?id={$id}\">Geri</a>");
}
$add=$db->query("INSERT INTO `mesaj`(`kim_id`, `kime_id`, `mesaj`, `tarix`,`fayl`) VALUES ('{$me["id"]}','{$id}','{$mesaj}','{$date}','{$tkn}')");
if($add){
echo "Mesaj getdi";
}
}
?>
<a href="mesaj.php?id=<?php echo $id;?>¥ile=<?php echo rand(2,999); ?>">Yenile</a><br>
<form method="POST" enctype="multipart/form-data" action=""><textarea name="mesaj" rows="4" cols="40" autocomplete="on" minlength="2" maxlength="250"></textarea><br><input type="file" name="fayl"><br><input type="submit" class="w3-btn-black" name="form" value="Yaz"></form>
<?php
$sql=$db->query("select * from mesaj where kim_id='{$me["id"]}' and kime_id='{$id}' or kime_id='{$me["id"]}' and kim_id='{$id}' order by tarix desc");
foreach($sql as $mes){
if($mes["kim_id"]==$me["id"]){
$n=explode(" ",$mes["tarix"]);
if($n[0]==date("d/m/y")){
$mes["tarix"]="Bu gun {$n[1]}";
}
if($n[0]<date("d/m/y")){
$mes["tarix"]="Dunen {$n[1]}";
}
//print_r($n);
echo "<div class=\"w3-border-light\" style=\"border:2px solid gray; width:360px; height:200px; margin:2px; background-color:lightgray;\"><span style=\"color:green\"><strong>{$mes["mesaj"]}</strong></span><br>{$mes["tarix"]}</div>";
}
else {
if(!empty($mes["fayl"])){
$mes["fayl"]=$mes["fayl"];
}
else {
$mes["fayl"]="";
}
echo "<div class=\"w3-border-light\" style=\"border:2px solid gray; width:360px; height:200px; margin:0px; background-color:lightsilver;\"><b></b></span> <strong> Gelen mesaj: {$mes["kim_id"]}</strong><hr><br> {$mes["mesaj"]} /<br>
<img src=\"{$mes["fayl"]}\" width=\"280\" height=\"175\" alt=\"imgs\"> <br> {$mes["tarix"]}</div>";
}
//print_r($mes);
if($_GET["clear"]=="chat"){
$mesaj_id=$_GET["mesaj_id"];
echo $mesaj_id;
$sil=$db->query("DELETE FROM mesaj where id='{$mesaj_id}'");
echo "Silindi";
}
}
echo "<a href=\"mesaj.php?id={$id}&clear=chat&mesaj_id={$mes["id"]}\">Sil</a>";
break;
}
?>