[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">



Jørgen Heesche wrote:
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.

Jeg vil anbefale at slå det fra igen. Det er meget let at komme til at lave scripts med sikkerhedshuller, når det er slået til. Det er derfor, det blev slået fra som standard.


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" />

Browseren sender ikke en værdi tilbage, der hedder submit. Det er fordi du har en navnløs submit-knap, som ikke i sig selv sender noget. Prøv at rette den til:


<input type="submit" name="submit" value="Submit form" />

Eller du kan bare teste på et af de navngivne felter i stedet for på submit med:

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

</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.


Og så lige min nysgerrighed. Hvorfor bruger du forresten XML-syntaks, når din kode mangler en hel del i at være gyldig XHTML alligevel?


Med venlig hilsen

Ole

 
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] *