Form submission opens php page

telekineser

I have a form on html page. it has action as mailer.php. All code works properly, but on submission, page goes to mailer.php and browser shows an empty page on screen

contactus.html form tag:

<form id="form_20" action="mailer.php" method="post" target="_self" 
      enctype="multipart/form-data">
    //input fields here
</form>

mailer.php file:

<?php
$to = '---------------'; //Removed for privacy
$subject = 'New Enquiry';

$name = $_POST['Name'];
$tel = $_POST['Number'];
$email = $_POST['Email'];
$comments = $_POST['Message'];

$body = "From: $name \nNumber: $tel \nEmail id: $email \nComments: $comments";
$headers = 'FROM: ---------------------------'.PHP_EOL; //Removed for privacy
mail($to, $subject, $body, $headers);
echo '<script>alert("Your data has been submitted.");</script>';
?>

The code works fine, I get the mail too. The only problem I have is that the page redirects to mailer.php

P.S. : If anyone finds this a duplicate question, please comment the link to the question it duplicates so I get my answer. Thanks

user557846

to send the user back to the previous page:

header('Location: http://www.example.com/foo.php?back=yes'); //add your url

after the mail call, and remove the script

on foo.php

if ($_GET['back']=='yes'){
echo '<script>alert("Your data has been submitted.");</script>';
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to avoid page reload in php form submission

From Dev

php return to page after form submission

From Dev

php return to page after form submission

From Dev

How to show the success message of PHP in html page on Form submission

From Dev

Using jQuery AJAX to call a php page on form submission

From Dev

Can't get rid of blank php page after submission form

From Dev

PHP / AJAX Contact Form - Page Opens Mid-Way

From Dev

Form Submission to Self (PHP)

From Dev

PHP contact form submission

From Dev

PHP, email submission form

From Dev

How to redirect page on form submission

From Dev

Does a form refresh the page on submission?

From Dev

Form submission to incorrect URL PHP

From Dev

Form Submission through Ajax and PHP

From Dev

PHP Form Submission without a client

From Dev

Form submission using ajax and page view moderation after the submission

From Dev

php form - clear form on submission - reset it

From Dev

Using PHP form validation on jQuery form submission

From Dev

Form submission preview with form validation (PHP)

From Dev

How to show the image uploaded using HTML file control on a new page after form submission in PHP?

From Java

Redirect and refresh page on form submission in React frontend

From Dev

Display the same page even after form submission

From Dev

Form submission to api and then redirect to a specifi page

From Dev

redirecting to another page after form submission

From Dev

HTML Form Submission to Existing Web Page

From Dev

INSERT failing on Form Submission from Page

From Dev

jQuery - Loading form submission in DIV of parent page (?)

From Dev

Preventing page reload upon form submission to database

From Dev

php coding Form submission to server using php

Related Related

  1. 1

    How to avoid page reload in php form submission

  2. 2

    php return to page after form submission

  3. 3

    php return to page after form submission

  4. 4

    How to show the success message of PHP in html page on Form submission

  5. 5

    Using jQuery AJAX to call a php page on form submission

  6. 6

    Can't get rid of blank php page after submission form

  7. 7

    PHP / AJAX Contact Form - Page Opens Mid-Way

  8. 8

    Form Submission to Self (PHP)

  9. 9

    PHP contact form submission

  10. 10

    PHP, email submission form

  11. 11

    How to redirect page on form submission

  12. 12

    Does a form refresh the page on submission?

  13. 13

    Form submission to incorrect URL PHP

  14. 14

    Form Submission through Ajax and PHP

  15. 15

    PHP Form Submission without a client

  16. 16

    Form submission using ajax and page view moderation after the submission

  17. 17

    php form - clear form on submission - reset it

  18. 18

    Using PHP form validation on jQuery form submission

  19. 19

    Form submission preview with form validation (PHP)

  20. 20

    How to show the image uploaded using HTML file control on a new page after form submission in PHP?

  21. 21

    Redirect and refresh page on form submission in React frontend

  22. 22

    Display the same page even after form submission

  23. 23

    Form submission to api and then redirect to a specifi page

  24. 24

    redirecting to another page after form submission

  25. 25

    HTML Form Submission to Existing Web Page

  26. 26

    INSERT failing on Form Submission from Page

  27. 27

    jQuery - Loading form submission in DIV of parent page (?)

  28. 28

    Preventing page reload upon form submission to database

  29. 29

    php coding Form submission to server using php

HotTag

Archive