Guest User

Untitled

a guest
Sep 3rd, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. <?php
  2. /**
  3. * Personal Information Registration
  4. */
  5.  
  6. // Place all required files here
  7. require_once('core/registerNew.php');
  8.  
  9. if($_POST){
  10.  
  11. // Declare the variables to prevent undefined var errors
  12. $lastname =""; $firstname = "";
  13. $middlename= ""; $address = "";
  14. $contact = ""; $gender = "";
  15. $course = ""; $bday = "";
  16. $bplace = ""; $telnum = "";
  17. $mother = ""; $father = "";
  18. $guardian = ""; $lastschool = "";
  19.  
  20. if(!empty($_POST['lastname'])) $lastname = strip_tags($_POST['lastname']);
  21. if(!empty($_POST['firstname'])) $firstname = strip_tags($_POST['firstname']);
  22. if(!empty($_POST['middlename'])) $middlename = strip_tags($_POST['middlename']);
  23. if(!empty($_POST['address'])) $address = strip_tags($_POST['address']);
  24. if(!empty($_POST['contact'])) $contact = strip_tags($_POST['contact']);
  25. if(!empty($_POST['gender'])) $gender = strip_tags($_POST['gender']);
  26. if(!empty($_POST['course'])) $course = strip_tags($_POST['course']);
  27. if(!empty($_POST['bday'])) $bday = strip_tags($_POST['bday']);
  28. if(!empty($_POST['bplace'])) $bplace = strip_tags($_POST['bplace']);
  29. if(!empty($_POST['telnum'])) $telnum = strip_tags($_POST['telnum']);
  30. if(!empty($_POST['mother'])) $mother = strip_tags($_POST['mother']);
  31. if(!empty($_POST['father'])) $father = strip_tags($_POST['father']);
  32. if(!empty($_POST['guardian'])) $guardian = strip_tags($_POST['guardian']);
  33. if(!empty($_POST['lastschool'])) $lastschool = strip_tags($_POST['lastschool']);
  34.  
  35. global $connect;
  36. $stmt = $connect->prepare("INSERT INTO `students`(`lastname`, `firstname`, `middlename`, `address`, `gender`, `course`, `bplace`, `mother`, `father`, `guardian`, `lastschool`, `contact`, `bday`, `telnum`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
  37. $stmt->bind_param("ssssssssssssss",$lastname,$firstname,$middlename,$address,$gender,$course,$bplace,$mother,$father,$guardian,$lastschool,$contact,$bday,$telnum);
  38.  
  39. if($stmt->execute()){
  40. echo "<script type='text/javascript'>alert('saved successfully...')</script>";
  41. } else {
  42. echo "<script type='text/javascript'> alert('Query: {$sql} failed with " . mysqli_error($connect) . "')</script>";
  43. }
  44.  
  45. // Not necessary to close connection because connection ends after each request anyway.
  46.  
  47. }
  48. ?>
Add Comment
Please, Sign In to add comment