Function erstellen und aufrufen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Function erstellen und aufrufen

    Ich mache ne Website.
    Ich will da verschiedene Links machen

    Wenn ich jetzt auf einen Link klicke,zb. News möchte ich das die datei news.php geladen wird innerhalb der main.php.

    Hier mein Code:

    <!doctype html public "-//W3C//DTD HTML 4.0 //EN">
    <html>
    <head>
    <title>main</title>
    <meta name="author" content="Legolas">
    <link rel="stylesheet" href="text.css" type="text/css">
    </head>
    <body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>

    <?php
    include('var.inc.php');

    if(!isset($site)){
    loadsite();}




    echo"<table width=\"100%\" height=\"500\" border=\"0\" cellspacing=\"0\" cellpading=\"0\">".
    "<tr>".
    "<th align=\"right\" colspan=\"2\" width=\"100%\" height=\"10%\" bgcolor=\"#FFFFFF\">";

    $timestamp = time();
    $datum = date("d.m.Y",$timestamp);
    $uhrzeit = date("H:i",$timestamp);
    echo "Heute ist der ",$datum," - ",$uhrzeit," Uhr";

    echo"</th>".
    "<td></td>".
    "<td></td>".

    "</tr>".
    "<tr>".

    "<td align=\"left\" valign=\"top\" height=\"500\" width=\"10%\" bgcolor=\"#000000\">".
    "<br>".
    "<a href=\"index.php\" class=\"normal\">Home</a>".
    "<br>".

    "<a href=\"main.php?site=news\" class=\"normal\">News</a></td>".

    loadsite{
    if($site=="news")
    {include($news);}
    }
    "<td height=\"500\" bgcolor=\"#C0C0C0\">Main</td>".
    "</tr>".
    "</table>".
    "</body>".
    "</html>";

    ?>

  • #2
    brauchst dafür nicht direkt ne Funktion...

    rufst die seite so auf ./index.php?content=blah

    und includest sie einfach...

    include("$HTTP_GET_VARS[content]");

    gruss

    Comment


    • #3
      Bekomme jetzt die Fehlermedlung wenn ich main.php öffne:

      Warning: Failed opening 'news' for inclusion (include_path='.;c:\php4\pear') in C:\Programme\Apache Group\Apache2\htdocs\php\main.php on line 42


      Meine var.inc.php:

      <?php
      $news = "news.php";
      ?>





      Main.php:

      <!doctype html public "-//W3C//DTD HTML 4.0 //EN">
      <html>
      <head>
      <title>main</title>
      <meta name="author" content="Legolas">
      <link rel="stylesheet" href="text.css" type="text/css">
      </head>
      <body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>

      <?php

      include('var.inc.php');


      echo"<table width=\"100%\" height=\"500\" border=\"0\" cellspacing=\"0\" cellpading=\"0\">".
      "<tr>".
      "<th align=\"right\" colspan=\"2\" width=\"100%\" height=\"10%\" bgcolor=\"#FFFFFF\">";

      $timestamp = time();
      $datum = date("d.m.Y",$timestamp);
      $uhrzeit = date("H:i",$timestamp);
      echo "Heute ist der ",$datum," - ",$uhrzeit," Uhr";

      echo"</th>".
      "<td></td>".
      "<td></td>".

      "</tr>".
      "<tr>".

      "<td align=\"left\" valign=\"top\" height=\"500\" width=\"10%\" bgcolor=\"#000000\">".
      "<br>".
      "<a href=\"index.php\" class=\"normal\">Home</a>".
      "<br>".

      "<a href=\"main.php?content=news\" class=\"normal\">News</a></td>".

      "<td height=\"500\" bgcolor=\"#C0C0C0\">".

      include("$HTTP_GET_VARS[content]");

      "</td>".

      "</tr>".
      "</table>".
      "</body>".
      "</html>";

      ?>

      Last edited by Legolas; 17-06-2002, 16:00.

      Comment


      • #4
        Kann mir keiner helfen?
        Wo liegt der Fehler?

        Comment


        • #5
          gibt es denn eine Datei, die news heisst?
          Beantworte nie Threads mit mehr als 15 followups...
          Real programmers confuse Halloween and Christmas because OCT 31 = DEC 25

          Comment


          • #6
            Im Zweifel würde ich ... auch aus Sicherheitsgründen

            include("./".$HTTP_GET_VARS["content"].".php");

            verwenden.
            carpe noctem

            [color=blue]Bitte keine Fragen per EMail ... im Forum haben alle was davon ... und ich beantworte EMail-Fragen von Foren-Mitgliedern in der Regel eh nicht![/color]
            [color=red]Hinweis: Ich bin weder Mitglied noch Angestellter von ebiz-consult! Alles was ich hier von mir gebe tue ich in eigener Verantwortung![/color]

            Comment


            • #7
              Ja die datei heißt news.php

              Comment


              • #8
                ja aber du includest nur news und nicht news.php
                Beantworte nie Threads mit mehr als 15 followups...
                Real programmers confuse Halloween and Christmas because OCT 31 = DEC 25

                Comment


                • #9
                  ... warum hört nur nie jemand auf meine Anregungen ...
                  carpe noctem

                  [color=blue]Bitte keine Fragen per EMail ... im Forum haben alle was davon ... und ich beantworte EMail-Fragen von Foren-Mitgliedern in der Regel eh nicht![/color]
                  [color=red]Hinweis: Ich bin weder Mitglied noch Angestellter von ebiz-consult! Alles was ich hier von mir gebe tue ich in eigener Verantwortung![/color]

                  Comment


                  • #10
                    Alles klar.Habs hin bekommen.
                    Jetzt nur noch eine Letzte Frage!
                    Wie bekomme ich das hin das in der adresszeile nur noch

                    http://localhost/PHP/main.php?content=editorial

                    anstatt

                    http://localhost/PHP/main.php?content=editorial.php

                    steht?


                    Edit:

                    Oh ok
                    Habs gemekrt.
                    Jaja immer diese n00bs.Sorry!!!
                    Last edited by Legolas; 17-06-2002, 18:24.

                    Comment

                    Working...
                    X