Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.00 KB | None | 0 0
  1. <html>
  2. <head></head>
  3.  
  4. <body>
  5.  
  6. <h2>Mail</h2>
  7.  
  8. <form name="form1" method="post" action="mail.php">
  9. Send To: <input type="text" id="recipient" name="recipient">
  10. <br>
  11. Subject: <input type="text" id="subject" name="subject">
  12. <br>
  13. <input type="submit" value="Send">
  14.  
  15. </form>
  16.  
  17. </body>
  18.  
  19. </html>
  20.  
  21. <?php
  22.  
  23. $to = $_POST['recipient'];
  24. $subject = $_POST['subject'];
  25. $message = readfile("welcome.html","r") or exit ("Unable to open file");
  26. fclose($message);
  27.  
  28.  
  29. mail($to, $subject, $message);
  30.  
  31. ?>
  32.  
  33. $to = $_POST['recipient'];
  34. $subject = $_POST['subject'];
  35. $message = readfile("welcome.html","r") or exit ("Unable to open file");
  36.  
  37. $headers = "Content-type: text/htmlrn";
  38.  
  39. fclose($message);
  40.  
  41.  
  42. mail($to, $subject, $message, $headers);
  43.  
  44. <?php
  45. $statusMsg = '';
  46. $msgClass = '';
  47. if(isset($_POST['Submit'])){
  48. // Get the submitted form data
  49. $Email = $_POST['data_5'];
  50. $name = $_POST['Firstname'];
  51. $Phone = $_POST['data_6'];
  52. $file = $_POST['data_9'];
  53.  
  54. // Check whether submitted data is not empty
  55. if(!empty($Email) && !empty($name) && !empty($Phone)){
  56.  
  57. if(filter_var($Email, FILTER_VALIDATE_EMAIL) === false){
  58. $statusMsg = 'Please enter your valid Email.';
  59. $msgClass = 'errordiv';
  60. }else{
  61. // Recipient Email
  62. $toEmail = 'mydeen144@gmail.com';
  63. $emailSubject = 'Contact Request Submitted by '.$name;
  64. $htmlContent = '<h2>Contact Request Submitted</h2>
  65. <h4>Name</h4><p>'.$name.'</p>
  66. <h4>Email</h4><p>'.$Email.'</p>
  67. <h4>Phone</h4><p>'.$Phone.'</p>
  68. <h4>file</h4><p>'.$file.'</p>';
  69.  
  70. // Set content-type header for sending HTML email
  71. $headers = "MIME-Version: 1.0" . "rn";
  72. $headers .= "Content-type:text/html;charset=UTF-8" . "rn";
  73.  
  74. // Additional headers
  75. $headers .= 'From: '.$name.'<'.$Email.'>'. "rn";
  76.  
  77. // Send email
  78.  
  79. if(mail($toEmail,$emailSubject,$htmlContent,$headers)){
  80. $statusMsg = 'Your contact request has been submitted successfully !';
  81. $msgClass = 'succdiv';
  82. }else{
  83. $statusMsg = 'Your contact request submission failed, please try again.';
  84. $msgClass = 'errordiv';
  85. }
  86.  
  87.  
  88. }
  89.  
  90. }else{
  91. $statusMsg = 'Please fill all the fields.';
  92. $msgClass = 'errordiv';
  93. }
  94. }
  95. ?>
  96. <!DOCTYPE html>
  97. <head>
  98. </head>
  99. <body>
  100. <form method="post" action="" onSubmit="return validateForm();">
  101. <div style="padding-bottom: 18px;font-size : 32px;">Career</div>
  102. <h4>
  103. <?php echo $statusMsg; ?>
  104. </h4>
  105. <div style="display: flex; padding-bottom: 18px;width : 450px;">
  106. <div style=" margin-left : 0; margin-right : 1%; width : 49%;">First name<span style="color: red;"> *</span><br/>
  107. <input type="text" id="Firstname" name="Firstname" style="width: 100%;" class="form-control" required/>
  108. </div>
  109. <div style=" margin-left : 1%; margin-right : 0; width : 49%;">Last name<span style="color: red;"> *</span><br/>
  110. <input type="text" id="data_4" name="data_4" style="width: 100%;" class="form-control"required/>
  111. </div>
  112. </div>
  113. <div style="padding-bottom: 18px;">Email<span style="color: red;"> *</span><br/>
  114. <input type="text" id="data_5" name="data_5" style="width : 450px;" class="form-control" required/>
  115. </div>
  116. <div style="padding-bottom: 18px;">Phone<span style="color: red;"> *</span><br/>
  117. <input type="text" id="data_6" name="data_6" style="width : 450px;" class="form-control" pattern="^d{10}$" required/>
  118. </div>
  119. <div style="padding-bottom: 18px;">Resume upload<br/>
  120. <input id="data_9" name="data_9" style="width : 450px;" type="file" class="form-control" required/>
  121. </div>
  122. <div style="padding-bottom: 18px;"><input name="Submit" value="Submit" type="submit" /></div>
  123. </form>
  124. </body>
  125. </html>
  126. <script type="text/javascript">
  127. function validateForm() {
  128. if (isEmpty(document.getElementById('Firstname').value.trim())) {
  129. alert('First name is required!');
  130. return false;
  131. }
  132. if (isEmpty(document.getElementById('data_4').value.trim())) {
  133. alert('Last name is required!');
  134. return false;
  135. }
  136. if (isEmpty(document.getElementById('data_5').value.trim())) {
  137. alert('Email is required!');
  138. return false;
  139. }
  140. if (!validateEmail(document.getElementById('data_5').value.trim())) {
  141. alert('Email must be a valid email address!');
  142. return false;
  143. }
  144.  
  145. if (!validatefile(document.getElementById('data_9').value.trim())) {
  146. alert('File is required!');
  147. return false;
  148. }
  149. if (isEmpty(document.getElementById('data_6').value.trim())) {
  150. alert('Phone is required!');
  151. return false;
  152. }
  153. return true;
  154. }
  155. function validatefile(file) {
  156. var re = /^(([a-zA-Z]:)|(\{2}w+)$?)(\(w[w].*))+(.doc|.docx|.DOC|.DOCX|.txt|.TXT)$/i;
  157. return isEmpty(file) || re.test(file);
  158. }
  159. function isEmpty(str) { return (str.length === 0 || !str.trim()); }
  160. function validateEmail(email) {
  161.  
  162. var re = /^([w-]+(?:.[w-]+)*)@((?:[w-]+.)*w[w-]{0,66}).([a-z]{2,15}(?:.[a-z]{2})?)$/i;
  163. return isEmpty(email) || re.test(email);
  164.  
  165. }
  166. </script>
  167.  
  168.  
  169. this is my code how i insert commands for Attached file to mail sending?... pls i want immediately ans pls reply me
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement