Guest User

ayush

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