<html>
<head>
<title> Edit data dalam database MySQL </title>
</head>
<body>
<?php
if (isset($_POST['update']))
{
$host= 'localhost';
$user= 'root';
$pass= '';
$conn= mysql_connect($host,$user,$pass);
if (!$conn)
{
die ('Tidak bisa koneksi:'.mysql_error());
}
$nrp= $_POST ['nrp'];
$nama= $_POST['nama'];
$sem= $_POST['semester'];
$jur= $_POST['jurusan'];
$sql= "UPDATE data_mahasiswa".
"SET nama= $nama, semester= $SEM, jurusan= $jur".
"WHERE nrp= $nrp";
mysql_select_db('data_mahasiswa');
$retval= mysql_query($sql,$conn);
if (!$retval)
{
die('Tidak bisa edit data:'.mysql_error());
}
echo "Edit data sukses\n";
mysql_close($conn);
}
else{
?>
<form method="post" action="index3.php">
<table width="500" border="0" cellspacing="1" cellpading="2">
<tr> <td width="100">nrp</td>
<td><input name="nama" type="text" id="nama"></td>
</tr>
<tr> <td width="100">nama</td>
<td><input name="nama" type="text" id="nama"></td>
</tr>
</tr>
<tr> <td width="100">semester</td>
<td><input name="semester" type="text" id="nama"></td>
</tr>
</tr>
<tr> <td width="100">jurusan</td>
<td><input name="jurusan" type="text" id="jurusan"></td>
</tr>
<tr><td width="100"></td>
<td></td></tr>
<tr><td width="100"></td>
<td><input name="update" type="submit" id="update" value="Update">
</td></tr></table>
</from>
<?php
}
?>
</body>
</html>
Tidak ada komentar:
Posting Komentar