Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. //CONTENTS OF TIMEOFFREQUEST.PHP
  2.  
  3.  
  4. <?php
  5. $input=array("name","store","department","start","end","reason");
  6. $error=array("nameErr","storeErr","departmentErr","startErr","endErr","reasonErr");
  7. $input = "";
  8. $error = "";
  9.  
  10. var_dump($_POST);
  11.  
  12. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  13. $missing_data = false;
  14. //check all values.
  15. //if missing info, show an error and display the form again
  16. if(empty($_POST["name"])){
  17. $nameErr = "Name is required.";
  18. $missing_data = true;
  19. }
  20. else {
  21. $name = test_input($_POST["name"]);
  22. }
  23. if(empty($_POST["store"])){
  24. $storeErr = "Store is required.";
  25. $missing_data = true;
  26. }
  27. else {
  28. $store = test_input($_POST["store"]);
  29. }
  30. if(empty($_POST["department"])){
  31. $departmentErr = "Department is required.";
  32. $missing_data = true;
  33. }
  34. else {
  35. $department = test_input($_POST["department"]);
  36. }
  37. if(empty($_POST["start"])){
  38. $startErr = "Start date is required.";
  39. $missing_data = true;
  40. }
  41. else {
  42. $start = test_input($_POST["start"]);
  43. }
  44. if(empty($_POST["end"])){
  45. $endErr = "End date is required.";
  46. $missing_data = true;
  47. }
  48. else {
  49. $end = test_input($_POST["end"]);
  50. }
  51. if(empty($_POST["reason"])){
  52. $reasonErr = "Reason is required.";
  53. $missing_data = true;
  54. }
  55. else {
  56. $reason = test_input($_POST["reason"]);
  57. }
  58. //else store data, email to manager, and redirect to timeoffsubmission.php
  59. if ($missing_data == false){
  60. session_start();
  61. $_SESSION["name"] = $name;
  62.  
  63. header("Location: http://OMITTED/forms/handling/timeoffsubmission.php?success=yes");
  64.  
  65. }
  66. else {
  67. echo htmlspecialchars($_SERVER["PHP_SELF"]);
  68. }
  69. }
  70.  
  71.  
  72. function test_input($data)
  73. {
  74. $data = trim($data);
  75. $data = stripslashes($data);
  76. $data = htmlspecialchars($data);
  77. return $data;
  78. }
  79.  
  80. ?>
  81.  
  82.  
  83. //CONTENTS OF TIMEOFFSUBMISSION.PHP
  84.  
  85. <?php
  86.  
  87. session_start();
  88.  
  89. if ($_GET['success'] == 'yes')
  90. {
  91. echo "Thank you ". $_SESSION["name"];
  92. }
  93.  
  94. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement