Guest User

Untitled

a guest
Aug 8th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. <?php
  2. include("header.php");
  3. ?>
  4. <html>
  5. <head>
  6. <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  7.  
  8. </head>
  9. <body>
  10.  
  11.  
  12. <html>
  13. <body>
  14. <?php
  15. $b = $_POST['b'];
  16. $c = $_POST['c'];
  17. $d = $_POST['d'];
  18. $e = $_POST['e'];
  19. $f = $_POST['f'];
  20. $id = $_GET['id'];
  21.  
  22. if($_POST['v'] == "1"){
  23.  
  24. $dbconn = pg_connect("host=localhost dbname=project6 user=postgres password=p@ssw0rd")
  25. or die('Could not connect: ' . pg_last_error());
  26.  
  27.  
  28. $query = "update nutrition set shrt_desc='$b',water='$c',energ_kcal='$d',protein='$e',lipid_tot='$f' where ndb_no = '$id'";
  29. $update = pg_query($dbconn, $query);
  30. if($update)
  31. {
  32. ?>
  33. <meta http-equiv="refresh" content="0; url=inspect.php?id=<?php echo $id; ?>">
  34. <?php
  35. } else {
  36. echo "I can't update database.";
  37. }
  38.  
  39. }
  40. ?>
  41. <form action="#" method="post">
  42. <input type="hidden" name="b" value="<?php echo $b; ?>">
  43. <input type="hidden" name="c" value="<?php echo $c; ?>">
  44. <input type="hidden" name="d" value="<?php echo $d; ?>">
  45. <input type="hidden" name="e" value="<?php echo $e; ?>">
  46. <input type="hidden" name="f" value="<?php echo $f; ?>">
  47. <input type="hidden" name="v" value="1">
  48. Ndb_No: <?php echo $a; ?><br>
  49. Shrt_desc: <?php echo $b; ?><br>
  50. Water: <?php echo $c; ?><br>
  51. Energy_kcal: <?php echo $d; ?><br>
  52. Protein: <?php echo $e; ?><br>
  53. Lipid_tot: <?php echo $f; ?><br><br>
  54.  
  55. Are you sure you want to change this?<br>
  56. <input type="submit" value="Yes">
  57. <input type="button" value="No" onclick="location.href='edit.php?id=<?php echo $id; ?>'">
  58. </form>
  59.  
  60. </body>
  61. </html>
Add Comment
Please, Sign In to add comment