![]() |
[PHP] If-Abfrage macht nicht richtig!
Hi,
bin dabei meine Website ein wenig auszubauen. Nur leider klappt beim neuen Lexikon meine Seitenfunktion nicht mehr. Folgendes:
Code:
Wenn ich nun einen Suchbegriff eingebe, so wird die datei lexikon/index.php trotzdem aufgerufen! Weiß jemand wieso?
#----------------------------------------------
} elseif (($id == "lexikon") && ($keyword == "") && ($kid == "")) { # encyclopedia $rsite = "lexikon/index.php"; } elseif (($id == "lexikon") && ($keyword != "") && ($kid == "")) { $rsite = "lexikon/search_result.php"; } elseif (($id == "lexikon") && ($keyword == "") && ($kid != "")) { $rsite = "lexikon/show_entry.php"; #---------------------------------------------- Chris |
Die if-Abbfrage müsste soweit richtig sein. Vielleicht hat die Variable $keyword ja nicht den Wert, den sie haben sollte?
|
Hm... Also Keyword:
Code:
Und das Formular übergibt per GET und das Feld heißt Keyword...
$keyword = $HTTP_GET_VARS["keyword"];
Chris |
Versuchs mal so:
Code:
Ich meine nämlich das es anderst bei mir nicht getan hätte, kann aber auch sein dass ich mich irre.
$keyword = ( !empty($HTTP_GET_VARS['keyword']) ) ? $HTTP_GET_VARS['keyword'] : "";
|
Sorry, hat leider nix gebracht... :(
Chris |
Poste doch mal den Code des Forms.
|
![]()
Code:
<form action="index.php" method="get">
<table width="73%" border="0"> <tr> <td width="59%"><font size="-1">Bitte geben Sie einen Suchbegriff ein:</font></td> <td width="41%"><input name="keyword" type="text" id="keyword" size="30"></td> </tr> <tr> <td colspan="2"><div align="center"> <input name="site" type="hidden" id="site" value="lexikon"> <input type="submit" name="Submit" value="Suchen"> </div></td> </tr> </table> </form> ![]()
Code:
So..
<?php
$id = $HTTP_GET_VARS["site"]; $keyword = ( !empty($HTTP_GET_VARS['keyword']) ) ? $HTTP_GET_VARS['keyword'] : ""; $kid = $HTTP_GET_VARS["kid"]; $cat = ""; $lang = ""; $files = array("disclaimer" => "disclaimer.php", "contact" => "contact.php", "links" => "links.php", "404" => "../errors/404.php", "home" => "home.php", "rememberit" => "projects/rememberit.php", "tools" => "tools.php", "internetsurfer" => "projects/internetsurfer.php", "codelib" => "projects/codelib.php", "counter" => "counter.php", "impressum" => "contact.php" ); # functions function getFileName() { global $cat; global $lang; global $files; global $id; if (strpos($id, "tut_") === 0) { #tutorials $rsite = "tutorials.php"; $lang = substr($id, strpos($id, "_")+1, strlen($id)); #---------------------------------------------- } elseif (strpos($id, "inf_") === 0) { # tipps $rsite = "info.php"; $cat = substr($id, strpos($id, "_")+1, strlen($id)); #---------------------------------------------- } elseif ($id == "") { # others $rsite = "home.php"; #---------------------------------------------- } elseif ($id == "tipp_tp") { # tipps $lang = "tp"; $rsite = "tipps.php"; } elseif ($id == "tipp_delphi") { $lang = "delphi"; $rsite = "tipps.php"; #---------------------------------------------- } elseif (($id == "lexikon") && ($keyword == "") && ($kid == "")) { # encyclopedia $rsite = "lexikon/index.php"; } elseif (($id == "lexikon") && ($keyword != "") && ($kid == "")) { $rsite = "lexikon/search_result.php"; } elseif (($id == "lexikon") && ($keyword == "") && ($kid != "")) { $rsite = "lexikon/show_entry.php"; #---------------------------------------------- } else { # list $rsite = $files[$id]; } return $rsite; } ?> <?php $s = getFileName(); if ($s == "") { $s = "../errors/404.php"; } include("sites/".$s); ?> Chris |
Hallo,
ich würde in deiner Funktion mal das Keyword als global markieren... sonst geht definitiv nich! Thomas |
AU!! Das war es! das hatte ich bereits schoneinmal...
THX1 Chris |
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:29 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz