Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <PHP code>
- <?php
- //Database Connection
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "recordmain_db" ;
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- //Get ID from Database
- if(isset($_GET['doc_id'])){
- $sql = "SELECT * FROM recordmain_table WHERE doc_id =" .$_GET['doc_id'];
- $result = mysqli_query($conn, $sql);
- $row = mysqli_fetch_array($result);
- }
- //Update Information
- if(isset($_POST['update'])){
- $doc_type = $_POST['doc_type'];
- $doc_date = $_POST['doc_date'];
- $date_sent = $_POST['date_sent'];
- $medium_transac = $_POST['medium_transac'];
- $doc_descrip = $_POST['doc_descrip'];
- $docu_receiver = $_POST['docu_receiver'];
- $doc_address = $_POST['doc_address'];
- $doc_contact = $_POST['doc_contact'];
- $doc_attachment = $_POST['doc_attachment'];
- $update = "UPDATE recordmain_table SET doc_type='$doc_type',
- doc_date='$doc_date',date_sent='$date_sent',
- medium_transac='$medium_transac',doc_descrip='$doc_descrip',
- docu_receiver='$docu_receiver'doc_address='$doc_address',
- doc_contact='$doc_contact',
- doc_attachment='$doc_attachment' WHERE doc_id=". $_GET['doc_id'];
- $up = mysqli_query($conn, $update);
- if(!isset($sql)){
- die ("Error $sql" .mysqli_connect_error());
- }
- else
- {
- header("location: disp.php");
- }
- }
- ?>
- <HTML CODE>
- <!doctype html>
- <html>
- <body>
- <form method="post">
- <h1>Edit Employee Information</h1>
- <label>Type of Document:</label><input type="text" name="doc_type"
- placeholder="Name" value="<?php echo (isset($row['doc_type'])) ?
- $row['doc_type'] : ''; ?>"><br/><br/>
- <label>Date of Document:</label><input type="text" name="doc_date"
- placeholder="Gender" value="<?php echo (isset($row['doc_date'])) ?
- $row['doc_date'] : ''; ?>"><br/><br/>
- <label>Date Sent:</label><input type="text" name="date_sent"
- placeholder="Department" value="<?php echo (isset($row['date_sent'])) ?
- $row['date_sent'] : ''; ?>"><br/><br/>
- <label>Medium of Transaction:</label><input type="text"
- name="medium_transac" placeholder="Address" value="<?php echo
- (isset($row['medium_transac'])) ? $row['medium_transac'] : ''; ?>"><br/>
- <br/>
- <label>Document Title/Description:</label><input type="text"
- name="doc_descrip" placeholder="Mobile" value="<?php echo
- (isset($row['doc_descrip'])) ? $row['doc_descrip'] : ''; ?>"><br/><br/>
- <label>Document Receiver:</label><input type="text" name="docu_receiver"
- placeholder="email" value="<?php echo (isset($row['docu_receiver'])) ?
- $row['docu_receiver'] : ''; ?>"><br/><br/>
- <label>Address:</label><input type="text" name="doc_address"
- placeholder="email" value="<?php echo (isset($row['doc_address'])) ?
- $row['doc_address'] : ''; ?>"><br/><br/>
- <label>Contact Number:</label><input type="text" name="doc_contact"
- placeholder="email" value="<?php echo (isset($row['doc_contact'])) ?
- $row['doc_contact'] : ''; ?>"><br/><br/>
- <label>Attachment:</label><input type="text" name="doc_attachment"
- placeholder="email" value="<?php echo (isset($row['doc_attachment'])) ?
- $row['doc_attachment'] : ''; ?>"><br/><br/>
- <button type="submit" name="update" id="update" onClick="update()">
- <strong>Update</strong></button>
- <a href="disp.php"><button type="button" value="button">Cancel</button></a>
- </form>
- <!-- Alert for Updating -->
- <script>
- function update(){
- var x;
- if(confirm("Updated data Sucessfully") == true){
- x= "update";
- }
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment