Seri php thuần đăng ký đăng nhập thêm sửa xóa trong php

Phần 5 sữa dử liệu


<body>
<?php
include("Connection.php");
$us=$_GET['us'];
$sql= "SELECT * FROM `customer` where username='$us'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);


?>
<form action="" method="post" enctype="multipart/form-data" name="f" id="f">
  <table width="484"  align="center">
    <tr>
      <td width="129">&nbsp;</td>
      <td width="264" style="color:red;"><h2>Update Customer</h2></td>
    </tr>
    <tr>
      <td>Username</td>
      <td><label for="t1"></label>
        <input type="text" name="t1" id="t1" readonly="readonly" value="<?php echo $row['username'];?>"/></td>
    </tr>
    <tr>
      <td>Customer Name</td>
      <td><label for="t2"></label>
        <input type="text" name="t2" id="t2"  value="<?php echo $row['custname'];?>" /></td>
    </tr>
    <tr>
      <td>Address</td>
      <td><label for="t3"></label>
        <input type="text" name="t3" id="t3"   value="<?php echo $row['address'];?>"/></td>
    </tr>
    <tr>
      <td>Phone</td>
      <td><label for="t4"></label>
        <input type="text" name="t4" id="t4"  value="<?php echo $row['tel'];?>"/></td>
    </tr>
    <tr>
      <td>Your Image</td>
      <td><label for="hinh"></label>
        <img src="Image/<?php echo $row['hinhanh']?>" width="175" height="175"/>
        <input type="file" name="hinh" id="hinh" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="btn_up" id="btn_up" value="Save" /></td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>
<?php
if(isset($_POST['btn_up']))
{
include("Connection.php");
$us=$_POST['t1'];
$ten=$_POST['t2'];
$diachi=$_POST['t3'];
$sdt=$_POST['t4'];
$taptin =$_FILES['hinh'];
$hinhanh=$taptin['name'];

if($hinhanh=="")
{
$sq="UPDATE customer SET username='$us',custname='$ten',address='$diachi',tel='$sdt'
WHERE username='$us'";

mysql_query($sq);
echo "<script>alert('cap nhat thanh cong')</script>";
echo '<meta http-equiv="refresh" content="0;url=select_cus_del.php"/>';

}

else
{
if($taptin['type']=="image/ipg"||$taptin['type']=="image/jpeg"||$taptin['type']=="image/png"||$taptin['type']=="image/gif")
{
if($taptin['size']<=614400)
{
copy($taptin['tmp_name'],"Image/".$taptin['name']);


$sql="UPDATE customer SET username='$us',custname='$ten',address='$diachi',tel='$sdt',hinhanh='$hinhanh'
WHERE username='$us'";

mysql_query($sql);
echo "<script>alert('cap nhat thanh cong')</script>";
echo '<meta http-equiv="refresh" content="0;url=select_cus_del.php"/>';

}

else
{
echo  "hinh co kich thuoc lon";
}

}
else
{
echo "ko dung dinh dang hinh";
}

}
}


?>

Comments

Bài đăn phổ biến

Tính Bình Phương 1 Số Trong Python

Deploy website lên VPS hoặc Hosting với Gitlab CI/CD

Đổi tên "READ MORE" trong bài post

MỞ CAMERA VÀ CHỤP ẢNH BẰNG PHP