Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="insert2.php" method="GET" enctype="multipart/form-data">
- <div class="container">
- <div class="row">
- <h2>3. Description of Item(s) </h2>
- </div>
- <div class="col-xs-12">
- <div class="styled-input wide">
- <textarea name="description" required /></textarea>
- </div>
- // this is the file attachment where it allows to select file from computer.
- <div>
- <label>Attachment:</label><input type='file' name='img' ><br>
- </div>
- </div>
- </form>
- $con= mysqli_connect('127.0.0.1','root','');
- if(!$con)
- {
- echo 'Not Connected To Server';
- }
- if(!mysqli_select_db($con,'satsform1'))
- {
- echo 'Database Not Selected';
- }
- $description = $_GET['description'];
- $image = $_GET['img'];
- //insert image to database.
- $sql = "INSERT INTO handover (description,image)
- VALUES ('$description','$image')";
- if(!mysqli_query($con,$sql))
- {
- echo 'Not Submitted';
- }
- else
- {
- echo 'Submitted';
- }
- header("refresh:2; url=selection.php")
- ?>
- <?php
- $connect = mysqli_connect('127.0.0.1','root','', 'satsform1');
- $output = '';
- if(isset($_POST["query"]))
- {
- $search = mysqli_real_escape_string($connect, $_POST["query"]);
- $query = "
- SELECT * FROM handover
- WHERE name LIKE '%".$search."%'
- OR staffno LIKE '%".$search."%'
- OR date LIKE '%".$search."%'
- OR email LIKE '%".$search."%'
- ";
- }
- else
- {
- $query = "
- SELECT * FROM handover ORDER BY ID
- ";
- }
- $result = mysqli_query($connect, $query);
- if(mysqli_num_rows($result) > 0)
- {
- $output .= '
- <div class="table-responsive">
- <table class="table table bordered">
- <tr>
- <th>ID</th>
- <th>Image</th>
- </tr>
- ';
- while($row = mysqli_fetch_array($result))
- {
- $output .= '
- <tr>
- <td>'.$row["ID"].'</td>
- <td>'.$row["img"].'</td>
- </tr>
- ';
- }
- echo $output;
- }
- else
- {
- echo 'Data Not Found';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement