Guest User

Untitled

a guest
Feb 2nd, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <?php
  2. $db_host="localhost";
  3. $db_user="root";
  4. $db_pass="";
  5. $db_name="enr";
  6.  
  7. $db = new mysqli($db_host, $db_user, $db_pass, $db_name);
  8.  
  9. if($db->connect_error){
  10. die("Connection failed: " . $db->connect_error);
  11. }
  12. ?>
  13.  
  14. <?php
  15.  
  16. include ("config.php");
  17.  
  18. $id = "";
  19. $image = "";
  20. $name = "";
  21. $reg ="";
  22. $contact = "";
  23. $email = "";
  24. $shift = "";
  25. $semester = "";
  26. $courses = "";
  27.  
  28. if (isset($_POST["update"]))
  29. {
  30. $query = "UPDATE students
  31. SET image = '$image', name = '$name', reg = '$reg', contact = '$contact', email = '$email', shift = '$shift',semester ='$semester', courses = '$courses'
  32. WHERE id = '$id' ";
  33. try{
  34. $data = mysqli_query($db, $query);
  35. if($data)
  36. {
  37. if(mysqli_affected_rows($db) > 0)
  38. {
  39. echo '<div id="msg"> Data Updated <a href="display.php">Check Data</a> </div>';
  40. }else{
  41. echo '<div id="msg"> Data could not be updated <a href="display.php">Check Data</a> </div>';
  42. }
  43. }
  44. } catch (Exception $ex) {
  45. echo 'Error Update '.$ex->getMessage();
  46. }
  47. }
  48. ?>
Add Comment
Please, Sign In to add comment