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

Phần 2 : đăng ký thành viên


//lưu ý bạn có thể viết code xử lý ở 1 file php riêng và action đến file đó ở đây mình xữ lý trên trang luôn
<body>
<?php
include("Connection.php");//gọi đến file kết nối cơ sở dữ liệu
if(isset($_POST['btn_re']))//kiểm tra xem có bấm nút đăng ký hay không
{
$us=$_POST['t1'];
$pass=md5($_POST['t2']);
$cusname=$_POST['t4'];
$add=$_POST['t5'];
$phone=$_POST['t6'];
//up hinh
$taptin =$_FILES['hinh'];

//kiểm tra file hình ảnh
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']);

$hinhanh=$taptin['name'];
$sq="select * from customer where username='$us'";
$result= mysql_query($sq);
if(mysql_num_rows($result)>0){
echo "<script>alert('username da ton tai')</script>";
echo '<meta http-equiv="refresh" content="0;url=dangki.php"/>';
}
else{
$sql="insert into customer values('$us','$pass','$cusname','$add','$phone','$hinhanh')";
mysql_query($sql);
echo "<script>alert('dang ki thanh cong')</script>";
echo '<meta http-equiv="refresh" content="0;url=login.php"/>';
}

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

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

}

 ?>
<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>Register Form</h2></td>
    </tr>
    <tr>
      <td>Username</td>
      <td><label for="t1"></label>
        <input type="text" name="t1" id="t1" /></td>
    </tr>
    <tr>
      <td>Password</td>
      <td><label for="t2"></label>
        <input type="password" name="t2" id="t2" /></td>
    </tr>
    <tr>
      <td>confim Pass</td>
      <td><label for="t3"></label>
        <input type="password" name="t3" id="t3" /></td>
    </tr>
    <tr>
      <td>Customer Name</td>
      <td><label for="t4"></label>
        <input type="text" name="t4" id="t4" /></td>
    </tr>
    <tr>
      <td>Address</td>
      <td><label for="t5"></label>
        <input type="text" name="t5" id="t5" /></td>
    </tr>
    <tr>
      <td>Phone</td>
      <td><label for="t6"></label>
        <input type="text" name="t6" id="t6" /></td>
    </tr>
    <tr>
      <td>Your Image</td>
      <td><label for="hinh"></label>
        <input type="file" name="hinh" id="hinh" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="btn_re" id="btn_re" value="Register" /></td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>
</body>

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