Guest User

Untitled

a guest
Oct 26th, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.90 KB | None | 0 0
  1. <?php
  2. include"db.php";
  3.  
  4.  
  5. if (isset($_POST['Submit']))
  6. {
  7.  
  8.  
  9. $errors = array();
  10.  
  11.  
  12. $gym_name=mysqli_real_escape_string($conn,$_POST["name"]);
  13. $gym_email=mysqli_real_escape_string($conn,$_POST["email"]);
  14. $gym_contact=mysqli_real_escape_string($conn,$_POST["gym_contact_number"]);
  15. $gym_address=mysqli_real_escape_string($conn,$_POST["address"]);
  16. $gym_city=mysqli_real_escape_string($conn,$_POST["city"]);
  17. $gym_area=mysqli_real_escape_string($conn,$_POST["area"]);
  18. $gym_proximity=mysqli_real_escape_string($conn,$_POST["proximity"]);
  19. $open_time=mysqli_real_escape_string($conn,$_POST["open_time"]);
  20. $end_time=mysqli_real_escape_string($conn,$_POST["end_time"]);
  21.  
  22. $day=mysqli_real_escape_string($conn,$_POST["day"]);
  23.  
  24.  
  25. $admin_name=mysqli_real_escape_string($conn,$_POST["owner_name"]);
  26. // $admin_email=mysqli_real_escape_string($conn,$_POST["owner_email"]);
  27. $admin_contact=mysqli_real_escape_string($conn,$_POST["owner_contact"]);
  28. $admin_username=mysqli_real_escape_string($conn,$_POST["user_name"]);
  29. $admin_password=mysqli_real_escape_string($conn,$_POST["password_1"]);
  30. $expiry_date=mysqli_real_escape_string($conn,$_POST["expiry_date"]);
  31. $description=mysqli_real_escape_string($conn,$_POST["description"]);
  32.  
  33. $Sucess = "Gym Successfully Added";
  34. // $error = "Gym Successfully Added";
  35.  
  36.  
  37.  
  38.  
  39. $images_arr = array();
  40.  
  41. if (count($_FILES["image"]['name']) <=5)
  42. {
  43. //check if any file uploaded
  44. // $GLOBALS['msg'] = ""; //initiate the global message
  45. $ccount =count($_FILES["image"]['name']);
  46. for($j=0; $j < $ccount; $j++)
  47. { //loop the uploaded file array
  48. $filename = $_FILES["image"]['name']["$j"]; //file name
  49. $tmp_name = $_FILES["image"]["tmp_name"]["$j"];
  50.  
  51.  
  52. // $path = 'images/'.$filen; //generate the destination path
  53.  
  54. $fileinfo = getimagesize($tmp_name);
  55. $filewidth = $fileinfo[0];
  56. $fileheight = $fileinfo[1];
  57.  
  58.  
  59. if ( $filewidth < 1220 && $fileheight < 710 ) {
  60.  
  61. $error="Please Check Image Dimensions ";
  62. $_SESSION["error"] = $error;
  63. header('Location:gym_registration_form.php');
  64.  
  65.  
  66. } else {
  67.  
  68. $extension= pathinfo($filename,PATHINFO_EXTENSION);
  69.  
  70. //setting file path
  71. $i=$j+1;
  72. $extra ="image".$i."-";
  73. // echo $extra;
  74. $name = "gym_image/";
  75. //assigning a unique name to the image to avoid duplication
  76. $uniquesavename=time().uniqid(rand());
  77. //concatinating the file path and name with the extension
  78. $destFile = $name.$extra.$gym_name . $gym_area . $uniquesavename . ".".$extension;
  79.  
  80. echo $destFile;
  81.  
  82.  
  83. $images_arr[] = $destFile;
  84.  
  85. // echo count($images_arr);
  86.  
  87. move_uploaded_file($tmp_name,$destFile);
  88.  
  89. }
  90. }
  91. if (count($images_arr) == 1){
  92. $file1 = $images_arr[0];
  93. $file2 = '0';
  94. $file3 = '0';
  95. $file4 = '0';
  96. $file5 = '0';
  97. }elseif (count($images_arr) == 2) {
  98. $file1 = $images_arr[0];
  99. $file2 = $images_arr[1];
  100. $file3 = '0';
  101. $file4 = '0';
  102. $file5 = '0';
  103. } elseif (count($images_arr) == 3)
  104. {
  105. $file1 = $images_arr[0];
  106. $file2 = $images_arr[1];
  107. $file3 = $images_arr[2];
  108. $file4 = '0';
  109. $file5 = '0';
  110. } elseif (count($images_arr) == 4)
  111. {
  112. $file1 = $images_arr[0];
  113. $file2 = $images_arr[1];
  114. $file3 = $images_arr[2];
  115. $file4 = $images_arr[3];
  116. $file5 = '0';
  117. } elseif (count($images_arr) == 5)
  118. {
  119. $file1 = $images_arr[0];
  120. $file2 = $images_arr[1];
  121. $file3 = $images_arr[2];
  122. $file4 = $images_arr[3];
  123. $file5 = $images_arr[4];
  124. } else
  125. {
  126. $file1 = '0';
  127. $file2 = '0';
  128. $file3 = '0';
  129. $file4 = '0';
  130. $file5 = '0';
  131. }
  132.  
  133.  
  134.  
  135. $search="INSERT INTO fh_gym_list( admin_name,username,password,role,address,city,area,proximity, gym_description,email_id,contact_no,contact_person,open_time,end_time,day,disable_flag,regi_date,expiry_date,updated_flag,image1, image2,image3, image4, image5) VALUES ('$gym_name','$admin_username','$admin_password','admin','$gym_address','$gym_city','$gym_area','$gym_proximity','$description','$gym_email','$gym_contact','$admin_name','$open_time','$end_time','$day','0',NOW(),'$expiry_date','0','$file1','$file2','$file3','$file4','$file5')";
  136.  
  137. mysqli_query($conn,$search);
  138.  
  139. // for getting the ladt id of the insert query
  140. $last_id = mysqli_insert_id($conn);
  141.  
  142. //Inserting facility data in facility track table
  143.  
  144. if (isset($_POST['activityname']))
  145. {
  146. $stmt = $conn->prepare("INSERT INTO fh_gym_activity (gym_id,activity_id,disable_flag) VALUES( ?, ?, ?)");
  147. $stmt->bind_param("sss", $gym_id,$activity_id,$disable_flag);
  148.  
  149.  
  150. foreach ( $_POST['activityname'] as $selectedOption)
  151. {
  152. $gym_id=$last_id;
  153.  
  154. $activity_id=$selectedOption;
  155. //pending using select statement
  156.  
  157. $disable_flag='0';
  158. /*use session*/
  159. // $activity_id=$;
  160. $stmt->execute();
  161.  
  162.  
  163. //echo $selectedOption."\n";
  164. }
  165.  
  166.  
  167. }
  168. $_SESSION["Sucess"] = $Sucess;
  169. header('Location:gym_list.php');
  170.  
  171. mysqli_close($conn);
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179. } else{
  180. $_SESSION["error"] = $error;
  181. header('Location:gym_registration_form.php');
  182.  
  183. mysqli_close($conn);
  184.  
  185. }
  186. }
  187. else{
  188. echo "error";
  189.  
  190. }
  191.  
  192.  
  193. //$insert1="INSERT INTO gym_track_facility (facility_id,gym_id,added_datetime,added_by) VALUES ()";
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200. ?>
Add Comment
Please, Sign In to add comment