Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. <?php
  2. $hostname = "localhost";
  3. $dbname = "value";
  4. $username = "value";
  5. $password = "value";
  6.  
  7. $conn = new MySQLi($hostname, $username, $password, $dbname) or die('Can not connect to database')
  8. ?>
  9. <html>
  10. <head>
  11. <title>Untitled Document</title>
  12. </head>
  13. <body>
  14. <?php
  15. if(isset($_POST['Submit'])){
  16.  
  17.  
  18. $pubdate = $_POST['updatepubdate'];
  19.  
  20. $title = $_POST['updatetitle'];
  21.  
  22. $publisher = $_POST['updatepublisher'];
  23.  
  24. $img = $_POST['updateimg'];
  25.  
  26. $update = "UPDATE Books SET PublishDate='$pubdate', Title='$title', Publisher='$publisher', Image='$img' WHERE BookID = ".$bookid;
  27. $conn->query($update) or die("Cannot update");
  28. }
  29. ?>
  30. <?php
  31. $sql = "SELECT * FROM Books WHERE BookID = '".$bookid."'";
  32.  
  33. $result = $conn->query($sql) or die(mysql_error());
  34. $query=getenv(QUERY_STRING);
  35. parse_str($query);
  36.  
  37. ?>
  38. <h2>Update Record <?php echo $bookid;?></h2>
  39. <form action="" method="post">
  40. <?php
  41.  
  42.  
  43. while ($row = $result->fetch_assoc()) {?>
  44.  
  45. <table border="0" cellspacing="10">
  46. <tr>
  47. <td>Title:</td> <td><input type="text" name="updatetitle" value="<?php echo $row['Title']; ?>"></td>
  48. </tr>
  49. <tr>
  50. <td>Publisher:</td> <td><input type="text" name="updatepublisher" value="<?php echo $row['Publisher']; ?>"></td>
  51. </tr>
  52. <tr>
  53. <td>Publish Date:</td> <td><input type="text" name="updatepubdate" value="<?php echo $row['PublishDate']; ?>"></td>
  54. </tr>
  55. <tr>
  56. <td>Image URL:</td> <td><input type="text" name="updateimg" size="100" value="<?php echo $row['Image']; ?>"></td>
  57. </tr>
  58. <tr>
  59. <td><INPUT TYPE="Submit" VALUE="Update the Record" NAME="Submit"></td>
  60. </tr>
  61. </table>
  62. <?php }
  63. ?>
  64. </form>
  65. <?php
  66. if($update){
  67.  
  68. echo "<b>Update successful!</b>";
  69.  
  70.  
  71.  
  72. }
  73. ?>
  74. </body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement