Aşağıdaki PHP kodu göz önünde bulundurun:
<?php
$searchsport = $_REQUEST['sport'];
$sportarray = array(
"Football" => "Fb01",
"Cricket" => "ck32",
"Tennis" => "Tn43",
);
header("Location: ".$sportarray[$searchsport].".html"); //directs user to the corresponding page they searched
if ($searchsport == NULL) {
header("Location: youtypednothing.html"); //directs user to a page I've set up to warn them if they've entered nothing
} else {
header("Location: sportdoesnotexist.html"); //if sport isn't in my root, a warning will appear
}
?>
Benim form.html üzerinde Tenis yazarken temelde bu php dosyasına ve süreç veri göndermek ve benim tenis sayfası olan Tn43.html beni yönlendirecektir, kodu yorumlar kendini açıklayıcı olduğunu düşünüyorum. Ne yazık ki, bu işe yaramazsa ve ben gerçekten (Ben bazı büyük aptalca bir hata yaptım biliyorum) ... neden bilmek istiyorum.
PS: Bazı yönlendirmelerde yaparken kullanmak için doğru işlevi header mı?