I have a real problem and it's syntax problem. Normally when I need redirect any page I just use header function. Sometimes I use a variable when I need like below:
if(condition) header("Location: home.php?wrong=1");
Sometimes it could be:
if(condition) header("Location: home.php?wrong=1&&success=2");
There is no problem with direct use of variable(wrong or success). And when I need redirect a value from html form via post method, I use this code and it works:
if (condition) header("Location: home.php?id=".$_POST['topic_id']);
But I need more, I need pass another value too. So I use:
if (condition) header("Location: home.php?id=".$_POST['topic_id']&&wrong=1);
And this time I become a dumb. Can anyone help me out by providing proper syntax? I just need pass the WRONG=1 part too.
you need:
if (condition) header("Location: home.php?id=" . $_POST['topic_id'] . "&wrong=1");
or
if (condition) header("Location: home.php?id={$_POST['topic_id']}&wrong=1");
some times it could be
if (condition) {
$_SESSION['error']['topicId'] = $_POST['topic_id'];
$_SESSION['error']['otherData'] = array('sadfasdfasdfasd' => 'adsfasdf');
header("Location: home.php?wrong=1");
exit;
}
and then:
//home.php
if (!empty($_SESSION['error'])) {
$topicId = $_SESSION['error']['topicId'];
//... do someth ...
}
If there is any problem with PHP header function, you may keep in mind that you are able to printout the refresh meta tag in your script HTML output.
<meta http-equiv="refresh" content="0;url=http://yoursite.com/thepath/you/want/file.php?parames=anything">
This is a resource about meta refresh tag:
http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm