Once I got a weird trouble with submitting contact form.
My website was powered by WordPress and the contact form was placed at the default page (single page design), so I want the form to submit to the page itself that the form is on.
<form action="<?php bloginfo('template_url'); ?>/php-form-submit.php/" method="post">
File php-form-submit.php sends the form (and placed at the theme directory). After successful validation and emailing the form I would like to open ‘Thank you’ page.
It’s enough to get the URL with bloginfo(‘template_url’) for WordPress usually:
header('Location: ' . bloginfo('template_url') . '/thank-you/');
(where is ‘thank-you’ – my ‘Thank you’ page). Strangely, I got fatal error here – the function bloginfo() was undefined.
I used HTTP_HOST.
$_SERVER[‘HTTP_HOST’] gives the domain name through which the current request is being fulfilled and relates directly to the request:
header('Location: http://' . $_SERVER['HTTP_HOST'] . '/thank-you/');
works like a charm.