Hi to all new around here, have questions about how to redirect users from one page to another. The ideal whould be to have something like goto URL that you could call anywhere but since there isn't something like that I found redirection through html mata-headers, using the PHP's headers() and through javascript with the window.lacation, most claim that the first two are better since they are server-side so I used them in a php file the code is:
<?
include("../nimda/includes/config.php");
$code1=$_POST['code1'];
if (isset( $code1) && $code1!="" )
{ $goto=0;
if (stristr($code1,"GR-GM1"))
{
$q1=mssql_query("select code,AltCode from clroot.material where altcode='$code1' ") ;
$r1=mssql_fetch_array($q1);
$res=count($r1);
if ($res>1)
{
header("Location:../index.php?page=8&ISRC=$code1");
exit;
}
else
{ if ($res==1) $goto=$r1[0];
}
}
if (stristr($code1,"5205299"))
{
$q1=mssql_query("select MaterialAA from clroot.matbarcodes where code='$code1'");
$r1=mssql_fetch_array($q1);
$next=0;
$next=$r1[0];
if ($next!=0)
{
$q2=mssql_query("select code from clroot.material where AA=$next");
$r2=mssql_fetch_array($q2);
$goto=$r2[0];
}
}
if ($goto!=0)
{
header("../index.php?page=7&kwd=$goto");
exit;
$goto=0;
}
else
{
header("../index.php?page=3&msg=1&code1=$code1");
exit;
//echo "Δεν βρέθηκε αποτέλεσμα για κωδικό: $code1!";
}
}
$code2=$_POST['code2'];
if (isset( $code2) && $code2!="" )
{ $goto=0;
$q1=mssql_query("select code from clroot.material where code='$code2' ") ;
$r1=mssql_fetch_array($q1);
if ($r1[0]) $goto=$r1[0];
if ($goto!=0)
{
header("../index.php?page=7&kwd=$goto");
exit;
$goto=0;
}
else
{
header("../index.php?page=3&msg=2&code2=$code2");
exit;
//echo "Δεν βρέθηκε αποτέλεσμα για κωδικό: $code2!";
}
}
?>
but it doesn't redirect why?
(the include is just a connection to a database, the script simply takes some data from a form do something and returns some values)