Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Include, a zmienne typu GET
Forum PHP.pl > Forum > Przedszkole
S_Olewniczak
Mam w PHP plik index.php, który wygląda tak:
Kod
   <?php
   $kolorTla = 'white';
   include('class/generatorTresci.php?funkcja=deklaracjaDokumentu');
   include('class/generatorTresci.php?funkcja=generujFormLog');
   include('class/generatorTresci.php?funkcja=koniecDokumentu');
   ?>

I plik generatorTresci.php:
Kod
   if ($_GET['funkcja'] == 'generujFormLog') {//tworzenie formularzu logowania
   print '<table border="0" cellpadding="5" cellspacing="5">
   <tr>
           <td>';
     print '<p class="zwyklytekstrid"><b>Witamy w strefie konsultanta. Podaj swoją nazwę użytkownika i hasło, aby się zalogować:</b></p>';
       print "<form action=\"index.php\" method=\"POST\">";
     print "<table><tr><td><p class=\"mala\">użytkownik: </p></td></tr><tr><td><input type=\"text\" name=\"uzytkownik\" value=\"".$_POST['uzytkownik']."\"></td></tr>";
     print "<tr><td><p class=\"mala\">hasło: </p></td></tr><tr><td><input type=\"password\" name=\"haslo\"></td></tr></table>";        
     print '
   <input type="submit" value="Zaloguj">';
     print '</from>';    
  
   print    '</table>';
   print '
  
  
   ';//formularz logowania
  
   }
   elseif ($_GET['funkcja'] == 'deklaracjaDokumentu') {
  
   print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
   <html>
   <head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
   <meta http-equiv="Reply-to" content="szymon.olewniczak@rid.pl">
   <meta http-equiv="Content-Language" content="pl">
   <meta name="author" content="Szymon Olewniczak">
   <title>Wirtualny Pełnomocnik</title>
   <link rel="stylesheet" href="css/strefakon.css" type="text/css" />
   </head>
   <body style="background-color: '.$kolorTla.'">';
   }
   elseif ($_GET['funkcja'] == 'koniecDokumentu') {
   ?>
   </body>
   </html>
   <?
   }

i gdy chcę uruchomić plik index.php PHP wyrzuca mi taki komunikat:

Kod
   Warning: require_once(class/generatorTresci.php?funkcja=deklaracjaDokumentu) [function.require-once]: failed to open stream: No such file or directory in /opt/lampp/htdocs/Rid/wirtualny_pelnomocnik/index.php on line 10
  
   Fatal error: require_once() [function.require]: Failed opening required 'class/generatorTresci.php?funkcja=deklaracjaDokumentu' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/Rid/wirtualny_pelnomocnik/index.php on line 10

Czy ktoś wie gdzie popełniłem błąd?
Lejto
Fatal error: require_once() [function.require]: Failed opening required 'class/generatorTresci.php?funkcja=deklaracjaDokumentu' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/Rid/wirtualny_pelnomocnik/index.php on line 10
błędna ścieżka do pliku, podaj cały index.php
S_Olewniczak
Cały plik index.php:

Kod
<?php
session_start();
if (($_POST['uzytkownik']) && ($_POST['haslo'])) { //wartości są wpisane
include("class/logIwylog.php");
$logowanie = new logIwylog;
$logowanie->_construct($_POST['uzytkownik'],$_POST['haslo'],'konsultanci','username','haslo','index.php','ramka_strefakon.php');

}//koniec pętli sprawdzającej czy wpisano dane
$kolorTla = 'white';
require_once('class/generatorTresci.php?funkcja=deklaracjaDokumentu');
require_once('class/generatorTresci.php?funkcja=generujFormLog');
require_once('class/generatorTresci.php?funkcja=koniecDokumentu');

?>
pyro
Cytat(S_Olewniczak @ 29.03.2008, 18:46:48 ) *
Cały plik index.php:

Kod
<?php
session_start();
if (($_POST['uzytkownik']) && ($_POST['haslo'])) { //wartości są wpisane
include("class/logIwylog.php");
$logowanie = new logIwylog;
$logowanie->_construct($_POST['uzytkownik'],$_POST['haslo'],'konsultanci','username','haslo','index.php','ramka_strefakon.php');

}//koniec pętli sprawdzającej czy wpisano dane
$kolorTla = 'white';
require_once('class/generatorTresci.php?funkcja=deklaracjaDokumentu');
require_once('class/generatorTresci.php?funkcja=generujFormLog');
require_once('class/generatorTresci.php?funkcja=koniecDokumentu');

?>

w require i include nie mozna dodawac takiego czegos: ?funkcja=deklaracjaDokumentu, musisz podawac sciezke do PLIKU
kubap007
A są jakiekolwiek funkcje gdzie można to zrobić?
c4ash
Przeciez wczytujesz plik generator tresci, wiec co za problem w pliku generator tresci napisac funkcje: deklaracjaDokumentu, generujFormLog i koniecDokumentu, a nastepnie tylko odwolywac sie do nich?

To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.