0% found this document useful (0 votes)
28 views1 page

Nama Database: Babook Nama File: Komen - Simpan - PHP

The document describes the database and files for a social media website called babook. It includes the tables status and comments in the Nama Database babook. It then lists the PHP files and their purposes, including status_form.php for creating a status, status.php for viewing statuses, status_kirim.php for posting a status, suka.php for liking a status, komen_simpan.php for posting a comment, and style.css for styling. The files work together to allow users to post statuses and comments, and like other users' statuses.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views1 page

Nama Database: Babook Nama File: Komen - Simpan - PHP

The document describes the database and files for a social media website called babook. It includes the tables status and comments in the Nama Database babook. It then lists the PHP files and their purposes, including status_form.php for creating a status, status.php for viewing statuses, status_kirim.php for posting a status, suka.php for liking a status, komen_simpan.php for posting a comment, and style.css for styling. The files work together to allow users to post statuses and comments, and like other users' statuses.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Nama Database : babook

Nama Table : status Nama Table : komen


















Nama File : status_form.php
<link rel="stylesheet" type="text/css" href="style.css" />
<form method="POST" action="status_kirim.php">
Nama :<br>
<input type="text" name="nama" size="30"><br>
Apa Yang Anda Pikirkan ?<br>
<textarea name="isi_status" cols="30"
rows="3"></textarea><br>
<input type="submit" value=" Kirim ">
</form>

Nama File : status.php
<link rel="stylesheet" type="text/css" href="style.css" />
<?php
include "status_form.php";
echo "<hr size=1>";
$koneksi=mysql_connect("localhost","root","yawina");
$db=mysql_select_db("babook");
$sql="select * from status order by id_status desc";
$result=mysql_query($sql);
while($data=mysql_fetch_array($result))
{
?>
<font color="#000099" size="4">
<?php echo $data['nama']; ?></font> <br>
<font color="#000000">
<?php echo $data['isi_status']; ?></font> <br>
<font color="#000000">
<?php echo $data['tanggal']; ?></font> <br>
<a href="suka.php?id=<?php echo $data['id_status'] ?>"
title="Suka">(<?php echo $data['suka'] ?>)Suka</a> | <a
href="status.php?id_status=<?php echo
$data[id_status]?>">(<?php echo $data['komen']
?>)Komentar</a><p>
<?php
$id=$_GET['id_status'];
if($id=="$data[id_status]")
{
$sql_k="select * from komen where
id_status='$data[id_status]'";
$result_k=mysql_query($sql_k);
while($data_k=mysql_fetch_array($result_k))
{
?>
<font color="red"><b><?php echo
$data_k['nama'] ?></b></font><br>
<?php echo $data_k['isi_komen'] ?>
<br>
<?php } ?><P>
<?php
?>
<form method="POST" action="komen_simpan.php">
<input type="hidden" name="id_status" value="<?php
echo $data[id_status] ?>">
Nama :<br>
<input type="text" name="nama" size="30"><br>
Tuliskan Komentar :<br>
<textarea name="isi_komen" cols="30"
rows="3"></textarea><br>
<input type="submit" value=" Kirim ">
</form>
<?php
}
} ?>

Nama File : status_kirim.php
<?php
$koneksi=mysql_connect("localhost","root","yawina");
$db=mysql_select_db("babook");
$nama=$_POST['nama'];
$isi_status=$_POST['isi_status'];
$tanggal=date("Y-m-d h:i:s");
$sqlx="insert into status (nama,isi_status,tanggal) values
('$nama','$isi_status','$tanggal')";
$kirim=mysql_query($sqlx);
?>
<meta http-equiv="refresh" content="1;url=status.php">

Nama File : suka.php
<?php
$koneksi=mysql_connect("localhost","root","yawina");
$db=mysql_select_db("babook");
$id=$_GET['id'];
$sql="select * from status where id_status='$id'";
$result=mysql_query($sql);
$data=mysql_fetch_array($result);
$suka=$data['suka'];
$suka1=$suka+1;
$sqlx="update status set suka='$suka1' where
id_status='$id'";
$rubah=mysql_query($sqlx);
?>
<meta http-equiv="refresh" content="1;url=status.php">

Nama File : komen_simpan.php
<?php
$koneksi=mysql_connect("localhost","root","yawina");
$db=mysql_select_db("babook");
$id_status=$_POST['id_status'];
$nama=$_POST['nama'];
$isi_komen=$_POST['isi_komen'];
$tanggal=date("Y-m-d h:i:s");
$sqlx="insert into komen (nama,isi_komen,tgl,id_status)
values ('$nama','$isi_komen','$tanggal','$id_status')";
$kirim=mysql_query($sqlx);
$sql="select * from status where id_status='$id_status'";
$result=mysql_query($sql);
$data=mysql_fetch_array($result);
$komen=$data['komen'];
$komen1=$komen+1;
$sqlx="update status set komen='$komen1' where
id_status='$id_status'";
$rubah=mysql_query($sqlx);
?>
<meta http-equiv="refresh" content="1;url=status.php">

Nama File : style.css
body {
background: #EEEEEE url(header.gif) repeat-x top
left;
color: #000000;
margin: 0;
padding: 10;
font: 11px "Arial", Helvetica, Sans-Serif;
}
td {
color: #000000;
margin: 0;
font: 11px "Arial", Helvetica, Sans-Serif;
}
th {
background: #A0A0A0;
color: #ffffff;
margin: 0;
font: 11px "Arial", Helvetica, Sans-Serif;
}
a {
color: #3C6491;
background-color: inherit;
text-decoration: none;
}

a:hover {
color: #BF3E17;
background-color: inherit;
font-weight: bold;
}

You might also like