Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   [PHP] If-Abfrage macht nicht richtig! (https://www.delphipraxis.net/1644-%5Bphp%5D-if-abfrage-macht-nicht-richtig.html)

CalganX 15. Dez 2002 13:33


[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:
#----------------------------------------------   
  } 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";
#----------------------------------------------
Wenn ich nun einen Suchbegriff eingebe, so wird die datei lexikon/index.php trotzdem aufgerufen! Weiß jemand wieso?

Chris

Chewie 15. Dez 2002 13:51

Die if-Abbfrage müsste soweit richtig sein. Vielleicht hat die Variable $keyword ja nicht den Wert, den sie haben sollte?

CalganX 15. Dez 2002 14:09

Hm... Also Keyword:
Code:
$keyword = $HTTP_GET_VARS["keyword"];
Und das Formular übergibt per GET und das Feld heißt Keyword...

Chris

RomanK 15. Dez 2002 14:12

Versuchs mal so:
Code:
$keyword = ( !empty($HTTP_GET_VARS['keyword']) ) ? $HTTP_GET_VARS['keyword'] : "";
Ich meine nämlich das es anderst bei mir nicht getan hätte, kann aber auch sein dass ich mich irre.

CalganX 15. Dez 2002 15:17

Sorry, hat leider nix gebracht... :(

Chris

RomanK 15. Dez 2002 15:21

Poste doch mal den Code des Forms.

CalganX 15. Dez 2002 15:28

http://www.chris-harms.de/lexikon/index.php:
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>
http://www.chris-harms.de/index.php:
Code:
<?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);
       ?>
So..

Chris

fiasko 15. Dez 2002 17:59

Hallo,

ich würde in deiner Funktion mal das Keyword als global markieren... sonst geht definitiv nich!

Thomas

CalganX 15. Dez 2002 18:05

AU!! Das war es! das hatte ich bereits schoneinmal...

THX1

Chris


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:05 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz