Ada fitur sedang menulisnyaaa......
Ini Databasenya:
CREATE TABLE `tb_chat` (
`id` int(5) NOT NULL,
`tanggal` date NOT NULL,
`jam` time NOT NULL,
`tujuan` varchar(15) NOT NULL,
`pesan` text NOT NULL,
`status` int(1) NOT NULL DEFAULT '0',
`group` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `tb_chat`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `id` (`id`);
ALTER TABLE `tb_chat`
MODIFY `id` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=26;
COMMIT;
ini Class Utamanya:
package com.nurina.chatmessanger; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Random; import android.app.ListActivity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.util.Log; import android.view.View; import android.widget.EditText; import android.widget.ListAdapter; import android.widget.SimpleAdapter; import android.widget.Toast; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public class MessageActivity extends ListActivity { String myLati="-6.234234234"; String myLongi="130.345345"; String myPosisi="Jakarta"; String pesanbaru=""; JSONParser jParser = new JSONParser(); JSONArray myJSON = null; int adabaru=0; String newMessage=""; private static final String TAG_SUKSES = "sukses"; private static final String TAG_record = "record"; String ip="",waktu=""; //private ProgressDialog pDialog; int sukses; JSONParser jsonParser = new JSONParser(); ArrayList<Message> messages; AwesomeAdapter adapter; EditText text; static String sender; String asal,tujuan; int jd=0; String[]arPesan; String[]arNama; boolean[]arStatus; Handler mHandler; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); asal="Adiarray"; tujuan="Rini DA"; // Intent i = getIntent();// asal= i.getStringExtra("asal");// tujuan = i.getStringExtra("tujuan");// myLati= i.getStringExtra("myLati");// myLongi= i.getStringExtra("myLongi");// myPosisi= i.getStringExtra("myPosisi"); ip=jParser.getIP(); text = (EditText) this.findViewById(R.id.text); sender =tujuan;// Utility.sender[rand.nextInt( Utility.sender.length-1)]; this.setTitle(sender); messages = new ArrayList<Message>(); this.mHandler = new Handler(); m_Runnable.run(); new loadLama().execute(); } private final Runnable m_Runnable = new Runnable() { public void run() { new loadBaru().execute(); MessageActivity.this.mHandler.postDelayed(m_Runnable,3000); } }; public void sendMessage(View v){ newMessage = text.getText().toString().trim(); if(newMessage.length() > 0){ text.setText(""); addNewMessage(new Message(newMessage, true)); new send().execute(); //send() //new SendMessage().execute(); } } private class SendMessage extends AsyncTask<Void, String, String> { @Override protected String doInBackground(Void... params) { try { Thread.sleep(1000); }catch (InterruptedException e) { e.printStackTrace(); } this.publishProgress(String.format("%s started writing", sender)); try { Thread.sleep(1000); }catch (InterruptedException e) { e.printStackTrace(); } this.publishProgress(String.format("%s has entered text", sender)); try { Thread.sleep(3000);//simulate a network call }catch (InterruptedException e) { e.printStackTrace(); } return pesanbaru0;//Utility.messages[rand.nextInt(Utility.messages.length-1)]; } @Override public void onProgressUpdate(String... v) { if(messages.get(messages.size()-1).isStatusMessage){ messages.get(messages.size()-1).setMessage(v[0]); adapter.notifyDataSetChanged(); getListView().setSelection(messages.size()-1); } else{ addNewMessage(new Message(true,v[0])); } } @Override protected void onPostExecute(String text) { if(messages.get(messages.size()-1).isStatusMessage){ messages.remove(messages.size()-1); } addNewMessage(new Message(text, false)); // add the orignal message from server. } } void addNewMessage(Message m) { messages.add(m); adapter.notifyDataSetChanged(); getListView().setSelection(messages.size()-1); } class loadLama extends AsyncTask<String, String, String> { @Override protected void onPreExecute() { super.onPreExecute(); } protected String doInBackground(String... args) { List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("asal", asal)); params.add(new BasicNameValuePair("tujuan", tujuan)); Log.d("GO",ip+"chat/chat_show.php"); JSONObject json = jParser.makeHttpRequest(ip+"chat/chat_show.php", "GET", params); Log.d("show: ", json.toString()); try { sukses = json.getInt(TAG_SUKSES); if (sukses == 1) { myJSON = json.getJSONArray(TAG_record); jd=myJSON.length(); arNama=new String[jd]; arPesan=new String[jd]; arStatus=new boolean[jd]; for (int i = 0; i < jd; i++) { JSONObject c = myJSON.getJSONObject(i); String ltujuan= c.getString("tujuan"); String wkt= c.getString("waktu");//+" - "+c.getString("jurusan"); String psn= c.getString("pesan");;//"Tgl :"+c.getString("tanggal")+" - "+c.getString("jam")+"\nPesan :"+c.getString(TAG_pesan); arNama[i]=tujuan; arPesan[i]=psn; waktu=wkt; boolean st=false; if(ltujuan.equals(tujuan)){ st=true; } arStatus[i]=st; } } } catch (JSONException e) {e.printStackTrace();} return null; } protected void onPostExecute(String file_url) { runOnUiThread(new Runnable() { public void run() { if(sukses==1){ lihat(); } else{ init(); } } });} } void init(){ messages.add(new Message("Selamat Datang", true)); adapter = new AwesomeAdapter(this, messages); setListAdapter(adapter); //addNewMessage(new Message("Last Update: "+waktu, true)); } void lihat(){ for(int j=0;j<jd;j++){ messages.add(new Message(arPesan[j], arStatus[j])); } adapter = new AwesomeAdapter(this, messages); setListAdapter(adapter); addNewMessage(new Message("Last Update: "+waktu, true)); } int adabaru2=0; String pesanbaru0=""; class loadBaru extends AsyncTask<String, String, String> { @Override protected void onPreExecute() { super.onPreExecute(); } protected String doInBackground(String... args) { List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("asal", asal)); params.add(new BasicNameValuePair("tujuan", tujuan)); //Log.d("Loadbaru",ip+"chat/chat_showbaru.php"); JSONObject json = jParser.makeHttpRequest(ip+"chat/chat_showbaru.php", "GET", params); try { adabaru2= json.getInt("sukses"); pesanbaru=json.getString("pesanbaru"); if(pesanbaru.length()>1 && adabaru2>0) { pesanbaru0 = pesanbaru; } } catch (JSONException e) {e.printStackTrace();} return null; } protected void onPostExecute(String file_url) { runOnUiThread(new Runnable() { public void run() { if(adabaru2>0 && pesanbaru.length()>1) { adabaru2=0; bacabaru(); } } });} void bacabaru(){ new SendMessage().execute(); // messages.add(new Message(pesanbaru, false));// adapter = new AwesomeAdapter(MessageActivity.this, messages);// setListAdapter(adapter); //addNewMessage(new Message("Update data terahir: "+waktu, true)); // return Utility.messages[rand.nextInt(Utility.messages.length-1)]; } } class send extends AsyncTask<String, String, String> { @Override protected void onPreExecute() { super.onPreExecute(); // pDialog = new ProgressDialog(MessageActivity.this);// pDialog.setMessage("Menyimpan data ...");// pDialog.setIndeterminate(false);// pDialog.setCancelable(true);// pDialog.show(); } protected String doInBackground(String... args) { if(newMessage.equalsIgnoreCase("mymap") ||newMessage.equalsIgnoreCase("lokasiku")){ //newMessage="https://maps.google.com/q="+myLati+","+myLongi; newMessage="Posisi Saya :"+myPosisi +" Koord:"+myLati+","+myLongi; } List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("tujuan", tujuan)); params.add(new BasicNameValuePair("pesan", newMessage)); params.add(new BasicNameValuePair("group", asal+"-"+tujuan)); String url=ip+"chat/chat_add.php"; Log.v("add",url); JSONObject json = jsonParser.makeHttpRequest(url,"POST", params); Log.d("add", json.toString()); try { int sukses = json.getInt(TAG_SUKSES); if (sukses == 1) { Intent i = getIntent(); setResult(100, i); //finish(); } else { // gagal update data } } catch (JSONException e) { e.printStackTrace(); } return null; } protected void onPostExecute(String file_url) { // pDialog.dismiss(); } } }
+++++++++++++++++++++
ini chat_show.php
<?php
require_once"../konmysqli.php";
$respon = array();
$sql="SELECT * FROM `$tbchat` order by `id` asc";
if(isset($_GET["asal"])){
$asal=$_GET["asal"];
$tujuan=$_GET["tujuan"];
$group1="$asal-$tujuan";
$group2="$tujuan-$asal";
process($conn,"update `$tbchat` set status='1' where (`group` like '$group1' or `group` like '$group2') ");
$sql="SELECT * FROM `$tbchat` where status='1' and (`group` like '$group1' or `group` like '$group2') order by `id` asc";
}
$jum=getJum($conn,$sql);
if ($jum> 0) {
$respon["record"] = array();
$arr=getData($conn,$sql);
foreach($arr as $d) {
$record = array();
$record["id"] = $d["id"];
$record["waktu"] = WKTM($d["tanggal"])." Jam ".$d["jam"]." wib";
$record["tujuan"] = $d["tujuan"];
$record["pesan"] = $d["pesan"];
$tujuan = $d["tujuan"];
array_push($respon["record"], $record);
}
// sukses
$respon["sukses"] = 1;
$respon["pesan"] = "$jum record";
echo json_encode($respon);
} else {
// jika data kosong
$respon["record"]="";
$respon["sukses"] = 0;
$respon["pesan"] = "0 record";
echo json_encode($respon);
}
?>
<?php
function process($conn,$sql){
$s=false;
$conn->autocommit(FALSE);
try {
$rs = $conn->query($sql);
if($rs){
$conn->commit();
$last_inserted_id = $conn->insert_id;
$affected_rows = $conn->affected_rows;
$s=true;
}
}
catch (Exception $e) {
echo 'fail: ' . $e->getMessage();
$conn->rollback();
}
$conn->autocommit(TRUE);
return $s;
}
function getJum($conn,$sql){
$rs=$conn->query($sql);
$jum= $rs->num_rows;
$rs->free();
return $jum;
}
function getData($conn,$sql){
$rs=$conn->query($sql);
$rs->data_seek(0);
$arr = $rs->fetch_all(MYSQLI_ASSOC);
$rs->free();
return $arr;
}
?>
ini chat_showbaru.php
<?php require_once"../konmysqli.php"; $respon = array(); $sql="SELECT * FROM `$tbchat` where status='0' order by `id` asc"; if(isset($_GET["asal"])){ $asal=$_GET["asal"]; $tujuan=$_GET["tujuan"]; $group1="$asal-$tujuan"; $group2="$tujuan-$asal"; $sql="SELECT * FROM `$tbchat` where status='0' and `tujuan`='$asal' and (`group` like '$group1' or `group` like '$group2') order by `id` asc"; } $jum=getJum($conn,$sql); if ($jum> 0) { //$respon["record"] = array(); $d=getFieldM($conn,$sql); $id= $d["id"]; $pesan = $d["pesan"]; processM($conn,"update `$tbchat` set status='1' where id='$id'"); $respon["pesanbaru"] = $pesan; $respon["sukses"] = 1; $respon["pesan"] = "$jum record"; echo json_encode($respon); } else { // jika data kosong $respon["sukses"] = 0; $respon["pesanbaru"] = ""; $respon["pesan"] = "0 record"; echo json_encode($respon); } ?> <?php function getJum($conn,$sql){ $rs=$conn->query($sql); $jum= $rs->num_rows; $rs->free(); return $jum; } function getData($conn,$sql){ $rs=$conn->query($sql); $rs->data_seek(0); $arr = $rs->fetch_all(MYSQLI_ASSOC); $rs->free(); return $arr; } ?>
ini chat_add.php
<?php require_once"../konmysqli.php"; $respon = array(); if (isset($_POST['tujuan'])) { $tujuan = $_POST['tujuan']; $pesan = $_POST['pesan']; $group = $_POST['group']; $status = 0; $tanggal = date("Y-m-d"); $jam = date("H:i:s"); $sql="INSERT INTO `$tbchat` (`id`, `tanggal`, `jam`, `tujuan`,`pesan`, `group`, `status`) VALUES ('', '$tanggal', '$jam', '$tujuan', '$pesan', '$group', '$status')"; $simpan=process($conn,$sql); if($simpan){ $respon["sukses"] = 1; $respon["pesan"] = "1 sukses tambah."; echo json_encode($respon); } else { $respon["sukses"] = 0; $respon["pesan"] = "0 gagal tambah"; echo json_encode($respon); } } else { $respon["sukses"] = 0; $respon["pesan"] = "? lengkapi data"; echo json_encode($respon); } ?> <?php function process($conn,$sql){ $s=false; $conn->autocommit(FALSE); try { $rs = $conn->query($sql); if($rs){ $conn->commit(); $last_inserted_id = $conn->insert_id; $affected_rows = $conn->affected_rows; $s=true; } } catch (Exception $e) { echo 'fail: ' . $e->getMessage(); $conn->rollback(); } $conn->autocommit(TRUE); return $s; } ?>
ini index.php
<?php
if (version_compare(phpversion(), "5.3.0", ">=") == 1)
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
else
error_reporting(E_ALL & ~E_NOTICE);
?>
<?php
session_start();
//error_reporting(0);
require_once"konmysqli.php";
$mnu=$_GET["mnu"];
date_default_timezone_set("Asia/Jakarta");
$_SESSION["cid"]="Rini DA";
$tujuan="Adiarray";
require_once"chat/chat.php";
?>
<?php function RP($rupiah){return number_format($rupiah,"2",",",".");}?>
<?php
function WKT($sekarang){
$tanggal = substr($sekarang,8,2)+0;
$bulan = substr($sekarang,5,2);
$tahun = substr($sekarang,0,4);
$judul_bln=array(1=> "Januari", "Februari", "Maret", "April", "Mei","Juni", "Juli", "Agustus", "September","Oktober", "November", "Desember");
$wk=$tanggal." ".$judul_bln[(int)$bulan]." ".$tahun;
return $wk;
}
?>
<?php
function WKTP($sekarang){
$tanggal = substr($sekarang,8,2)+0;
$bulan = substr($sekarang,5,2);
$tahun = substr($sekarang,2,2);
$judul_bln=array(1=> "Jan", "Feb", "Mar", "Apr", "Mei","Jun", "Jul", "Agu", "Sep","Okt", "Nov", "Des");
$wk=$tanggal." ".$judul_bln[(int)$bulan]."'".$tahun;
return $wk;
}
?>
<?php
function BAL($tanggal){
$arr=explode(" ",$tanggal);
if($arr[1]=="Januari"||$arr[1]=="January"){$bul="01";}
else if($arr[1]=="Februari"||$arr[1]=="February"){$bul="02";}
else if($arr[1]=="Maret"||$arr[1]=="March"){$bul="03";}
else if($arr[1]=="April"){$bul="04";}
else if($arr[1]=="Mei"||$arr[1]=="May"){$bul="05";}
else if($arr[1]=="Juni"||$arr[1]=="June"){$bul="06";}
else if($arr[1]=="Juli"||$arr[1]=="July"){$bul="07";}
else if($arr[1]=="Agustus"||$arr[1]=="August"){$bul="08";}
else if($arr[1]=="September"){$bul="09";}
else if($arr[1]=="Oktober"||$arr[1]=="October"){$bul="10";}
else if($arr[1]=="November"){$bul="11";}
else if($arr[1]=="Nopember"){$bul="11";}
else if($arr[1]=="Desember"||$arr[1]=="December"){$bul="12";}
return "$arr[2]-$bul-$arr[0]";
}
?>
<?php
function BALP($tanggal){
$arr=split(" ",$tanggal);
if($arr[1]=="Jan"){$bul="01";}
else if($arr[1]=="Feb"){$bul="02";}
else if($arr[1]=="Mar"){$bul="03";}
else if($arr[1]=="Apr"){$bul="04";}
else if($arr[1]=="Mei"){$bul="05";}
else if($arr[1]=="Jun"){$bul="06";}
else if($arr[1]=="Jul"){$bul="07";}
else if($arr[1]=="Agu"){$bul="08";}
else if($arr[1]=="Sep"){$bul="09";}
else if($arr[1]=="Okt"){$bul="10";}
else if($arr[1]=="Nov"){$bul="11";}
else if($arr[1]=="Nop"){$bul="11";}
else if($arr[1]=="Des"){$bul="12";}
return "$arr[2]-$bul-$arr[0]";
}
?>
<?php
function process($conn,$sql){
$s=false;
$conn->autocommit(FALSE);
try {
$rs = $conn->query($sql);
if($rs){
$conn->commit();
$last_inserted_id = $conn->insert_id;
$affected_rows = $conn->affected_rows;
$s=true;
}
}
catch (Exception $e) {
echo 'fail: ' . $e->getMessage();
$conn->rollback();
}
$conn->autocommit(TRUE);
return $s;
}
function getJum($conn,$sql){
$rs=$conn->query($sql);
$jum= $rs->num_rows;
$rs->free();
return $jum;
}
function getField($conn,$sql){
$rs=$conn->query($sql);
$rs->data_seek(0);
$d= $rs->fetch_assoc();
$rs->free();
return $d;
}
function getData($conn,$sql){
$rs=$conn->query($sql);
$rs->data_seek(0);
$arr = $rs->fetch_all(MYSQLI_ASSOC);
//foreach($arr as $row) {
// echo $row['nama_kelas'] . '*<br>';
//}
$rs->free();
return $arr;
}
function getMhs($conn,$kode){
$field="nama_mahasiswa";
$sql="SELECT `$field` FROM `tb_mahasiswa` where `nim`='$kode'";
$rs=$conn->query($sql);
$rs->data_seek(0);
$row = $rs->fetch_assoc();
$rs->free();
return $kode." - ".$row[$field];
}
?>
ini chat/chat.php
<?php
$jam=date("H:i:s");
$tanggal=WKT(date("Y-m-d"));
$pro="simpan";
$pesan="";
?>
<link type="text/css" href="<?php echo "$PATH/base/";?>ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="<?php echo "$PATH/";?>jquery-1.3.2.js"></script>
<script type="text/javascript" src="<?php echo "$PATH/";?>ui/ui.core.js"></script>
<script type="text/javascript" src="<?php echo "$PATH/";?>ui/ui.datepicker.js"></script>
<script type="text/javascript" src="<?php echo "$PATH/";?>ui/i18n/ui.datepicker-id.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#tanggal").datepicker({
dateFormat : "dd MM yy",
changeMonth : true,
changeYear : true
});
});
</script>
<script type="text/javascript">
function PRINT(v){
win=window.open('chat/chat_print.php?v='+v,'win','width=1000, height=400, menubar=0, scrollbars=1, resizable=0, location=0, toolbar=0, status=0'); }
</script>
<script language="JavaScript">
function buka(url) {window.open(url, 'window_baru', 'width=800,height=600,left=320,top=100,resizable=1,scrollbars=1');}
</script>
<!-- aC 1--->
<link rel="stylesheet" href="jsacordeon/jquery-ui.css">
<link rel="stylesheet" href="resources/demos/style.css">
<script src="jsacordeon/jquery-1.12.4.js"></script>
<script src="jsacordeon/jquery-ui.js"></script>
<script>
$( function() {
$( "#accordion" ).accordion({
collapsible: true
});
} );
</script>
</head>
<body>
<div id="accordion">
<?php
if($_GET["pro"]=="ubah"){
$id=$_GET["kode"];
$sql="select * from `$tbchat` where `id`='$id'";
$d=getField($conn,$sql);
$id=$d["id"];
$tanggal=WKT($d["tanggal"]);
$jam=$d["jam"];
$tujuan=$d["tujuan"];
$pesan=$d["pesan"];
$status=$d["status"];
$pro="ubah";
}
?>
<h3>Form Chat Input</h3>
<div>
<!-- aC 1--->
<form action="" method="post" enctype="multipart/form-data">
<table class="table table-striped table-bordered table-hover"width="40%" >
<tr>
<td width="66">Tujuan<td width="9">:
<td colspan="2">
<input name="tujuan" type="text" id="tujuan" value="<?php echo $tujuan;?>" size="20" />
</tr>
<tr>
<td height="24"><label for="pesan">Pesan</label>
<td>:<td><textarea name="pesan" cols="45" rows="3" id="pesan"><?php echo $pesan;?></textarea>
</td>
</tr>
<tr>
<td>
<td>
<td colspan="2"><input name="Simpan" type="submit" id="Simpan" value="Simpan" />
<input name="pro" type="hidden" id="pro" value="<?php echo $pro;?>" />
<input name="id" type="hidden" id="id" value="<?php echo $id;?>" />
<input name="id0" type="hidden" id="id0" value="<?php echo $id0;?>" />
<a href="?mnu=chat"><input name="Batal" type="button" id="Batal" value="Batal" /></a>
</td></tr>
</table>
</form>
<br />
<!--aC2--->
</div>
<?php
$sqlc="select distinct(tujuan) from `$tbchat` order by `tujuan` asc";
$arrc=getData($conn,$sqlc);
foreach($arrc as $dc) {
$tujuan=$dc["tujuan"];
?>
<h3>Lihat Data <?php echo $tujuan;?></h3>
<div>
<!--aC2--->
Data Chat <?php echo $tujuan;?>:
| <img src='ic_print.png' title='PRINT' OnClick="PRINT('<?php echo $tujuan;?>')"> |
<br>
<table class="table table-striped table-bordered table-hover"width="100%" border="0">
<tr bgcolor="#cccccc">
<th width="4%">No</td>
<th width="15%">Waktu</td>
<th width="70%">Pesan</td>
<th width="5%">Hapus</td>
</tr>
<?php
$group1=$_SESSION["cid"]."-".$tujuan;
$group2=$tujuan."-".$_SESSION["cid"];
$sql="select * from `$tbchat` where `group` like '$group1' or `group` like '$group2' order by `id` desc";
$jum=getJum($conn,$sql);
$no=1;
if($jum > 0){
$arr=getData($conn,$sql);
foreach($arr as $d) {
$id=$d["id"];
$tanggal=WKTP($d["tanggal"]);
$jam=$d["jam"];
$tujuan=$d["tujuan"];
$pesan=$d["pesan"];
$status=$d["status"];
$ask="$tujuan";
if($tujuan==$_SESSION["cid"]){
$ask="Anda";
}
$color="#dddddd";
if($no %2==0){$color="#eeeeee";}
echo"<tr bgcolor='$color'>
<td>$no</td>
<td>$tanggal - $jam</td>
<td><b>$ask :</b><i>$pesan</i></td>
<td><div align='center'>
<a href='?mnu=chat&pro=hapus&kode=$id'><img src='ic_chat.png' title='hapus'
onClick='return confirm(\"Apakah Anda benar-benar akan menghapus pesan pada data chat ?..\")'></a></div></td>
</tr>";
$no++;
}//while
}//if
else{echo"<tr><td colspan='6'><blink>Maaf, Data chat belum tersedia...</blink></td></tr>";}
?>
</table>
</div>
<?php
}
?>
</div>
<?php
if(isset($_POST["Simpan"])){
$tanggal=date("Y-m-d");
$jam=date("H:i:s");
$tujuan=strip_tags($_POST["tujuan"]);
$pesan=strip_tags($_POST["pesan"]);
$group1=$_SESSION["cid"]."-".$tujuan;
$sql=" INSERT INTO `$tbchat` (
`id` ,
`tanggal` ,
`jam` ,
`tujuan` ,
`pesan` ,`status` ,`group`
) VALUES (
'',
'$tanggal',
'$jam',
'$tujuan',
'$pesan','0','$group1'
)";
$simpan=process($conn,$sql);
if($simpan) {echo "<script>alert('Data Pesan berhasil disimpan !');document.location.href='?mnu=chat';</script>";}
else{echo"<script>alert('Data Pesan gagal disimpan...');document.location.href='?mnu=chat';</script>";}
}
?>
<?php
if($_GET["pro"]=="hapus"){
$id=$_GET["kode"];
$sql="delete from `$tbchat` where `id`='$id'";
$hapus=process($conn,$sql);
if($hapus) {echo "<script>alert('Data $id berhasil dihapus !');document.location.href='?mnu=chat';</script>";}
else{echo"<script>alert('Data $id gagal dihapus...');document.location.href='?mnu=chat';</script>";}
}
?>
ini penampakan akhir servernya:
Tidak ada komentar:
Posting Komentar