Advertisement
Guest User

Untitled

a guest
Dec 16th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.95 KB | None | 0 0
  1. $_SESSION['tsmUserName']=$username;
  2.  
  3. $ids=$_SESSION['tsmUserName'];
  4.  
  5. <?php
  6. $firstnameError = $lastnameError = $usernameError = $passwordError = $birthdateError = $mobileError = $emailError = "";
  7. // Check if data are posted.
  8. if (isset($_POST['submit'])){
  9. $firstname = $lastname = $username = $password = $birthdate = $mobile = $email = "";
  10. $errorOccured = false;
  11.  
  12. if (isset($_POST['tsmFirstName'])){
  13. $firstname = trim($_POST['tsmFirstName']);
  14. if (strlen($firstname) == 0){
  15. $firstnameError = "First Name is missing";
  16. $errorOccured = true;
  17. }
  18. }
  19. else{
  20. $firstnameError = "First Name is missing";
  21. }
  22.  
  23. //Checking last name
  24. if (isset($_POST['tsmLastName'])){
  25. $lastname = trim($_POST['tsmLastName']);
  26. if (strlen($lastname) == 0){
  27. $lastnameError = "First Name is missing";
  28. $errorOccured = true;
  29. }
  30. }
  31. else{
  32. $lastnameError = "First Name is missing";
  33. }
  34.  
  35. //checking the username
  36. if (isset($_POST['tsmUserName'])){
  37. $username = trim($_POST['tsmUserName']);
  38. $usernameLenght = strlen($username);
  39. if ($usernameLenght == 0){
  40. $usernameError = "First Name is missing";
  41. $errorOccured = true;
  42. }
  43. elseif ($usernameLenght < 4){
  44. $usernameError = "Your username should be minimum 4 characters";
  45. $errorOccured = true;
  46. }
  47. }
  48. else{
  49. $usernameError = "First Name is missing";
  50. }
  51.  
  52.  
  53. //checking the password
  54. if (isset($_POST['tsmPassword'])){
  55. $password = trim($_POST['tsmPassword']);
  56. if (strlen($password) == 0){
  57. $passwordError = "First Name is missing";
  58. $errorOccured = true;
  59. }
  60. }
  61. else{
  62. $passwordError = "First Name is missing";
  63. }
  64.  
  65. //checking the birthdate
  66. if (isset($_POST['tsmBirthDate'])){
  67. $birthdate = trim($_POST['tsmBirthDate']);
  68. if (strlen($birthdate) == 0){
  69. $birthdateError = "First Name is missing";
  70. $errorOccured = true;
  71. }
  72. }
  73. else{
  74. $birthdateError = "First Name is missing";
  75. }
  76.  
  77. // checking the mobile
  78. if (isset($_POST['tsmMobile'])){
  79. $mobile = trim($_POST['tsmMobile']);
  80. if (strlen($mobile) == 0){
  81. $mobileError = "First Name is missing";
  82. $errorOccured = true;
  83. }
  84. }
  85. else{
  86. $mobileError = "Mobile is missing";
  87. }
  88.  
  89. //checking the email
  90. if (isset($_POST['tsmEmail'])){
  91. $email = trim($_POST['tsmEmail']);
  92. if (strlen($email) == 0){
  93. $emailError = "Email is missing";
  94. $errorOccured = true;
  95. }
  96. }
  97. else{
  98. $emailError = "Email is missing";
  99. }
  100.  
  101.  
  102. if(!$errorOccured){
  103. require_once("connection.php");
  104.  
  105. $_SESSION['tsmUserName']=$username;
  106. $names=$_SESSION['tsmFirstName'];
  107. var_dump($_SESSION);
  108. $keychain= sha1($username);
  109. $my_query="INSERT INTO users (id, firstname, lastname, username, password, birthdate, mobile, email, status, keychain) VALUES (NULL,'$firstname','$lastname','$username','$password','2016-1-1','$mobile','$email','0','$keychain')";
  110. $result=mysqli_query($connection,$my_query);
  111. if($result){
  112. $message_mail = "Dear $firstname, <br> Thank You for registering with us. Click now on the link below to activate your account. <br> $keychain <br><br> Thank You.";
  113. $subject_mail= "Your account has been created";
  114. $to_mail = $email;
  115. $headers[]= 'MIME-Version 1.0';
  116. $headers[]= 'content-type:text/html; charset=utf8';
  117. $headers[]= 'From: admin@tassimo.com';
  118. mail($to_mail,$subject_mail,$message_mail,implode("rn",$headers));
  119. //after email is sent redirect to thank you page.
  120. header("Location:completed.php?task=done");
  121. exit();
  122. echo 'Thank You';
  123. }
  124. else{
  125. echo "<b> Error unable to post. </b>";
  126. mysqli_error($connection);
  127. }
  128. mysqli_close($connection);
  129. }
  130.  
  131. }
  132.  
  133.  
  134. ?>
  135.  
  136. <?php
  137. session_start();
  138. $EntryError=$ExitError="";
  139. if (isset($_POST['submit'])){
  140. $entrydate = $exitdate = "";
  141. $errorOccured = false;
  142.  
  143. if (isset($_POST['tsmdate'])){
  144. $entrydate = trim($_POST['tsmdate']);
  145. if (strlen($entrydate) == 0){
  146. $EntryError = "date is missing";
  147. $errorOccured = true;
  148. }
  149. }
  150. else{
  151. $EntryError = "date is missing";
  152. }
  153.  
  154. // checking for last name
  155. if (isset($_POST['tsmexit'])){
  156. $exitdate = trim($_POST['tsmexit']);
  157. if (strlen($exitdate) == 0){
  158. $ExitError = "First Name is missing";
  159. $errorOccured = true;
  160. }
  161. }
  162. else{
  163. $ExitError = "last Name is missing";
  164. }
  165. $ids=$_SESSION['tsmUserName'];
  166.  
  167. var_dump($_SESSION);
  168. if(!$errorOccured){
  169. require_once("connection.php");
  170. $my_query="INSERT INTO timing (`No`, `Entry Date and Time`, `Exit Date and Time`, `Username`) VALUES (NULL,'$EntryError','$exitdate','$ids')";
  171. $result=mysqli_query($connection,$my_query);
  172. if($result)
  173. {
  174. echo 'thank you';
  175. }
  176. else
  177. {
  178. echo 'error';
  179. }
  180. mysqli_close($connection);
  181. }
  182. }
  183. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement