Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head></head>
- <body>
- <h2>Mail</h2>
- <form name="form1" method="post" action="mail.php">
- Send To: <input type="text" id="recipient" name="recipient">
- <br>
- Subject: <input type="text" id="subject" name="subject">
- <br>
- <input type="submit" value="Send">
- </form>
- </body>
- </html>
- <?php
- $to = $_POST['recipient'];
- $subject = $_POST['subject'];
- $message = readfile("welcome.html","r") or exit ("Unable to open file");
- fclose($message);
- mail($to, $subject, $message);
- ?>
- $to = $_POST['recipient'];
- $subject = $_POST['subject'];
- $message = readfile("welcome.html","r") or exit ("Unable to open file");
- $headers = "Content-type: text/htmlrn";
- fclose($message);
- mail($to, $subject, $message, $headers);
- <?php
- $statusMsg = '';
- $msgClass = '';
- if(isset($_POST['Submit'])){
- // Get the submitted form data
- $Email = $_POST['data_5'];
- $name = $_POST['Firstname'];
- $Phone = $_POST['data_6'];
- $file = $_POST['data_9'];
- // Check whether submitted data is not empty
- if(!empty($Email) && !empty($name) && !empty($Phone)){
- if(filter_var($Email, FILTER_VALIDATE_EMAIL) === false){
- $statusMsg = 'Please enter your valid Email.';
- $msgClass = 'errordiv';
- }else{
- // Recipient Email
- $toEmail = 'mydeen144@gmail.com';
- $emailSubject = 'Contact Request Submitted by '.$name;
- $htmlContent = '<h2>Contact Request Submitted</h2>
- <h4>Name</h4><p>'.$name.'</p>
- <h4>Email</h4><p>'.$Email.'</p>
- <h4>Phone</h4><p>'.$Phone.'</p>
- <h4>file</h4><p>'.$file.'</p>';
- // Set content-type header for sending HTML email
- $headers = "MIME-Version: 1.0" . "rn";
- $headers .= "Content-type:text/html;charset=UTF-8" . "rn";
- // Additional headers
- $headers .= 'From: '.$name.'<'.$Email.'>'. "rn";
- // Send email
- if(mail($toEmail,$emailSubject,$htmlContent,$headers)){
- $statusMsg = 'Your contact request has been submitted successfully !';
- $msgClass = 'succdiv';
- }else{
- $statusMsg = 'Your contact request submission failed, please try again.';
- $msgClass = 'errordiv';
- }
- }
- }else{
- $statusMsg = 'Please fill all the fields.';
- $msgClass = 'errordiv';
- }
- }
- ?>
- <!DOCTYPE html>
- <head>
- </head>
- <body>
- <form method="post" action="" onSubmit="return validateForm();">
- <div style="padding-bottom: 18px;font-size : 32px;">Career</div>
- <h4>
- <?php echo $statusMsg; ?>
- </h4>
- <div style="display: flex; padding-bottom: 18px;width : 450px;">
- <div style=" margin-left : 0; margin-right : 1%; width : 49%;">First name<span style="color: red;"> *</span><br/>
- <input type="text" id="Firstname" name="Firstname" style="width: 100%;" class="form-control" required/>
- </div>
- <div style=" margin-left : 1%; margin-right : 0; width : 49%;">Last name<span style="color: red;"> *</span><br/>
- <input type="text" id="data_4" name="data_4" style="width: 100%;" class="form-control"required/>
- </div>
- </div>
- <div style="padding-bottom: 18px;">Email<span style="color: red;"> *</span><br/>
- <input type="text" id="data_5" name="data_5" style="width : 450px;" class="form-control" required/>
- </div>
- <div style="padding-bottom: 18px;">Phone<span style="color: red;"> *</span><br/>
- <input type="text" id="data_6" name="data_6" style="width : 450px;" class="form-control" pattern="^d{10}$" required/>
- </div>
- <div style="padding-bottom: 18px;">Resume upload<br/>
- <input id="data_9" name="data_9" style="width : 450px;" type="file" class="form-control" required/>
- </div>
- <div style="padding-bottom: 18px;"><input name="Submit" value="Submit" type="submit" /></div>
- </form>
- </body>
- </html>
- <script type="text/javascript">
- function validateForm() {
- if (isEmpty(document.getElementById('Firstname').value.trim())) {
- alert('First name is required!');
- return false;
- }
- if (isEmpty(document.getElementById('data_4').value.trim())) {
- alert('Last name is required!');
- return false;
- }
- if (isEmpty(document.getElementById('data_5').value.trim())) {
- alert('Email is required!');
- return false;
- }
- if (!validateEmail(document.getElementById('data_5').value.trim())) {
- alert('Email must be a valid email address!');
- return false;
- }
- if (!validatefile(document.getElementById('data_9').value.trim())) {
- alert('File is required!');
- return false;
- }
- if (isEmpty(document.getElementById('data_6').value.trim())) {
- alert('Phone is required!');
- return false;
- }
- return true;
- }
- function validatefile(file) {
- var re = /^(([a-zA-Z]:)|(\{2}w+)$?)(\(w[w].*))+(.doc|.docx|.DOC|.DOCX|.txt|.TXT)$/i;
- return isEmpty(file) || re.test(file);
- }
- function isEmpty(str) { return (str.length === 0 || !str.trim()); }
- function validateEmail(email) {
- var re = /^([w-]+(?:.[w-]+)*)@((?:[w-]+.)*w[w-]{0,66}).([a-z]{2,15}(?:.[a-z]{2})?)$/i;
- return isEmpty(email) || re.test(email);
- }
- </script>
- 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