<?php
session_start();
//mastiin bahwa variabel session username dan password terdaftar di server
if (!empty($_SESSION["$mouse"]) and !empty($_SESSION["$keyboard"]))
{
echo "<h1>Input Berita</h1>
<form action='input_berita.php' method='post'>
<table align='center' border='0' >
<tr>
<td>Judul</td>
<td>: <input type='text' size='60' name='judul_berita'></td>
</tr>
<tr>
<td>katagori</td>
<td>: <select name='no_katagori'>
<option value=0 selected>--Pilih Katagori--";
include "koneksi_detik.php";
$tampil=mysql_query("select * from katagori order by nama_katagori");
while ($data=mysql_fetch_array($tampil))
{
echo "<option value=$data[no_katagori]>$data[nama_katagori]";
}
echo "</option></select></td>
</tr>
<tr>
<td>Headline Berita</td>
<td>: <textarea name='headline_berita' cols='60' rows='5'> </textarea></td>
</tr>
<tr>
<td>Isi Berita</td>
<td>: <textarea name='isi_berita' cols='60' rows='10'></textarea></td>
</tr>
<tr>
<td><input type='submit' value='Kirim'></td>\
</tr>
</form>";
}
else {
echo "untuk si berita,anda harus login<br>
<a href='form_login.php'>Login</a>"; }
?>
<form action="cek_login.php" method="post">
<table align="center" border="0">
<tr>
<th>Username</th>
<td>:</td>
<td><input type="text" name="dinul" /></td>
</tr>
<tr>
<th>Password</th>
<td>:</td>
<td><input type="password" name="furqon" /></td>
</tr>
<tr>
<td colspan="3" align="right"><input type="submit" value="Login" /></td>
</tr>
</table>
</form>
<?php
include "koneksi_detik.php";
$login=mysql_query("select * from reporter where user='$dinul' and pass='$furqon'");
$data=mysql_fetch_array($login);
//apabila benar
if(!empty($data["user"])==$dinul AND !empty($data["pass"])==$furqon) {
session_start();
//daftar variabel user dan pass
session_register("mouse");
session_register("keyboard");
//nilai user dan pass
$_SESSION["$mouse"]=$data["username"];
$_SESSION["$keyboard"]=$data["password"];
header("location:form_berita.php");
// echo "Nama Kamu adalah : $mouse <br> Password kamu adalah : $keyboard ";
}
else {
echo "Gagal! username&password tidak benar<br>
<a href='form_login.php'>Ke Halaman Utama</a>"; }
?>
<?php
include "koneksi_detik.php";
$login=mysql_query("select * from reporter where user='$dinul' and pass='$furqon'");
$data=mysql_fetch_array($login);
//apabila benar
if(!empty($data["user"])==$dinul AND !empty($data["pass"])==$furqon) {
session_start();
//nilai user dan pass
$_SESSION["mouse"]=$data["user"];
$_SESSION["keyboard"]=$data["pass"];
header("location:form_berita.php");
}
else {
echo "Gagal! username&password tidak benar<br>
<a href='form_login.php'>Ke Halaman Utama</a>"; }
?>
trus file untuk input berita jadi<?php
session_start();
//mastiin bahwa variabel session username dan password terdaftar di server
if (!empty($_SESSION["mouse"]) and !empty($_SESSION["keyboard"]))
{
echo "<h1>Input Berita</h1>
<form action='input_berita.php' method='post'>
<table align='center' border='0' >
<tr>
<td>Judul</td>
<td>: <input type='text' size='60' name='judul_berita'></td>
</tr>
<tr>
<td>katagori</td>
<td>: <select name='no_katagori'>
<option value=0 selected>--Pilih Katagori--";
include "koneksi_detik.php";
$tampil=mysql_query("select * from katagori order by nama_katagori");
while ($data=mysql_fetch_array($tampil))
{
echo "<option value=$data[no_katagori]>$data[nama_katagori]";
}
echo "</option></select></td>
</tr>
<tr>
<td>Headline Berita</td>
<td>: <textarea name='headline_berita' cols='60' rows='5'> </textarea></td>
</tr>
<tr>
<td>Isi Berita</td>
<td>: <textarea name='isi_berita' cols='60' rows='10'></textarea></td>
</tr>
<tr>
<td><input type='submit' value='Kirim'></td>\
</tr>
</form>";
}
else {
echo "untuk si berita,anda harus login<br>
<a href='form_login.php'>Login</a>"; }
?>