Archiv verlassen und diese Seite im Standarddesign anzeigen : POST-Methode
ich arbeite mich gerade in php ein (versuche es zumindest;-))
ich habe ein kleines test-script, mit dem man daten in eine .dat-Datei schreiben kann (wenn es funktioniert).
Aber scheinbar funktioniert irgend etwas nicht so richtig.
Ich bekomme folgende Fehlermeldung:
Method Not Allowed
The requested method POST is not allowed for the URL /test/4.php3.
Apache/1.3.20 Server at linux.local Port 80
Ich habe schon mal in der httpd.conf geschaut und im Netz gesucht aber leider noch keinen passenden Hinweis gefunden.
Hat jemand einen kleinen Tip?
Danke
netzmeister
06-04-2002, 19:11
Hallo,
ist die Datei schreibbar für den Apache User? (Chmod 777)
Hast Du in der php.ini den SafeMode auf Off ?
Viele Grüsse
Eicke
Kannst Du das Skript mal posten?
@Eike:
> ist die Datei schreibbar für den Apache User? (Chmod 777)
Ich glaube nicht, dass es ein Rechteproblem ist. Wenn man via PHP in eine Datei schreiben willst und dir fehelen die Rechte, gibt der PHP-Parser eine Warneung/Fehlermeldung aus. Diese ist aber vom Apache generiert.
Ich hatte die mal, als ich mich im <form>-Tag verschrieben hatte...
oliver
Noch einige Erläuterungen (OS SuSE 7.3, Standartinstalltion):
Ich habe zur Vereinfachung - auch wenn es keine gute Lösung ist - unter
/usr/local/httpd/htdocs
ein Verzeichnis angelegt, in dem ich meine PHP-Sripte ablege und dann
über http:/localhost/Verzeichnis/xyz.php aufrufe.
PHP läuft im übrigen, da Seiten ohne POST funktionieren.
Auszug aus httpd.conf:
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/usr/local/httpd/htdocs">
#
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
Options Indexes -FollowSymLinks +Includes MultiViews
#
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
#
# disable WebDAV by default for security reasons.
#
<IfModule mod_dav.c>
DAV Off
</IfModule>
#
# Enable SSI (Server Side Includes) for the demo index.html pages, as some of
the content
# is created dynamically. This should be disabled when setting up a productive
# server.
<Files /usr/local/httpd/htdocs/index.htm*>
Options -FollowSymLinks +Includes +MultiViews
</Files>
#
# Protect the php3 test page, so it cannot be viewed from an outside system.
#
<Files test.php3>
Order deny,allow
deny from all
allow from localhost
</Files>
</Directory>
#
# UserDir: The name of the directory which is appended onto a user's home
# directory if a ~user request is received.
# Note:
# The next three lines are commented out here. These directives and the access
# control section have been put into /etc/httpd/suse_public_html.conf.
# If the variable HTTPD_SEC_PUBLIC_HTML in /etc/rc.config.d/apache.rc.config
# is set to "yes" (default), SuSEconfig will include that file via
# /etc/httpd/suse_include.conf.
# Also note that for the /home/*/public_html directories to be browsable the
# executable flag must be set on the /home/* directories.
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/usr/local/httpd/htdocs">
#
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
Options Indexes -FollowSymLinks +Includes MultiViews
#
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
#
# disable WebDAV by default for security reasons.
#
<IfModule mod_dav.c>
DAV Off
</IfModule>
#
# Enable SSI (Server Side Includes) for the demo index.html pages, as some of
the content
# is created dynamically. This should be disabled when setting up a productive
# server.
<Files /usr/local/httpd/htdocs/index.htm*>
Options -FollowSymLinks +Includes +MultiViews
</Files>
#
# Protect the php3 test page, so it cannot be viewed from an outside system.
#
<Files test.php3>
Order deny,allow
deny from all
allow from localhost
</Files>
</Directory>
#
# UserDir: The name of the directory which is appended onto a user's home
# directory if a ~user request is received.
# Note:
# The next three lines are commented out here. These directives and the access
# control section have been put into /etc/httpd/suse_public_html.conf.
# If the variable HTTPD_SEC_PUBLIC_HTML in /etc/rc.config.d/apache.rc.config
# is set to "yes" (default), SuSEconfig will include that file via
# /etc/httpd/suse_include.conf.
# Also note that for the /home/*/public_html directories to be browsable the
# executable flag must be set on the /home/* directories.
suse_public_html.conf:
<IfModule mod_userdir.c>
UserDir public_html
</IfModule>
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
Ich habe schon im Netz gesucht und alternative Einstellungen aus anderen access.conf-Dateien in die suse_public_html.conf übertragen, hat aber nicht so richtig funktioniert.
Ich bin schon seit Stunden mit meinem (sicherlich lückenhaften) Wissen am Ende und habe auch so ziemlich die Schnauze voll (für heute;-)).
Vielleicht weiß ja jemand mal eine (einfache) Lösung
@ lolli:
4.html
<HTML>
<HEAD>
<TITLE>PHP-Kochrezept 4: Datenerfassung über Formular in einer Datei gesammelt
</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff" TEXT="#000000" LINK="#0000ff" VLINK="#800080" ALINK="#ff0000">
<H1>PHP-Kochrezept 4: Datenerfassung über Formular in einer Datei gesammelt</H1>
<? if (isSet($name) && ereg("[a-zA-Z]+", $name)
&& isSet($vorname) && ereg("[a-zA-Z]+", $vorname)
&& isSet($strasse) && ereg("[a-zA-Z]+", $strasse)
&& isSet($ort) && ereg("[a-zA-Z]+", $ort)) {
$date = Date("d.m.y H:i ");
$host = GetEnv("REMOTE_HOST");
$data = sprintf(
"%s %s\n\tName:\t\t%s\n\tVorname:\t%s\n\tStrasse:\t%s\ n\tPLZ/Ort:\t%s %s",
$date,$host,$name,$vorname,$strasse,$plz,$ort);
if (IsSet($email) && ereg("[a-zA-Z]+", $email)) {
$data .= sprintf("\n\tEMail:\t\t%s",$email);
}
$fp = fopen("/home/tb/test.dat","a");
fputs($fp,$data);
fputs($fp,"\n\n");
fclose($fp);
?>
Folgende Daten wurden aufgenommen:
<PRE>
<? Echo $data; ?>
</PRE>
<P>
<? } else { ?>
In diesem Beispiel werden natürlich keine echten Daten für einen echten
Zweck gesammelt; wenn Sie die Funktionalität testen möchten, geben Sie am
besten Phantasiedaten ein, die keinen wirklichen Personen entsprechen.
<BR>
Die Adressen werden nicht zu anderen Zwecken benutzt oder weitergegeben.<BR>
Ihre Eingaben können nur berücksichtigt werden, wenn Name, Vorname, Straße
und Ort angegeben sind.<BR>
<FORM ACTION="4.php3" METHOD=POST>
<TABLE BORDER=0>
<TR>
<TD COLSPAN="2" ALIGN=RIGHT>
Name <INPUT NAME="name" TYPE="text" SIZE="30">
Vorname <INPUT NAME="vorname" TYPE="text" SIZE="24"><P>
<TR>
<TD COLSPAN="2" ALIGN=RIGHT>
Straße und H-Nr.<INPUT NAME="strasse" TYPE="text" SIZE="56"><BR>
<TR>
<TD COLSPAN="2" ALIGN=RIGHT>
Plz <INPUT NAME="plz" TYPE="text" SIZE="6">
Ort <INPUT NAME="ort" TYPE="text" SIZE="51"><P>
<TR>
<TD ALIGN=RIGHT>
E-Mail <INPUT NAME="email" TYPE="text" SIZE="30"><BR>
<TR>
<TD COLSPAN="2" ALIGN=RIGHT>
<INPUT TYPE="SUBMIT" VALUE="Ab geht's!">
</TABLE>
</FORM>
<? } ?>
<BR>
<HR NOSHADE SIZE=2>
<A HREF="Welcome.php3">PHP-Kochrezepte</A> von
<A HREF="/~tb/">Bernd Cappel</A>; Nr. 4 zuletzt geändert am
<? Echo Date("d.m.Y",getlastmod()); ?>
</BODY>
</HTML>
4.php3
<HTML>
<HEAD>
<TITLE>PHP-Kochrezept 4: Datenerfassung über Formular in einer Datei gesammelt
</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff" TEXT="#000000" LINK="#0000ff" VLINK="#800080" ALINK="#ff0000">
<H1>PHP-Kochrezept 4: Datenerfassung über Formular in einer Datei gesammelt</H1>
Folgende Daten wurden aufgenommen:
<PRE>
05.04.02 15:27 pd9e582ca.dip0.t-ipconnect.de
Name: bla
Vorname: bla
Strasse: bla
PLZ/Ort: bla bla
EMail: bla</PRE>
<P>
<BR>
<HR NOSHADE SIZE=2>
<A HREF="Welcome.php3">PHP-Kochrezepte</A> von
<A HREF="/~tb/">Bernd Cappel</A>; Nr. 4 zuletzt geändert am
13.09.1999</BODY>
</HTML>
Mein /home-Verzeichnis ist /tb
Zur Kenntnis (damit ich mich nicht mit fremden Federn schmücke):
Die Scripte sind nicht auf meinem Mist gewachsen, die habe ich aus dem Netz und versuche diese zu verstehen und auf meinem Rechner zum laufen zu bringen.
Mal klappt es und mal nicht;-(
Wie auch immer: Nenne deine Dateien einfach *.php. Dann funktionierts. (Habs selbst probiert). Denke auch daran, das <form>-Tag anzupassen...
Aber frage nicht nach der Erklärung. Ich abe keine :confused: :confused:
oliver
@ lolli
Vielen Dank!!!!!!!!
Der Fehler mit der POST-Methode ist weg (kann es vielleicht sein, das php3 die Methode nicht unterstützt?).
Wenn ich das richtig verstanden habe müßte das Sript die eingegebenen Daten in der Datei
/home/tb/test.txt (Habe ich geändert) speichern und danach auf dem Bildschirm ausgeben.
Leider gibt er aber nur blabla ;-) aus und in die Datei wird nichts geschrieben.
Habe ich da sonst noch ein Verständnisproblem (vermutlich ja)?
Powered by vBulletin® Version 4.2.5 Copyright ©2024 Adduco Digital e.K. und vBulletin Solutions, Inc. Alle Rechte vorbehalten.