Pelajaran Hidup

Inspirasi dari sebuah pengalaman dan pelajaran hidup..Semua butuh sebuah pembelajaran

Script Edit di PHP

Mengedit data dengan php

Contoh mengedit data anggota ;

<form id="form1" name="form1" method="post" action="edit_angg_reg.php">

<font face="Calibri" size="5"><center>Edit Anggota</center></font>

<?

session_start();

include("koneksi.php");

$no=$HTTP_GET_VARS['no'];

$query_string="select * from peminjam where no='$no'";

$query=mysql_query($query_string);

$record=mysql_fetch_array($query);

?>

<input name="no" type="hidden" id="no" value="<? echo $record['no'];?>" />

<table width="530" border="0">

<tr>

<td width="91" align="left" valign="top"><font face="Calibri"> Nama </font></td>

<td width="12" align="center" valign="top"><font face="Calibri">:</font></td>

<td width="275" align="left" valign="top"><label>

<input name="nama" type="text" id="nama" value="<? echo $record['nama'];?>" size="30" />

</label></td>

</tr>

<tr>

<td width="91" align="left" valign="top"><font face="Calibri"> NIM / NoKTP </font></td>

<td width="12" align="center" valign="top"><font face="Calibri">:</font></td>

<td width="275" align="left" valign="top"><label>

<input name="nim" type="text" id="nim" value="<? echo $record['nim'];?>" size="30" />

</label></td>

</tr>

<tr>

<td width="91" align="left" valign="top"><font face="Calibri"> Alamat </font></td>

<td width="12" align="center" valign="top"><font face="Calibri">:</font></td>

<td width="275" align="left" valign="top"><label>

<input name="alamat" type="text" id="alamat" value="<? echo $record['alamat'];?>" size="30" />

</label></td>

</tr>

<tr>

<td width="91" align="left" valign="top"><font face="Calibri"> No Telp </font></td>

<td width="12" align="center" valign="top"><font face="Calibri">:</font></td>

<td width="275" align="left" valign="top"><label>

<input name="hp" type="text" id="hp" value="<? echo $record['hp'];?>" size="30" />

</label></td>

</tr>



<td>&nbsp;</td>

<td>&nbsp;</td>

<td><label>

<input type="submit" name="Submit" value="SIMPAN" />

<input type="reset" name="Submit2" value="BATAL" />

</label></td>

</tr>

</table>

<p>&nbsp; </p>

</form>



Edit_anggota_reg.php

<?

session_start();

include ("koneksi.php");

$nama=$HTTP_POST_VARS['nama'];

$nim=$HTTP_POST_VARS['nim'];

$alamat=$HTTP_POST_VARS['alamat'];

$hp=$HTTP_POST_VARS['hp'];

mysql_query("update peminjam set nama='$nama',nim='$nim',alamat='$alamat',hp='$hp' where no='$no'");

header ("location:main.php?a=lihatp");

?>




download disini