Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. $Sno= $_POST['Sno'];
  2. $Clientname= $_POST['Clientname'];
  3. $Contactno = $_POST['Contactno'];
  4. $Dos= $_POST['Dos'];
  5. $Start= $_POST['Start'];
  6. $End= $_POST['End'];
  7. $Dow= $_POST['Dow'];
  8. $Osi= $_POST['Osi'];
  9. $Emhr= $_POST['Emhr'];
  10. $Er= $_POST['Er'];
  11. $Mir= $_POST['Mir'];
  12. $Ea= $_POST['Ea'];
  13. $Cr= $_POST['Cr'];
  14. $Mir1= $_POST['Mir1'];
  15. $Am= $_POST['Am'];
  16. $Ca= $_POST['Ca'];
  17. $Date= $_POST['Date'];
  18. $Image= $_Post['image'];
  19.  
  20. $sql= "INSERT INTO surveyform(Sno, Clientname, Contactno, Dos, Start, End, Dow, Osi, Emhr, Er, Mir, Ea, Cr, Mir1, Am, Ca, Date)
  21. VALUES('$Sno', '$Clientname', '$Contactno', '$Dos','$Start', '$End', '$Dow', '$Osi', '$Emhr', '$Er','$Mir', '$Ea', '$Cr', '$Mir1', '$Am', '$Ca', '$Date' )";
  22.  
  23. if(!mysql_query($sql))
  24. {
  25. die('caution record not added' . mysql_error());
  26. }
  27. echo"1 record added";
  28.  
  29.  
  30.  
  31.  
  32.  
  33. $target_dir = "images/";
  34. $target_file = $target_dir . basename($_FILES["image"]["name"]);
  35. $uploadOk = 1;
  36. $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  37. // Check if image file is a actual image or fake image
  38. if(isset($_POST["submit"])) {
  39. $check = getimagesize($_FILES["image"]["tmp_name"]);
  40. if($check !== false) {
  41. echo "File is an image - " . $check["mime"] . ".";
  42. $uploadOk = 1;
  43. } else {
  44. echo "File is not an image.";
  45. $uploadOk = 0;
  46. }
  47. }
  48. // Check if file already exists
  49. if (file_exists($target_file)) {
  50. echo "Sorry, file already exists.";
  51. $uploadOk = 0;
  52. }
  53.  
  54. // Check file size
  55. if ($_FILES["image"]["size"] > 500000) {
  56. echo "Sorry, your file is too large.";
  57. $uploadOk = 0;
  58. }
  59.  
  60. // Allow certain file formats
  61. if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
  62. && $imageFileType != "gif" ) {
  63. echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
  64. $uploadOk = 0;
  65. }
  66. // Check if $uploadOk is set to 0 by an error
  67. if ($uploadOk == 0) {
  68. echo "Sorry, your file was not uploaded.";
  69. // if everything is ok, try to upload file
  70. } else {
  71. if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
  72. echo "The file ". basename( $_FILES["image"]["name"]). " has been uploaded.";
  73. } else {
  74. echo "Sorry, there was an error uploading your file.";
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement