Advertisement
Guest User

sandip

a guest
Feb 15th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. <?php
  2. $servername= "localhost";
  3. $username= "root";
  4. $password="";
  5. $dbname="bit2018";
  6. $msg='';
  7. $std_id = $_GET['id'];
  8. //create connection
  9. $conn = mysqli_connect($servername, $username, $password, $dbname);
  10. //check connection
  11. if(!$conn)
  12. {
  13. die("Connection failed:" . mysqli_connect_error());
  14. }
  15. if(isset($_POST['updatebtn']))
  16. {
  17. $std_fname= $_POST['std_fname'];
  18. $std_lname= $_POST['std_lname'];
  19. $std_roll= $_POST['std_roll'];
  20. $std_contact= $_POST['std_contact'];
  21. $std_address= $_POST['std_address'];
  22.  
  23. $sqlQuery = "UPDATE students SET std_fname='$std_fname', std_lname='$std_lname',std_roll='$std_roll',std_contact='$std_contact',std_address='$std_address' WHERE std_id='$std_id';
  24. if(mysqli_query($conn,$sqlQuery))
  25. {
  26. $msg = "Information updated Successfully";
  27. }
  28. else
  29. {
  30. $msg = "Problem in updating data";
  31. }
  32. }
  33. $selectQuery = "SELECT" FROM students WHERE std_id='$std_id'";
  34. $result = mysqli_query($conn, $selectQuery);
  35. $info = mysqli_fetch_assoc($result);
  36. ?>
  37.  
  38.  
  39. <h1 style = "color:green"><?php echo $msg;?></h1>
  40. <fieldset>
  41. <legend>student update form</legend>
  42. <form method = "POST">
  43. <b>First Name:</b><input type="text" value="<?php echo $info['std_fname'];?>" name="std_fname" required>
  44. <hr>
  45. <b>Last Name:</b><input type="text" value="<?php echo $info['std_lname'];?>" name="std_lname" required>
  46. <hr>
  47. <b>Roll:</b><input type="text" value="<?php echo $info['std_roll'];?>" name="std_roll" required>
  48. <hr>
  49. <b>Contact:</b><input type="text" value="<?php echo $info['std_contact'];?>" name="std_contact" required>
  50. <hr>
  51. <b>Address:</b><input type="text" value="<?php echo $info['std_address'];?>" name="std_address" required>
  52. <hr>
  53. <button type="submit" name="updatebtn"> Save</button>
  54. </form>
  55. </fieldset>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement