'I need to redirect an email form in PHP Script to another page once the form is sent
friends of Stack overflow, what happens is that I have an email form in PHP Script and the idea is that once one sent the message successfully, I redirect you to a page, in my case I want to redirect users to a "Thank you" page.
I have managed that once the message is sent, a green box appears saying "Thank you for sending your message" and when it is not sent, an error box comes out, but I have not managed to redirect once it was successfully sent to a "Thank you" page.
This is the code
<?php
require_once('FormProcessor.php');
$form = array(
'subject' => 'New Form Submission',
'email_message' => 'You have a new form submission',
'success_redirect' => '',
'sendIpAddress' => true,
'email' => array(
'from' => '',
'to' => '[email protected]'
),
'fields' => array(
'name' => array(
'order' => 1,
'type' => 'string',
'label' => 'Name',
'required' => true,
'errors' => array(
'required' => 'Field \'Name\' is required.'
)
),
'email' => array(
'order' => 2,
'type' => 'email',
'label' => 'Email',
'required' => true,
'errors' => array(
'required' => 'Field \'Email\' is required.'
)
),
'message' => array(
'order' => 3,
'type' => 'string',
'label' => 'Message',
'required' => true,
'errors' => array(
'required' => 'Field \'Message\' is required.'
)
),
)
);
$processor = new FormProcessor('');
$processor->process($form);
?>
this is the html
Name Email Message Submit Thank you! Your message has been sent. Unable to send your message. Please fix errors then try again.Solution 1:[1]
use this header("Location: https://somewahere.com/thankYouPage.php");die();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rootShiv |
