I have a problems with receiving data from forms on the website. i mean, after successfuly registration user have to see string like this: Hello "name", but instead of this i receive all strings, but every string have to be special for every new user. How can i do this with session? Help. Thanks.
The header
function is used to redirect.
<?php header('Location: thispage.php'); ?>
Include this line in the page from which you want to redirect to thispage.php
.
Or in case If you have the URL in some variable so write like this
<?php header('Location: '.$URL); ?>
Do not add unnecessary NewLine
on the top of the page, or the header
function will not work and return header have already been sent.
This is a good method to perform a redirection that works in all situations:
// $url contains the page to which you want to redirect the user
function redirect($url)
{
if (!headers_sent())
header('Location: '.$url);
else
{
echo '<script type="text/javascript">';
echo 'window.location.href="'.$url.'";';
echo '</script>';
echo '<noscript>';
echo '<meta http-equiv="refresh" content="0;url='.$url.'"/>';
echo '</noscript>';
}
exit();
}
Use it once the user registration is completed:
redirect('successfull_registration.php');