Guest User

Untitled

a guest
Aug 20th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.85 KB | None | 0 0
  1. <div class="container cart ">
  2. <form name="checkout" method="post" id="myForm" class="needs-validation" action="" novalidate="novalidate" onSubmit="clearField();">
  3. <div class="row ">
  4.  
  5. <div class="col-sm-12 col-md-10 col-md-offset-1 ctabl">
  6. <table class="table table-responsive-sm w-100 table-hover" id="table" name="table">
  7. <thead>
  8. <tr>
  9. <th>Tuote</th>
  10. <th>Määrä</th>
  11. <th class="text-center">Hinta</th>
  12. <th class="text-center">Yhteensä</th>
  13. <th> </th>
  14. </tr>
  15. </thead>
  16. <tbody id="cart-items" name="items">
  17. </tbody>
  18. <tfoot>
  19. <tr>
  20. <td><a href="javascript:;" onClick="document.location.reload(true)" class="btn btn-danger" data-cesta-feira-clear-basket>Poista kaikki</a></td>
  21. <td>  </td>
  22. <td>Kokonaishinta</td>
  23. <td class="text-right" id="total-value"><strong>€0</strong></td>
  24. <td>  </td>
  25. </tr>
  26.  
  27. </tfoot>
  28. </table>
  29. </div>
  30. </div>
  31. <div class="row tabl">
  32. <div class="col-md-4 order-md-2 mb-4 textarea">
  33. <div class="form-group">
  34. <label for="exampleTextarea">Tarjouspyyntö / lisätiedot (esim.tilattava määrä)</label>
  35. <textarea class="form-control" name="textarea" id="exampleTextarea" rows="15" placeholder=""></textarea>
  36. </div>
  37. </div>
  38. <div class="col-md-8 order-md-1">
  39. <h4 class="mb-3">Tarjouspyynnön lähettäjä</h4>
  40. <hr class="mb-4">
  41.  
  42.  
  43. <div class="row">
  44. <div class="col-md-6 mb-3">
  45.  
  46. <label for="firstName">Etunimi *</label>
  47. <input type="text" class="form-control" id="firstName" name="firstName" placeholder="" value="" required>
  48. <div class="invalid-feedback">
  49. Valid first name is required.
  50. </div>
  51. </div>
  52. <div class="col-md-6 mb-3">
  53. <label for="lastName">Sukunimi *</label>
  54. <input type="text" class="form-control" id="lastName" name="lastName" placeholder="" value="" required>
  55. <div class="invalid-feedback">
  56. Valid last name is required.
  57. </div>
  58. </div>
  59. </div>
  60. <div class="mb-3">
  61. <label for="companyName">Yrityksen nimi <span class="text-muted">(valinnainen)</span></label>
  62. <input type="text" class="form-control" name="companyName" id="companyName" placeholder="" value="" >
  63. <div class="invalid-feedback">
  64. Please enter a valid company name for shipping updates.
  65. </div>
  66. </div>
  67. <div class="mb-3">
  68. <label for="email">Sähköpostiosoite *</label>
  69. <input type="email" name="email" class="form-control" id="email" placeholder="you@example.fi" required="">
  70. <div class="invalid-feedback">
  71. Please enter a valid email address for shipping updates.
  72. </div>
  73. </div>
  74.  
  75. <div class="mb-3">
  76. <label for="phone">Puhelin *</label>
  77. <input type="tel" class="form-control" name="tel" id="tel" placeholder="0414826104" required>
  78. <div class="invalid-feedback">
  79. Please enter a valid email address for shipping updates.
  80. </div>
  81. </div>
  82.  
  83.  
  84.  
  85. <div class="mb-3">
  86. <label for="fileupload">Lataa kuva <span class="text-muted">(valinnainen)</span></label>
  87. <input type="file" name="fileupload" value="fileupload" id="fileupload" accept="image/png, image/jpeg">
  88. </div>
  89. <hr class="mb-4 order-3">
  90. <button class="submit-btn butt1 order-3" name="submit" id="send" type="submit" onclick="validateForm()">Pyydä tarjous</button> </div> </div> </form>
  91. <div class="status" id="status"></div>
  92.  
  93. var c = document.getElementById('#cart-items');
  94. var t = c.getContext('2d');
  95. var dataURL = c.toDataURL();
  96. $(document).ready(function () {
  97. $("#myForm").on('submit', function (e) {
  98.  
  99. e.preventDefault();
  100. $.ajax({
  101. type: 'POST',
  102. url: '../mail.php',
  103. data: {imgBase64: dataURL, $("myForm').serialize()},
  104. success: function () {
  105. alert('form was submitted');
  106. }
  107. });
  108. });
  109. });
  110.  
  111. <?php
  112. $name = $_POST['firstName'];
  113. $email = $_POST['email'];
  114. $message = $_POST['textarea'];
  115. define('UPLOAD_DIR', 'images/');
  116. $img = $_POST['img'];
  117. $img = str_replace('data:image/png;base64,', '', $img);
  118. $img = str_replace(' ', '+', $img);
  119. $data = base64_decode($img);
  120. $file = UPLOAD_DIR . uniqid() . '.png';
  121. $filee = file_put_contents($file, $data);
  122. header('Content-Type: application/json');
  123. if ($name === ''){
  124. print json_encode(array('message' => 'Name cannot be empty', 'code' => 0));
  125. exit();
  126. }
  127. if ($email === ''){
  128. print json_encode(array('message' => 'Email cannot be empty', 'code' => 0));
  129. exit();
  130. } else {
  131. if (!filter_var($email, FILTER_VALIDATE_EMAIL)){
  132. print json_encode(array('message' => 'Email format invalid.', 'code' => 0));
  133. exit();
  134. }
  135. }
  136. if ($subject === ''){
  137. print json_encode(array('message' => 'Subject cannot be empty', 'code' => 0));
  138. exit();
  139. }
  140. if ($message === ''){
  141. print json_encode(array('message' => 'Message cannot be empty', 'code' => 0));
  142. exit();
  143. }
  144. $content="From: $name nEmail: $email nMessage: $message nFile: $filee";
  145. $recipient = "pozitroniya@gmail.com";
  146. $mailheader = "From: $email rn";
  147. mail($recipient, $subject, $content, $mailheader) or die("Error!");
  148. print json_encode(array('message' => 'Email successfully sent!', 'code' => 1));
  149. exit();
  150. ?>
Add Comment
Please, Sign In to add comment