Hi I am trying to redirect to a form page however I got the following message
ERR_TOO_MANY_REDIRECTS
I have been able to figure that
header('Location: http://localhost:8888/wordpress/send');
is causing the error I have tried a number of different things including adding exit underneath the final line of code but it still seems to be looping.
<?php
/*
Template Name: Send
*/
?>
<?php
session_start();
require_once(get_template_directory().'/vendor/PHPMailer/PHPMailerAutoload.php');
$errors = [];
if(isset($_POST['customername'], $_POST['email'], $_POST['message'])) {
$fields = [
'name' => $_POST['customername'],
'email' => $_POST['email'],
'message' => $_POST['message']
];
foreach ($fields as $field => $data) {
if (empty($data)) {
$errors[] = 'The ' . $field . ' field is required';
}
}
} else {
$errors[] = 'Something went wrong.';
}
header('Location: http://localhost:8888/wordpress/send');
exit();