Guest User

Untitled

a guest
Feb 1st, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. //config.php
  2.  
  3. <?php
  4.  
  5.  
  6. $db_host="localhost";
  7. $db_user="root";
  8. $db_pass="";
  9. $db_name="enr";
  10.  
  11.  
  12. $db = new mysqli($db_host, $db_user, $db_pass, $db_name);
  13.  
  14. if($db->connect_error){
  15. die("Connection failed: " . $db->connect_error);
  16. }
  17.  
  18.  
  19.  
  20. ?>
  21.  
  22.  
  23.  
  24. //update.php
  25.  
  26.  
  27. <!DOCTYPE html>
  28. <html>
  29. <head>
  30. <title>Update</title>
  31. </head>
  32. <body>
  33.  
  34. <?php
  35.  
  36. include ("config.php");
  37.  
  38. $id = "";
  39. $image = "";
  40. $name = "";
  41. $reg ="";
  42. $contact = "";
  43. $email = "";
  44. $shift = "";
  45. $semester = "";
  46. $courses = "";
  47.  
  48.  
  49. if (isset($_POST["update"]))
  50.  
  51. {
  52.  
  53. $query = "UPDATE students SET image = '$image', name = '$name', reg = '$reg', contact = '$contact', email = '$email', shift = '$shift',semester ='$semester', courses = '$courses' WHERE id = '$id' ";
  54.  
  55. try{
  56.  
  57. $data = mysqli_query($db, $query);
  58.  
  59. if($data)
  60. {
  61. if(mysqli_affected_rows($db) > 0)
  62. {
  63. echo '<div id="msg"> Data Updated <a href="view.php">Check Data</a> </div>';
  64. }else{
  65. echo '<div id="msg"> Data could not be updated <a href="view.php">Check Data</a> </div>';
  66. }
  67. }
  68. } catch (Exception $ex) {
  69. echo 'Error Update '.$ex->getMessage();
  70. }
  71.  
  72. }
  73.  
  74. ?>
  75.  
  76.  
  77. </body>
  78. </html>
Add Comment
Please, Sign In to add comment