সাধারন একটি পিএইচপি ফটো গ্যালারী। এটা আমি এমন ভাবে তৈরী করেছি ইচ্ছা করলে আপনি এই সিসিটেমটা আপনার সাইটে ইউজার প্রফাইল ফটো হিসাবে ব্যবহার করতে পারবেন।
HTML Code:
- <form action="#" method="post" enctype="multipart/form-data">
- <table style="margin:100px;">
- <tr><td>Name :</td><td> <input type="text" name="name" /></td></tr>
- <tr><td>User Name :</td><td> <input type="text" name="username" /></td><tr>
- <tr><td>Password :</td><td> <input type="password" name="password" /></td></tr>
- <tr><td>Phosto :</td><td> <input type="file" name="photo" /></td></tr>
- <tr><td></td><td><input type="submit" name="submit" value="Submit" required /></td></tr>
- </table>
- </form>
PHP Code for Photo Upload:
- <?php
- if(isset($_POST["submit"])){
- $name=$_POST["name"];
- $username=$_POST["username"];
- $password=$_POST["password"];
- //This code for Photo save by photo original name.
- //move_uploaded_file($_FILES["photo"]["tmp_name"],"photo/".$_FILES["photo"]["name"]);
- $photo=$_FILES["photo"]["name"];
- $photoEx="";
- if(!empty($photo)){
- $photoEx=pathinfo($photo);
- $photoEx=$photoEx["extension"];
- }else{
- echo "Please chose a photo.";
- }
- if($photoEx=="jpg" or $photoEx=="JPG" or $photoEx=="png" or $photoEx=="gif" or $photoEx=="jpeg" or $photoEx=="JPEG"){
- include("config.php");
- $db->query("insert into user_info(name,username,password) values('$name','$username','$password')");
- $id=$db->insert_id;
- $photoName=$id.".".$photoEx;
- $db->query("update user_info set photo='$photoName' where id='$id'");
- move_uploaded_file($_FILES["photo"]["tmp_name"],"photo/".$photoName);
- echo "Photo saved.";
- }else{
- echo "<font color='#FF0000'>Please select jpg or png or gif or jpeg format photo.</font>";
- }
- }
- ?>
PHP Code for Show The Photo Gallery: ai code ta alada page a likben. jekane Gallery show korate chan.
- <div id="photoGalary">
- <?php
- include("admin/config.php");
- $rs=$db->query("select * from galary");
- //echo "<div id=\"photoGalary\">";
- while($row=$rs->fetch_row()){
- echo "<img src='galary/$row[1]'/>";
- }
- //echo "</div>";
- ?>
- </div>
CSS Code:
- #photoGalary{
- position:relative;
- overflow:hidden;
- width:100%;
- padding:0px;
- float:left;
- margin-bottom:30px;
- }
- #photoGalary img{
- margin: 30px 0 0 40px;
- border: 1px solid #008C45;
- height: 150px;
- width: 200px;
- float: left;
- text-align: center;
- }
আজ এ পর্যন্ত আল্লাহ হফেজ!!
Thanks!!!