[trick] Membuat Aplikasi Game Online Berbasis Flash dengan php mysql

Bismillah…

Ok Kali Ini Gw coba post salah satu proyek gw y, yaitu membuat aplikasi game online berbasis flash dengan php mysql

Langsung Saja >>

siapkan databasesnya >>

database

OK setelah itu kita siapkan kodingannya >>

1. index.php


<?php
mysql_connect("localhost","root","");
mysql_select_db("game");

if($_GET['menu']==''){

$kolom=3;
$sql=mysql_query("select * from table_game");
echo"<h3>Game Online >> </h3><hr><br><a href='?menu=tambah_game'><input type=submit value='Tambah'></a><p></p><table width=100%><tr>";
$i=0;
while($data=mysql_fetch_array($sql)){
if($i >= $kolom){
echo"</tr><tr>";
$i=0;
}
$i++;
echo"<td align=center><embad src='game/$data[nama_game]' height=300 width=400></embad><br><a href='?menu=edit_game&id=$data[id]'>Edit</a><br><a href=\"aksi.php?act=hapus_game&id=$data[id]\" onclick=\"return confirm('Yakin Hapus $data[nama_game] ??');\">Hapus</a></td>";
}
echo"</tr></table>";

}
if($_GET['menu']=='tambah_game'){
echo"
<h3>Tambah Game >> </h3><hr><br>
<form method=POST action='aksi.php?act=tambah_game' enctype='multipart/form-data'>
<table border=0 cellpadding=4 cellspacing=0>
<tr><td>Upload Game >> </td><td><input type=file name='nama_game'></td></tr>
<tr><td></td><td><input type=submit value='Tambah'></td></tr>
</table>
</form>
";
}

if($_GET['menu']=='edit_game'){
$data=mysql_fetch_array(mysql_query("select * from table_game where id='$_GET[id]'"));
echo"
<h3>Edit Game >> </h3><hr><br>
<form method=POST action='aksi.php?act=edit_game' enctype='multipart/form-data'>
<input type=hidden name='id' value='$data[id]'>
<table border=0 cellpadding=4 cellspacing=0>
<tr><td>Id</td><td><input type=text name='id' value='$data[id]' size=1 disabled></td></tr>
<tr><td>Game >> </td><td><embad src='game/$data[nama_game]' height=300 width=400></embad></td></tr>
<tr><td>Upload Game >> </td><td><input type=file name='nama_game'></td></tr>
<tr><td></td><td><input type=submit value='Update'></td></tr>
</table>
</form>
";
}
?>

 


2. aksi.php

<?php
mysql_connect("localhost","root","");
mysql_select_db("game");

$act=$_GET['act'];

if($act=='tambah_game'){
$lokasi_file=$_FILES['nama_game']['tmp_name'];
$nama_file=$_FILES['nama_game']['name'];
if(!empty($lokasi_file)){
move_uploaded_file($lokasi_file,"game/$nama_file");
mysql_query("insert into table_game(id,nama_game)values('$_POST[id]','$nama_file')");
header('location:index.php');
}else{
echo"<script>alert('data masih kosong');window.location=('javascript:history.go(-1)');</script>";
}
}

if($act=='edit_game'){
$lokasi_file=$_FILES['nama_game']['tmp_name'];
$nama_file=$_FILES['nama_game']['name'];
if(!empty($lokasi_file)){
move_uploaded_file($lokasi_file,"game/$nama_file");
mysql_query("update table_game set id='$_POST[id]',nama_game='$nama_file' where id='$_POST[id]'");
}else{
mysql_query("update table_game set id='$_POST[id]' where id='$_POST[id]'");
}
header('location:index.php');
}

if($act=='hapus_game'){
mysql_query("delete from table_game where id='$_GET[id]'");
header('location:index.php');
}
?>

dan hasil seperti ini >>

game

inti kodenya sie pada <embad></embad>

catatan :  <embad></embad>  itu bisa dipake untuk game/video, silahkan berexperimen sendiri Y…

download source code nya disini Y  >> http://www.4shared.com/zip/7yJBHcJ4/game.html

Selesai

Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: