[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] <form action="<?php echo $PHP_SELF?>" method="POST">



Ole Kofoed Hansen wrote:
Anders Ossowicki wrote:

Så vidt jeg kan læse, ud fra det du skriver, vil det kræve at REGISTER GLOBALS er slået til i PHP før du kan gøre som du ønsker. REGISTER GLOBALS gør det, at den søger efter variabler med post, get og cookie-metoderne. Finder den disse variabler, tildeler den værdierne af dem, til deres navn.


Det er korrekt. Og register_globals har været slået fra i standardopsætningen af PHP i ganske lang tid nu. Det er der en grund til, så derfor bør man ikke slå den til med mindre man ved, hvad man gør, og hvad konsekvenserne er.

Det er generelt smartest at fange værdier fra formularer med de specielle variable i stedet. De hedder $_POST, $_GET og $_COOKIE, og deres indhold er også samlet i den fælles $_REQUEST.

I stedet for at smide $_POST['submit'] over i en anden variabel og teste på den, kan man gøre således:

if(isset($_POST['submit']))

eller bare

if($_POST['submit'])

men den anden metode vil give en NOTICE, hvis man har slået det til.


Hverken if(isset($_POST['submit'])) eller if($_POST['submit']) har nogen effekt: min form bliver ikke processed.
Register globals er nu slået til. phpinfo viste off, men efter installation af:
"
Name: php-ini
Version: 4.3.0-1mdk
Summary: INI files for PHP
"
og reboot er register globals slået til.



Scriptet ser nu sådan ud:


<html>
<body>

<?php
/* if (isset($_POST['submit'])) */
if ($_POST['submit'])
{
  // process form
  $NN = $_POST["name"];
  $AGE = $_POST["age"];
  print("Welcome $NN<br>");
  print("You are $AGE  years old!<br>");
}
else
{
 // display form
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
Enter your name: <input type="text" name="name" />
Enter your age: <input type="text" name="age" />
<input type="submit" />
</form>

View source i Firefox:
<html>
<body>

<form action="/~jph/test/test-self.php" method="POST">
Enter your name: <input type="text" name="name" />
Enter your age: <input type="text" name="age" />
<input type="submit" />
</form>

</body>
</html>

Som det ses har 'PHP_SELF' korrekt værdi.

--
Med venlig hilsen

Jørgen Heesche
mailto:sslug@sslug


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-11-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *