wp_redirect() not working in Insert PHP plugin in WordPress

/This is my code in Insert php pluggin. I have added this php snippet generated by the plugin in a page in WordPress. The wp_redirect is not working with this snippet./
// define variables and set to empty values
$emailErr = $passwordErr = “”;
$email = $password = “”;

function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}

if ($_SERVER[“REQUEST_METHOD”] == “POST”) {
if (empty($_POST[“email”])) {
$emailErr = “Email is required”;
}
else {
$email = test_input($_POST[“email”]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = “Invalid email format”;
}
}

if (empty($_POST[“password”])) {
$passwordErr = “Password is required”;
} else {
$password = test_input($_POST[“password”]);
// check if URL address syntax is valid (this regular expression also allows dashes in the URL)
//if (!preg_match(“/b(?:(?:https?|ftp)://|www.)[-a-z0-9+&@#/%?=~|!:,.;]*[-a-z0-9+&@#/%=~|]/i”,$website)) {
// $websiteErr = “Invalid URL”;
//}

if ($emailErr == “” && $passwordErr == “”)
{
wp_redirect(“https://grenstonhrs.000webhostapp.com“,301);
exit;
}
}

}

?>

Email

” />

Password

Sign Up

Read more here:: wp_redirect() not working in Insert PHP plugin in WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *