Advertisement
iuliaa

Untitled

Dec 12th, 2020
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. <?php
  2. $db=mysqli_connect("localhost","root","","sfdatabase");
  3. $id=$_REQUEST['id'];
  4. $query = "SELECT * from destinations_page where id='".$id."'";
  5. $result = mysqli_query($db, $query) or die ( "Cannot access db");
  6. $row = mysqli_fetch_assoc($result);
  7. ?>
  8. <!DOCTYPE html>
  9. <html>
  10. <head>
  11. <meta charset="utf-8">
  12. <title>Update Record</title>
  13. <link rel="stylesheet" href="css/style.css" />
  14. <link rel="stylesheet" href="styles.css">
  15. <link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@300;400;700&display=swap" rel="stylesheet">
  16. <script src="https://kit.fontawesome.com/b28a5ee64c.js" crossorigin="anonymous"></script>
  17. <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
  18. <script type="text/javascript" src="ckeditor/sample.js"></script>
  19. <style>
  20.  
  21. #buttonsubmit{
  22. background-color:inherit;
  23. border: 2px solid white;
  24. font-family: 'Roboto Condensed', sans-serif;
  25. font-size:15px;
  26. cursor: pointer;
  27. height: 50px;
  28. width: 90px;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <div class="form">
  34. <h1>Update Record</h1>
  35. <?php
  36. $status = "";
  37. if(isset($_POST['new']) && $_POST['new']==1)
  38. {
  39. $db=mysqli_connect("localhost","root","","sfdatabase");
  40. $id=$_REQUEST['id'];
  41. $target="images/".basename($_FILES['image']['name']);
  42. $description =$_POST['description'];
  43. $destination =$_POST['destination'];
  44. $image=$_FILES['image']['name'];
  45. if ($_FILES['image']['error'] == UPLOAD_ERR_OK) {
  46. $update="update destinations_page set destination='".$destination."',image='".$image."',description='".$description."'
  47. where id='".$id."'";
  48. }else{
  49. $update="update destinations_page set destination='".$destination."',description='".$description."'
  50. where id='".$id."'";
  51. }
  52.  
  53.  
  54. mysqli_query($db, $update) or die("Cannot update");
  55. if(move_uploaded_file($_FILES['image']['tmp_name'], $target)){
  56. $msg="Uploaded successfully";
  57. }else{
  58. $msg="Couldn't upload";
  59. }
  60. $status = "Record Updated! </br></br>
  61. <a href='admin_destinations.php'>View Updated Record</a>";
  62. echo '<p style="color:#FF0000;">'.$status.'</p>';
  63. }else {
  64. ?>
  65. <div>
  66. <form name="form" method="post" action="" width="80%" enctype="multipart/form-data">
  67. <input type="hidden" name="new" value="1" />
  68. <input name="id" type="hidden" value="<?php echo $row['id'];?>" />
  69. <p>Modify the picture:</p>
  70. <p><input type="file" name="image"></p>
  71.  
  72. <p>Edit the destination:</p>
  73. <p><textarea name="destination" cols="40" rows="5" placeholder="Add a destination." required><?php echo $row['destination'];?></textarea></p>
  74. <p>Edit the decription:</p>
  75. <p><textarea name="description" cols="40" rows="5" placeholder="Add a description." class="ckeditor" required><?php echo $row['description'];?></textarea></p>
  76.  
  77.  
  78. <p><input name="submit" type="submit" value="Update" id="buttonsubmit" /></p>
  79. </form>
  80. <?php } ?>
  81. </div>
  82. </div>
  83. </body>
  84. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement