gagal

Rheyank Iwan Nytt · Feb 10, 2013
mas numpang tanya....
og inputnya gagal trs ea .. pa nya ea yang salah ????

input.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>English Lesson Of Grammar</title>
<link href="css/rheyank_style.css" rel="stylesheet" type="text/css" />

<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" />

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/ddsmoothmenu.js">

/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

</script>

<script type="text/javascript">

ddsmoothmenu.init({
	mainmenuid: "menu", //menu DIV id
	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
	classname: 'ddsmoothmenu', //class added to menu's outer DIV
	//customtheme: ["#1c5a80", "#18374a"],
	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

</script>
<style type="text/css">
<!--
.style1 {color: #75a62c}
.style2 {
	color: #333;
	font-weight: bold;
}
-->
</style>
</head>
<body>

<div id="body">
	<div id="header"></div> 
	<!-- end of header -->
    
    <div id="menu" class="ddsmoothmenu"></div>
	<!-- end of menu -->

    <div id="main">    	
	    <h2>Masukan Data Diri Anda !!! </h2>
        <div class="col_2 float_l">
            <br class="cleaner h20" />
            <div id="data_form">
			<form action="simpan2.php" method="post" NAME="input">

                        <label for="id">ID</label> <input type="text" id="id" name="id" class="input" />
                        <div class="cleaner h10"></div>                     
                        <label for="nama">Nama</label> <input type="text" id="nama" name="nama" class="input" />
                        <div class="cleaner h10"></div>
                        <label for="kelas">Kelas</label> <input type="text" id="kelas" name="kelas" class="input" />
                        <div class="cleaner h10"></div>
                        <label for="alamat">Alamat</label> <input type="text" id="alamat" name="alamat" class="input" />
                        <div class="cleaner h10"></div>
                        <label for="username">Username</label> <input type="text" id="username" name="username" class="input" />
                        <div class="cleaner h10"></div>
						<label for="password">Password</label> <input type="password" id="password" name="password" class="input" />
                        <div class="cleaner h10"></div>
                               
                        <input type="submit" value="Daftar" id="submit" name="submit" class="submit_btn float_l" />
						<input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" />
                        
            	</form>
            </div> 
        </div>
		        <div class="col_2 float_l">
        
        	<h4 class="style1">Petunjuk ..</h4>
			<p align="justify">Sebelum anda mengakses Aplikasi ini, Anda diharuskan untuk mengisi data diri anda pada form yang ada disebelah kiri tersebut. Setelah itu tekan <span class="style2">&quot;Daftar&quot;</span>. Maka anda akan dapat mengakses aplikasi ini dengan bebas kapanpun. </p>
			<p align="justify">Jika anda sudah terdaftar, silakan <span class="style2">&quot;Login&quot;</span> untuk mengakses aplikasi ini.</p>
			<p align="justify">terdapat materi yang dapat dibaca, dan didownload. Terdapat juga soal latihan untuk mengukur kemampuan anda mengenai materi grammar. </p>
			<p align="justify">Selamat mencoba !!! </p>
                     <div class="cleaner h10"></div>
					 
	<form method="post" action="login.php">
    <table width="329" height="198" border="0" align="center" background="backgroud.png">
    <tr>
      <th width="24" rowspan="3" scope="row">&nbsp;</th>
      <th height="35%" colspan="3" scope="row">&nbsp;</th>
      <td width="22" rowspan="3">&nbsp;</td>
    </tr>
    <tr>
      <th width="85" height="45" scope="row"> <div align="left">Username</div></th>
      <td width="15">:</td>
      <td width="161">
        <input type="text" name="username" />      </td>
      </tr>
    <tr>
      <th height="47" scope="row"><div align="left">Password</div></th>
      <td>:</td>
      <td><input type="password" name="password" /></td>
      </tr>
    <tr>
      <th height="45" colspan="5" scope="row">
         <input type="submit" name="Submit" value="Login" />  
        <input name="reset" type="reset" value="Reset" /></th>
      </tr>
    <tr>
      <th height="27" colspan="5" scope="row">&nbsp;</th>
    </tr>
  </table>
  </form>
            <a href="#" class="more">Lanjut</a>
   
        </div>
        
		        <br class="cleaner" />
    </div> <!-- end of main -->
    
    <div id="footer">
    	            <div class="footer_social_button">
                <a href="#"><img src="images/facebook-32x32.png" title="facebook" alt="facebook" /></a>
                <a href="#"><img src="images/flickr-32x32.png" title="flickr" alt="flickr" /></a>
                <a href="#"><img src="images/twitter-32x32.png" title="twitter" alt="twitter" /></a>
                <a href="#"><img src="images/youtube-32x32.png" title="youtube" alt="youtube" /></a>
                <a href="#"><img src="images/rss-32x32.png" title="rss" alt="rss" /></a>
			</div>       		
  </div>
        <div class="cleaner"></div>
</div> <!-- end of footer -->

<div id="cr_bar_wrapper">
	<div id="cr_bar">
    	Copyright © 2013 Designed by <a href="http://www.facebook.com/rheyank.iwan">Rheyank Iwan</a>    </div>
</div>

</body>
</html>

simpannya
<?
//Cek Tombol 
if ($_POST){
//Kirimkan Variabel
$id = $_POST['id'];
$nama = $_POST['nama'];
$kelas = $_POST['kelas'];
$alamat = $_POST['alamat'];
$username = $_POST['username'];
$password = $_POST['password'];

//validasi data jika pesan kosong
if (empty($_POST['id'])|| empty($_POST['nama'])|| empty($_POST['kelas'])|| empty($_POST['alamat'])|| empty($_POST['username'])|| empty($_POST['password'])) 
{
?>
<script language="JavaScript">
alert('Data Harap Dilengkapi');
document.location='inputsiswa.php';
</script>
<?
}
//Jika Validasi Terpenuhi
else
{
//Memanggil File Koneksi Database
mysql_connect("localhost", "root", "12345");
mysql_select_db("english");

//Masukan data ke Table user
     $query ="INSERT INTO user VALUES('$id','$nama','$kelas','$alamat','$username','$password')";
     $hasil = mysql_query($query);  
     if($hasil){  
//Jika Sukses
//echo "Data telah diinput";
?>
<script language="JavaScript">
alert('Data Berhasil diinput');
document.location='index.php';
</script>
<?

}
else
{
//Jika Gagal
//echo "Data gagal diinput, Silakan Ulangi";
}
}
}
?>
<script language="JavaScript">
alert('Data Gagal diinput,, Silakan ulangi');
document.location='inputsiswa.php';
</script>

ne struktur tabelnya mas...
id* int(11)
nama varchar(20)
kelas varchar(10)
username varchar(20)
password varchar(10)

tlong ea mas....:)
Silahkan login untuk menjawab!
0
Loading...
Rheyank Iwan Nytt · Feb 10, 2013 · 0 Suka · 0 Tidak Suka
ne struktur tabelnya mas... yang diatas tdi salah tulis
id* int(11)
nama varchar(20)
kelas varchar(10)
alamat varachar(50)
username varchar(20)
password varchar(10)
0
Loading...
Robert James M · Feb 10, 2013 · 0 Suka · 0 Tidak Suka
ah bisa ko mas, cuma ku sesuaikan dengan database buatan ku sesuai data mas semua jalan.
0
Loading...
Rheyank Iwan Nytt · Feb 11, 2013 · 0 Suka · 0 Tidak Suka
. ea t ? p dtabase q yg slah ?
cz gga"l trz punya q ..
0
Loading...
Robert James M · Feb 11, 2013 · 0 Suka · 0 Tidak Suka
ga ada yang error, cek koneksi sama nama tabel mungkin ada salah nama
0
Loading...
Ellyx Christian · Feb 12, 2013 · 0 Suka · 0 Tidak Suka
coba ubah jadi seperti di bawah, dan lihat apa errornya?
<?
//Cek Tombol 
if ($_POST){
//Kirimkan Variabel
$id = $_POST['id'];
$nama = $_POST['nama'];
$kelas = $_POST['kelas'];
$alamat = $_POST['alamat'];
$username = $_POST['username'];
$password = $_POST['password'];
 
//validasi data jika pesan kosong
if (empty($_POST['id'])|| empty($_POST['nama'])|| empty($_POST['kelas'])|| empty($_POST['alamat'])|| empty($_POST['username'])|| empty($_POST['password'])) 
{
?>
<script language="JavaScript">
alert('Data Harap Dilengkapi');
document.location='inputsiswa.php';
</script>
<?
}
//Jika Validasi Terpenuhi
else
{
//Memanggil File Koneksi Database
mysql_connect("localhost", "root", "12345");
mysql_select_db("english");
 
//Masukan data ke Table user
     $query ="INSERT INTO user VALUES('$id','$nama','$kelas','$alamat','$username','$password')";
     $hasil = mysql_query($query);  
     if($hasil){  
//Jika Sukses
//echo "Data telah diinput";
?>
<script language="JavaScript">
alert('Data Berhasil diinput');
document.location='index.php';
</script>
<?
 
}
else
{
echo mysql_error(); // hilangkan kalau sudah tahu errornya
//Jika Gagal
//echo "Data gagal diinput, Silakan Ulangi";
}
}
}
?>
<script language="JavaScript">
alert('Data Gagal diinput,, Silakan ulangi');
document.location='inputsiswa.php';
</script>
0
Loading...
Rheyank Iwan Nytt · Feb 12, 2013 · 0 Suka · 0 Tidak Suka
swun mas ,, da bsa ... cmangad,,,,,
0
Loading...
Rheyank Iwan Nytt · Feb 12, 2013 · 0 Suka · 0 Tidak Suka
mas tanya lagi ,,, script di atas da bsa .. trs waktu q tampilin og gbsa ea ??? g kbaca mas di aplikasinya ...
ne script tampilnya mas
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>English Lesson Of Grammar</title>
<link href="css/rheyank_style.css" rel="stylesheet" type="text/css" />

<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" />

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/ddsmoothmenu.js">

/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

</script>

<script type="text/javascript">

ddsmoothmenu.init({
	mainmenuid: "menu", //menu DIV id
	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
	classname: 'ddsmoothmenu', //class added to menu's outer DIV
	//customtheme: ["#1c5a80", "#18374a"],
	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

</script>
<style type="text/css">
<!--
.style3 {color: #000000; font-weight: bold; }
.style4 {color: #000000}
-->
</style>
</head>
<body>

<div id="body">
	<div id="header"></div> 
	<!-- end of header -->
    
    <div id="menu" class="ddsmoothmenu">
        <ul>
            <li><a href="index.php" class="selected">Home</a></li>
            <li><a href="grammar.php">Grammar</a></li>
          	<li><a href="soal.php">Excercise</a></li>
          	<li><a href="about.php">About</a></li>
        </ul>
        <br style="clear: left" />
    </div> <!-- end of menu -->

    <div id="main">
	        <div class="col_l">
        	<h2 align="center">Daftar Siswa Pembelajaran Grammar  </h2>
            <br class="cleaner h20" />
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"  id="tabel">
	<tr bgcolor="#8BB2D9">
		<th width="4%" height="39" bgcolor="#CCCCCC"><span class="style3">No
	        </td>
		</span>
		<th width="7%" bgcolor="#CCCCCC"><span class="style3">Id Siswa </td>
		
		</span>
		<th width="14%" bgcolor="#CCCCCC"><span class="style3">Nama</td>
		
		</span>
		<th width="14%" bgcolor="#CCCCCC"><span class="style3">Kelas 
		      </td>
        </span> </th>
		<th width="14%" bgcolor="#CCCCCC"><span class="style3">Alamat 
		  </td>
        </span> </th>
		<th width="14%" bgcolor="#CCCCCC"><span class="style3">Username 
		  </td>
        </span> </th>
		<th width="14%" bgcolor="#CCCCCC"><span class="style3">Password</span> </th>
		<th width="9%" bgcolor="#CCCCCC"><span class="style3">Action
	        </td>	
	        </span></tr>
	<?
//Memanggil File Koneksi Database
mysql_connect("localhost", "root", "12345");
mysql_select_db("english");

	$sql="SELECT * FROM user ORDER BY id";
	$tampil = mysql_query($sql);
    while (	$hasil = mysql_fetch_array ($tampil)) {
			$kd_materi = stripslashes ($hasil['id']);
			$judul = stripslashes ($hasil['nama']);
			$file = stripslashes ($hasil['kelas']);
			$file = stripslashes ($hasil['alamat']);
			$file = stripslashes ($hasil['username']);
			$file = stripslashes ($hasil['password']);
      {
		$no++;
	?>
		<tr align="center">
		  <td bgcolor="#CCCCCC"><span class="style4"></span></td>
		  <td bgcolor="#CCCCCC"><span class="style4"></span></td>
		  <td bgcolor="#CCCCCC"><span class="style4"></span></td>
		  <td bgcolor="#CCCCCC"><span class="style4"></span></td>
		  <td bgcolor="#CCCCCC"><span class="style4"></span></td>
		  <td bgcolor="#CCCCCC"><span class="style4"></span></td>
		  <td bgcolor="#CCCCCC"><span class="style4"></span></td>
		  <td bgcolor="#CCCCCC">&nbsp;</td>
	  </tr>
		<tr align="center">
			<td bgcolor="#CCCCCC"><span class="style4">
		    <?=$no?>
	        </span>
		  <div align="center" class="style4"></div></td>
			<td bgcolor="#CCCCCC"><span class="style4">
		    <?=$id?>
	        </span>
		  <div align="center" class="style4"></div></td>
			<td bgcolor="#CCCCCC"><span class="style4">
		    <?=$nama?>
	        </span>
		  <div align="center" class="style4"></div></td>
			<td bgcolor="#CCCCCC"><span class="style4">
              <?=$kelas?>
              </span>
                <div align="center" class="style4"></div></td>
			<td bgcolor="#CCCCCC"><span class="style4">
              <?=$alamat?>
              </span>
                <div align="center" class="style4"></div></td>
			<td bgcolor="#CCCCCC"><span class="style4">
              <?=$username?>
              </span>
                <div align="center" class="style4"></div></td>
			<td bgcolor="#CCCCCC"><span class="style4">
              <?=$password?>
              </span>
                <div align="center" class="style4"></div></td>
		  <td bgcolor="#CCCCCC"><div align="center"><a href="editsiswa.php=<?=$id?>">Edit</a> | <a href="deletesiswa.php=<?=$id?>" OnClick="return confirm('Yakin Data <?=$nama?> akan dihapus');">Delete</a></div></td>
	    </tr>
		<tr align="center">
		  <td bgcolor="#CCCCCC"><span class="style4"></span></td>
		  <td bgcolor="#CCCCCC"><span class="style4"></span></td>
		  <td bgcolor="#CCCCCC"><span class="style4"></span></td> 
		  <td bgcolor="#CCCCCC"><span class="style4"></span></td>
		  <td bgcolor="#CCCCCC"><span class="style4"></span></td>
		  <td bgcolor="#CCCCCC"><span class="style4"></span></td>
		  <td bgcolor="#CCCCCC"><span class="style4"></span></td>
		  <td bgcolor="#CCCCCC">&nbsp;</td>
	  </tr>
	<?  
	}}
	?>
  </table>
</div>

            <div class="cleaner h20"></div>
            <a href="inputsoal.php" class="more">Input Soal </a>
        </div>
        </div>
    </div> <!-- end of main -->
    
    <div id="footer">	
  </div>
        <div class="cleaner"></div>
</div> <!-- end of footer -->

<div id="cr_bar_wrapper">
	<div id="cr_bar">
    	Copyright © 2013 Designed by <a href="http://www.facebook.com/rheyank.iwan">Rheyank Iwan</a>    </div>
</div>

</body>
</html>

tlong ea mas.... kci pencerahan lgi
0
Loading...
MyPHPtutorials · Feb 21, 2013 · 0 Suka · 0 Tidak Suka
coba kamu perhatikan kode ini
$sql="SELECT * FROM user ORDER BY id";
	$tampil = mysql_query($sql);
    while (	$hasil = mysql_fetch_array ($tampil)) {
			$kd_materi = stripslashes ($hasil['id']);
			$judul = stripslashes ($hasil['nama']);
			$file = stripslashes ($hasil['kelas']);
			$file = stripslashes ($hasil['alamat']);
			$file = stripslashes ($hasil['username']);
			$file = stripslashes ($hasil['password']);
      {
seharusnya:
$sql="SELECT * FROM user ORDER BY id";
	$tampil = mysql_query($sql);
    while (	$hasil = mysql_fetch_array ($tampil)) {
			$kd_materi = stripslashes ($hasil['id']);
			$judul = stripslashes ($hasil['nama']);
			$kelas = stripslashes ($hasil['kelas']);
			$alamat = stripslashes ($hasil['alamat']);
			$username = stripslashes ($hasil['username']);
			$password = stripslashes ($hasil['password']);
      {
coba kamu pelajari: http://www.myphptutorials.com/tutorials/33/save-edit-delete-data-dari-database