-2

I made a form in php and after submitting the form, I wanna redirect to aboutus page, the form is working fine and Im getting proper mail but I just need redirection.

here is my code

<?php if (isset($_POST['submit'])) { $to = "myemailhere@mail.com"; $from = $_POST['email']; $name = $_POST['name']; $phone = $_POST['phone']; $email = $_POST['email']; $subject = $_POST['subject']; $subject = "Form submission"; $message = "Query Request from:" . "\n\n" . "Name : " . $_POST['name'] . "\n\n" . "Email : " . $_POST['email'] . "\n\n" . "Number : " . $_POST['phone'] . "\n\n" . "Subject : " . $_POST['subject'] . "\n\n" . "Message : " . $_POST['message']; $headers = "From:" . $from; $headers2 = "From:" . $to; mail($to, $subject, $message, $headers); mail($from, $subject2, $message2, $headers2); echo '<script type="text/javascript">'; echo ' alert("Mail Sent. Thank you, we will contact you shortly.")'; //not showing an alert box. redirect('/index.php'); echo '</script>'; } ?>

Reacting
  • 3
  • 3
  • 1
    Does this answer your question? [How do I make a redirect in PHP?](https://stackoverflow.com/questions/768431/how-do-i-make-a-redirect-in-php) – Don't Panic Mar 23 '23 at 08:08

1 Answers1

0

The do a redirection in php, you need to use the function header('Location: '.$newURL.php);.

Have a good day.