Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = "localhost";
- $username = "root";
- $password = "";
- $db_name = "db_php_school";
- mysql_connect($host,$username,$password) or die("Database not connect");
- mysql_select_db($db_name) or die ("could not connect databse");
- error_reporting("E_ERROR_WORKING");
- echo "Database connecet success";
- ?>
- <?php
- include './classes/image_class.php';
- $obj_image = new Image();
- if(@$_POST['Submit'])
- {
- $obj_image->image_name=str_replace("'", "''", $_POST['txt_image_name']);
- $obj_image->image=str_replace("'", "''", $_POST['txt_image']);
- $obj_image->Insert_into_image();
- $data_image=$obj_image->get_all_image_list();
- $row=mysql_num_rows($data_image);
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>NOvaeye </title>
- </head>
- <body>
- <CENTER><H1>Novaeyewear</H1></CENTER>
- <CENTER><H2>Sunglass</H2></CENTER>
- <CENTER>
- <form method="post" enctype="multipart/form-data">
- <table border="1" width="80%">
- <tr>
- <th width="50%">Image NAme</th>
- <td width="50%"><input type="text" name="txt_image_name"></input></td>
- </tr>
- <tr>
- <th width="50%">Upload IMage</th>
- <td width="50%"><input type="file" name="txt_image"></input></td>
- </tr>
- <tr>
- <td></td>
- <td width="50%"><input type="submit" name="Submit" value="Submit"></input></td>
- </tr>
- </table>
- </form>
- </CENTER>
- <?php
- if($row!=0)
- {
- ?>
- <center>
- <table width="80%" border="1">
- <?php
- $icount = 1;
- while($data= mysql_fetch_assoc($data_image))
- {
- ?>
- <tr>
- <td style="text-align:center" style="width:10%;"><?php echo $icount; ?></td>
- <td style="text-align:center" style="width:20%;"><?php echo $data['image_name']?></td>
- <td style="text-align:center" style="width:50%;><img src="images/<?php echo $data['image']; ?>" width="400px" height="200px"></td>
- </tr>
- <?php
- $icount++;
- }
- ?>
- </table>
- </center>
- <?php
- }
- ?>
- </body>
- </html>
- <?php
- include 'db/db.php' ;
- class Image{
- var
- $image_id,
- $image_name,
- $image;
- function Insert_into_image(){
- if(isset($_FILES['txt_image']))
- {
- $tempname = $_FILES['txt_image']['tmp_name'];
- $originalname =$_FILES['txt_image']['name'];
- $size =($_FILES['txt_image']['size']/5242888). "MB<br>";
- $type=$_FILES['txt_image']['type'];
- $image=$_FILES['txt_image']['name'];
- move_uploaded_file($_FILES['txt_image']['tmp_name'],"images/".$_FILES['txt_image']['name']);
- }
- $query = "Insert into t_image_upload
- (
- image_name,
- image
- )
- values
- (
- '$this->image_name',
- '$image'
- )";
- if(mysql_query($query)){
- echo "Insert success";
- }
- else
- {
- echo "Insert not success";
- }
- }
- function get_all_image_list(){
- $query = "select *from t_image_upload";
- $result = mysql_query($query);
- return $result;
- }
- }
- ?>
- <td style="text-align:center" style="width:50%;><img src="images/<?php echo $data['image']; ?>" width="400px" height="200px"></td>
- </tr>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement