In WordPress, after form submission I am trying to redirect to another page, but I cannot with the following:
if(isset($_POST['name']))
{
$q=mysql_query("INSERT INTO `contactsus` (name, email, location, mobile, subject, comment, created) VALUES('$name', '$email', '$location', '$mobile', '$subjct', '$comment', '".time()."') ");
if($q)
{
echo '{"responce":"1","message":"Thanks for the registration","url":"'.$_SESSION['SITE_URL'].student.'"}';
}
else
{
echo '{"responce":"0","message":"Your registration request has been failed due to system error"}';
}
}
The result of this code is:
{
"responce":"1",
"message":"Thanks for the registration",
"url":"http://localhost/manishatutors/student"
}
For that you can use wp_safe-redirect function of WordPress, which Performs a safe (local) redirect, using
wp_redirect()
.for the redirect in wordpress you can use