# PHP Question

**URL:** <https://www.phphelp.com/t/php-question/25857>\
**Category:** Comments and Questions\
**Created:** [April 26, 2017, 8:08am UTC](https://www.phphelp.com/t/php-question/25857 "2017-04-26T08:08:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sa11435](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/e68b1a/32.png) [@sa11435](https://www.phphelp.com/u/sa11435)\
**Post date:** [April 26, 2017, 8:08am UTC](https://www.phphelp.com/t/php-question/25857/1 "2017-04-26T08:08:37Z")

</div>

I created a form and also done with email also.But Now issue is when form is submitted then details to be sent to email and also file to be downloaded automatically when mail is sent.File is located in folder only. So the file in that folder to be downloaded when click on submit button.

---

<div class="post-metadata">

**Author:** ![astonecipher](https://www.phphelp.com/user_avatar/www.phphelp.com/astonecipher/32/2797_2.png) [@astonecipher](https://www.phphelp.com/u/astonecipher)\
**Post date:** [April 26, 2017, 2:14pm UTC](https://www.phphelp.com/t/php-question/25857/2 "2017-04-26T14:14:16Z")

</div>

Code?

---

<div class="post-metadata">

**Author:** ![sa11435](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/e68b1a/32.png) [@sa11435](https://www.phphelp.com/u/sa11435)\
**Post date:** [April 27, 2017, 5:28am UTC](https://www.phphelp.com/t/php-question/25857/3 "2017-04-27T05:28:55Z")

</div>

[php]  
  
  
\<input type=“mobile” for="mobile"placeholder=“Mobile\* (include ISD code)” required\>

For details/demo

  
[/php]

---

<div class="post-metadata">

**Author:** ![sa11435](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/e68b1a/32.png) [@sa11435](https://www.phphelp.com/u/sa11435)\
**Post date:** [April 27, 2017, 5:32am UTC](https://www.phphelp.com/t/php-question/25857/4 "2017-04-27T05:32:26Z")

</div>

[php]  
  
  
\<input type=“mobile” for="mobile"placeholder=“Mobile\* (include ISD code)” required\>

For details/demo

Here is form.php code

\<?php if(isset($\_POST['send'])) { $to = 'xxxxxx'; $from\_email = $\_POST['email']; //sender email $subject = 'Enquiry Form'; $headers = "From: " . $from\_email . "\r\n"; $headers .= "Reply-To: ". strip\_tags($\_POST['email']) . "\r\n" ."X-Mailer: PHP/" . phpversion(); $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; // PREPARE THE BODY OF THE MESSAGE $message = ''; $message .= ''; $message .= ""; $message .= ""; $message .= ""; $message .= ""; $message .= ""; $message .= ""; if(mail($to,$subject,"",$header)){ echo "success"; }else{ echo "fail"; } $message .= "

| **Name :** | " . strip\_tags($\_POST['name']) . " |
| **Name :** | " . strip\_tags($\_POST['name2']) . " |
| **Mobile No:** | " . strip\_tags($\_POST['mobile']) . " |
| **Email:** | " . strip\_tags($\_POST['email']) . " |
| **Location:** | " . strip\_tags($\_POST['location']) . " |
| **Your Comments:** | " . strip\_tags($\_POST['comment']) . " |

"; $message .= ""; //echo $message; //die(); if (mail($to, $subject, $message, $headers)){ $success = " Thanks for Your Feedback. "; }else{ $success = "Message Sending Failed, try again"; } if (mail($to, $subject, $message, $headers)){ $success = " Thanks for Your Feedback. "; }else{ $success = "Message Sending Failed, try again"; } ?\>

```
        <?php

```

}  
?\>

[/php]

---

<div class="post-metadata">

**Author:** ![astonecipher](https://www.phphelp.com/user_avatar/www.phphelp.com/astonecipher/32/2797_2.png) [@astonecipher](https://www.phphelp.com/u/astonecipher)\
**Post date:** [April 27, 2017, 11:30am UTC](https://www.phphelp.com/t/php-question/25857/5 "2017-04-27T11:30:37Z")

</div>

I am going to use JQuery for this exercise.

[php]\<!doctype html\>

  

For details/demo Here

 [/php]

Now, what you need to do, aside from change your PHP to not need the actual button clicked, is to trap the click event on the link, and redirect it to click something else, the button. Then, everything works in series.

---

<div class="post-metadata">

**Author:** ![sa11435](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/e68b1a/32.png) [@sa11435](https://www.phphelp.com/u/sa11435)\
**Post date:** [April 27, 2017, 11:49am UTC](https://www.phphelp.com/t/php-question/25857/6 "2017-04-27T11:49:44Z")

</div>

Oh Thank q for Your Support…
