Selasa, 18 September 2012

Script PHP

SCRIPT PHP  GABUNGAN

           
<?   
if(isset($_POST['simpanEDIT']))
  {
  $con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("smksr", $con);

$sql="UPDATE siswa set nis='$_POST[nis]', nama='$_POST[nama]'
where nis='$_POST[nis]'";
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record Update";
mysql_close($con);

 

if(isset($_POST['cariEDIT']))
  {
  $conn=mysql_connect("localhost", "root", "");
mysql_select_db("smksr");
//membuat query select
$sql="select * from siswa WHERE nis='$_POST[nis]'";
//membaca data
$hasil=mysql_query($sql);
//menampilkan data
$row=mysql_fetch_array($hasil)
?>
  <p align="center"><strong><font size="6">Edit Data Siswa </font></strong></p>
  <form name="form4" method="post" action="">
    <div align="center">
      <table width="29%"  border="1">
        <tr>
          <td width="43%">Nis</td>
          <td width="57%"><input name="nis" type="text" id="nis" value="<? echo $row['nis']; ?>" size="10">        </td>
        </tr>
        <tr>
          <td>Nama Siswa </td>
          <td><input name="nama" type="text" id="nama" value="<? echo $row['nama']; ?>"></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input type="submit" name="simpanEDIT" value="Simpan Data"></td>
        </tr>
          </table>
    </div>
</form>





  <p>    <? 
  }

 if(isset($_POST['cariHPS']))
  {
  $con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("smksr", $con);
mysql_query("DELETE FROM siswa WHERE nis='$_POST[nis]'");
mysql_close($con);
 
  }

 if(isset($_POST['cari']))
  {
  ?>
  </p>
  <p align="center"><font color="#0000FF"><font face="Times New Roman" size="6">LAPORAN PENCARIAN DATA SISWA</font></font></p>
        <div align="center">
          <div align="center">
            <table width="57%"  border="1">
              <tr bgcolor="#999999">
                <td width="28%"><div align="center"><strong>NIS</strong></div></td>
                <td width="72%"><div align="center"><strong>NAMA SISWA </strong></div></td>
              </tr>
              <?
            $conn=mysql_connect("localhost", "root", "");
mysql_select_db("smksr");
//membuat query select
$sql="select * from siswa WHERE nis='$_POST[nis]'";
//membaca data
$hasil=mysql_query($sql);
//menampilkan data
while($row=mysql_fetch_array($hasil)){
            ?>
              <tr>
                <td><? echo $row['nis']; ?></td>
                <td><? echo $row['nama']; ?></td>
              </tr>
              <?
            }
            ?>
                    </table>
</div>
         
  <?
  }










if(isset($_POST['simpan']))
  {
$conn=mysql_connect("localhost", "root", "");
mysql_select_db("smksr");
$sql="INSERT INTO siswa (nis, nama)
VALUES
('$_POST[nis]','$_POST[nama]')";
if (!mysql_query($sql))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";
}
 
if(isset($_POST['access']))
  {

    if ($_POST[ac]=="input")
      {
       ?>
   
        <p align="center"><font color="#0000FF"><font face="Times New Roman" size="6">INPUT DATA SISWA </font></font></p>
        <form name="form1" method="post" action="">
          <div align="center">
            <table width="27%"  border="0">
              <tr>
                <td width="42%">Nis</td>
                <td width="58%"><input name="nis" type="text" id="nis" size="10"></td>
              </tr>
              <tr>
                <td>Nama Siswa </td>
                <td><input name="nama" type="text" id="nama"></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td><input type="submit" name="simpan" value="Simpan Data"></td>
              </tr>
                    </table>
          </div>
</form>
        <p align="center"><font color="#0000FF" size="6" face="Times New Roman"></font></p>
        <div align="center">
         
</div>
        <div align="center"></div>
        <p>&nbsp; </p>
        <p>         
          <? 
      }











      if ($_POST[ac]=="tampil")
      {
      ?>
     
        </p>
        <p align="center"><font color="#0000FF"><font face="Times New Roman" size="6">LAPORAN DATA SISWA</font></font></p>
        <div align="center">
          <table width="57%"  border="1">
            <tr bgcolor="#999999">
              <td width="28%"><div align="center"><strong>NIS</strong></div></td>
              <td width="72%"><div align="center"><strong>NAMA SISWA </strong></div></td>
            </tr>
            <?
            $conn=mysql_connect("localhost", "root", "");
mysql_select_db("smksr");
//membuat query select
$sql="select * from siswa";
//membaca data
$hasil=mysql_query($sql);
//menampilkan data
while($row=mysql_fetch_array($hasil)){
            ?>
            <tr>
              <td><? echo $row['nis']; ?></td>
              <td><? echo $row['nama']; ?></td>
            </tr>
            <?
            }
            ?>
                  </table>
          <form name="form2" method="post" action="logica2.php">
            <input type="submit" name="Submit" value="Back">
          </form>
          <p>&nbsp;</p>
</div>
        <p align="center"><font color="#0000FF" size="6" face="Times New Roman"></font></p>
        <? 
      }
      if ($_POST[ac]=="cari")
      {
      ?>
   
        <p align="center"><font color="#0000FF"><font face="Times New Roman" size="6">Cari Data Siswa</font></font></p>
        <form name="form3" method="post" action="">
          <div align="center">Nis :
            <input name="nis" type="text" id="nis" size="10">
            <input type="submit" name="cari" value="Cari">
          </div>
        </form>
        <p align="center"><font color="#0000FF" size="6" face="Times New Roman"></font></p>
        <? 
      }
   




  if ($_POST[ac]=="hapus")
      {
      ?>
   
        <p align="center"><font color="#0000FF"><font face="Times New Roman" size="6">Cari Data Siswa Yang Hapus</font></font></p>
        <p align="center">
        <form name="form3" method="post" action="">
          <div align="center">Nis :
            <input name="nis" type="text" id="nis" size="10">
            <input type="submit" name="cariHPS" value="Cari">
          </div>
        </form>
        </p>
        <? 
      }
      if ($_POST[ac]=="edit")
      {
      ?>
   
        <p align="center"><font color="#0000FF"><font face="Times New Roman" size="6">Cari Data Siswa Yang Di Edit </font></font></p>
        <p align="center">
        <form name="form3" method="post" action="">
          <div align="center">Nis :
            <input name="nis" type="text" id="nis" size="10">
            <input type="submit" name="cariEDIT" value="Cari">
          </div>
        </form>
        </p>
        <? 
      } 
}
  else
   {
   ?>
          <p align="center"><font color="#0000FF"><font face="Times New Roman" size="6">Cari Data </font></font></p>
          <form action="" method="POST">
  <table width="21%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#111111" id="AutoNumber1" style="border-collapse: collapse">
  <tr>
    <td width="37%"><b>Tema</b></td>
    <td width="63%" ><input type="text" name="ac" id="ac" size="20" /></td>
  </tr>
 
  <tr>
    <td width="37%">&nbsp;</td>
    <td width="63%"><input type="submit" name="access" value="Cari"/></td>
  </tr>
</table>

  </form>
            <?PHP
  }
  ?>

Tidak ada komentar:

Posting Komentar

Know us

Our Team

Video of the Day

Contact us

Nama

Email *

Pesan *