Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $db=mysqli_connect("localhost","root","","sfdatabase");
- $id=$_REQUEST['id'];
- $query = "SELECT * from destinations_page where id='".$id."'";
- $result = mysqli_query($db, $query) or die ( "Cannot access db");
- $row = mysqli_fetch_assoc($result);
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Update Record</title>
- <link rel="stylesheet" href="css/style.css" />
- <link rel="stylesheet" href="styles.css">
- <link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@300;400;700&display=swap" rel="stylesheet">
- <script src="https://kit.fontawesome.com/b28a5ee64c.js" crossorigin="anonymous"></script>
- <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
- <script type="text/javascript" src="ckeditor/sample.js"></script>
- <style>
- #buttonsubmit{
- background-color:inherit;
- border: 2px solid white;
- font-family: 'Roboto Condensed', sans-serif;
- font-size:15px;
- cursor: pointer;
- height: 50px;
- width: 90px;
- }
- </style>
- </head>
- <body>
- <div class="form">
- <h1>Update Record</h1>
- <?php
- $status = "";
- if(isset($_POST['new']) && $_POST['new']==1)
- {
- $db=mysqli_connect("localhost","root","","sfdatabase");
- $id=$_REQUEST['id'];
- $target="images/".basename($_FILES['image']['name']);
- $description =$_POST['description'];
- $destination =$_POST['destination'];
- $image=$_FILES['image']['name'];
- if ($_FILES['image']['error'] == UPLOAD_ERR_OK) {
- $update="update destinations_page set destination='".$destination."',image='".$image."',description='".$description."'
- where id='".$id."'";
- }else{
- $update="update destinations_page set destination='".$destination."',description='".$description."'
- where id='".$id."'";
- }
- mysqli_query($db, $update) or die("Cannot update");
- if(move_uploaded_file($_FILES['image']['tmp_name'], $target)){
- $msg="Uploaded successfully";
- }else{
- $msg="Couldn't upload";
- }
- $status = "Record Updated! </br></br>
- <a href='admin_destinations.php'>View Updated Record</a>";
- echo '<p style="color:#FF0000;">'.$status.'</p>';
- }else {
- ?>
- <div>
- <form name="form" method="post" action="" width="80%" enctype="multipart/form-data">
- <input type="hidden" name="new" value="1" />
- <input name="id" type="hidden" value="<?php echo $row['id'];?>" />
- <p>Modify the picture:</p>
- <p><input type="file" name="image"></p>
- <p>Edit the destination:</p>
- <p><textarea name="destination" cols="40" rows="5" placeholder="Add a destination." required><?php echo $row['destination'];?></textarea></p>
- <p>Edit the decription:</p>
- <p><textarea name="description" cols="40" rows="5" placeholder="Add a description." class="ckeditor" required><?php echo $row['description'];?></textarea></p>
- <p><input name="submit" type="submit" value="Update" id="buttonsubmit" /></p>
- </form>
- <?php } ?>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement