Apache, PHP & method="post"

Apache, Lighttpd, nginx, Cherokee
Post Reply
nimrod
Posts: 9
Joined: 2003-04-23 20:21
 

Apache, PHP & method="post"

Post by nimrod »

Bin mir nicht ganz sicher obs n php oder n Apache Problem ist, ich posts einfach mal hier:

Ich hab n Formular und will die Daten an ein php Script übergeben. mit method="get" klappt das ganze problemlos. Setz ich method auf post, werden aber keinerlei Superglobals belegt, weder _POST[] noch _REQUEST[]. _SERVER['REQUEST_METHOD'] liefert allerdings erwartungsgemäß POST zurück. Auch das Apache log erzählt von nem POST request:

Code: Select all

80.132.90.220 - - [15/Jul/2003:15:02:59 +0200] "GET /show.php?section=mailform&id=1 HTTP/1.1" 200 1946 "http://www.immo-fr.de/muster" "Opera/7.0 (Windows XP; U)  [en]"
80.132.90.220 - - [15/Jul/2003:15:03:06 +0200] "POST /show.php HTTP/1.1" 200 438 "http://www.immo-fr.de/show.php?section=mailform&id=1" "Opera/7.0 (Windows XP; U)  [en]"
Sowohl mit IE als auch Opera das gleiche Problem, am Browser dürfts damit IMO ned liegen. Mit google hab ich leider auch schon erfolglos gesucht, vllt hatte ich auch nur die falschen Begriffe. Das System is n neuerer 1und1 root mit Debian sid und den entsprechenden Paketen für Apache und PHP. Bin für jegliche Tipps dankbar.
arty
Userprojekt
Userprojekt
Posts: 729
Joined: 2002-06-12 10:11
Contact:
 

Re: Apache, PHP & method="post"

Post by arty »

Hi,

welche PHP-Version nutzt du und benutzt du PHP als CGI oder Modul?

bye
arty
nimrod
Posts: 9
Joined: 2003-04-23 20:21
 

Re: Apache, PHP & method="post"

Post by nimrod »

Ups, ja sry =) php 4.1.2 als Modul(denk ich...), register globals off

Code: Select all

'../configure' '--prefix=/usr' '--with-apxs=/usr/bin/apxs' '--with-regex=php' '--with-config-file-path=/etc/php4/apache' '--disable-rpath' '--disable-debug' '--enable-memory-limit' '--enable-calendar' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-trans-sid' '--enable-bcmath' '--with-bz2' '--enable-ctype' '--with-db2' '--with-iconv' '--with-ndbm' '--enable-exif' '--enable-filepro' '--enable-ftp' '--with-gettext' '--enable-mbstring' '--with-pcre-regex=/usr' '--enable-shmop' '--enable-sockets' '--enable-wddx' '--with-xml=/usr' '--with-expat-dir=/usr' '--enable-yp' '--with-zlib' '--without-pgsql' '--disable-static' '--with-layout=GNU' '--with-curl=shared,/usr' '--with-dom=shared,/usr' '--with-zlib-dir=/usr' '--with-gd=shared,/usr' '--with-jpeg-dir=shared,/usr' '--with-xpm-dir=shared,/usr/X11R6' '--with-png-dir=shared,/usr' '--with-freetype-dir=shared,/usr' '--with-imap=shared,/usr' '--with-ldap=shared,/usr' '--with-mcal=shared,/usr' '--with-mhash=shared,/usr' '--with-mm' '--with-mysql=shared,/usr' '--with-unixODBC=shared,/usr' '--with-recode=shared,/usr' '--enable-xslt' '--with-xslt-sablot=shared,/usr' '--with-snmp=shared' '--enable-ucd-snmp-hack' '--with-sybase-ct=shared,/usr' '--with-ttf=shared,/usr' '--with-t1lib=shared,/usr'
arty
Userprojekt
Userprojekt
Posts: 729
Joined: 2002-06-12 10:11
Contact:
 

Re: Apache, PHP & method="post"

Post by arty »

Hi,

also $_GET[] ist bei GET gesetzt, $_POST[] bei POST nicht? Kannst du das Script mal hier posten?

bye
arty
nimrod
Posts: 9
Joined: 2003-04-23 20:21
 

Re: Apache, PHP & method="post"

Post by nimrod »

Ok, einmal der absendende Teil:

Code: Select all

	<form action="show.php" method="post" enctype="text/plain" target="_self">
    	<input name="section" type="hidden" value="mailsend">
  	<input name="id" type="hidden" value="<?php echo $pageid; ?>">
  	<p style="margin-left:25px;">
  	<table>
  	  	<tr><td>Ihr Name:</td></tr>
  		<tr><td><input name="visitorname" type="text" size="81" maxlength="100"></td></tr>
  	  	<tr><td>Ihre E-mailadresse:</td></tr>
  		<tr><td><input name="replyto" type="text" size="81" maxlength="100"></td></tr>
  		<tr><td>Betreff:</td></tr>
  		<tr><td><input name="betreff" type="text" size="81" maxlength="150" value="<?php echo $ueberschrift; ?>"></td></tr>
		<tr><td height="15"> </td></tr>
   		<tr><td><textarea name="mailtext" cols="60" rows="12" wrap="virtual"></textarea></td></tr>
		<tr><td height="15"> </td></tr>
		<tr><td><input type="submit" value=" Absenden "> <input type="reset" value=" L&schen "></td></tr>
   	</table>
   	</p>
	</form>
und einmal der empfangende Teil:

Code: Select all

elseif ($_REQUEST['section'] == 'mailsend') {
        	if (!$_REQUEST['id']) { gohome(); };
        	$query = "select pageid from immo_pages where pageid = '" . $_REQUEST['id']. "'";
        	$result = mysql_query($query) or die("Anfrage an pagess fehlgeschlagen");   
        	$fields = mysql_fetch_row($result);
        		if ($fields[0]) { 
    				$pageid = $fields[0]; }
        		else { gohome(); };
		if (!$_REQUEST['mailtext']) { $mailerror = 'Sie haben keine Nachricht angegeben.'; }
		else { $mailtext = $_REQUEST['mailtext']; };
		if (!$_REQUEST['betreff']) { $mailerror = 'Sie haben keinen Betreff angegeben.'; }
		else { $betreff = $_REQUEST['betreff']; };
        	if (!$_REQUEST['replyto']) { $mailerror = 'Sie haben keine Antwortadresse angegeben!'; }
        	else { 
			if (!eregi("^s*([_.0-9a-z-]+@(([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}))s*$", $replyto, $mailpart)) { 
				$mailerror = 'Ihre angegebene E-mailadresse ist ung&ltig!'; }
			else { if (!checkdnsrr($mailpart[2])) { $mailerror = 'Ihre angegebene E-mailadresse ist ung&ltig!'; }
				else { $replyto = $mailpart[1]; }; }; };
		if (!$_REQUEST['visitorname']) { $mailerror = 'Sie haben keinen Namen angegeben.'; }
		else { $visitorname = $_REQUEST['visitorname']; }; 
		$section = 'mailsend'; }
Der zweite Teil wird allerdings bei method post schon garnicht mehr abgearbeitet, da section nicht belegt ist. Die Testseite die ich derweil alternativ ausgeben lass bestätigt mir dann dass alle Werte unbelegt sind:

Code: Select all

Req method: POST
Req section: 
Req id: 
Req visitorname: 
Req replyto: 
Req betreff: 
Req mailtext: 

Post section: 
Post id: 
Post visitorname: 
Post replyto: 
Post betreff: 
Post mailtext: 

Get section: 
Get id: 
Get visitorname: 
Get replyto: 
Get betreff: 
Get mailtext: 
arty
Userprojekt
Userprojekt
Posts: 729
Joined: 2002-06-12 10:11
Contact:
 

Re: Apache, PHP & method="post"

Post by arty »

Hi,

setze mal ganz am Anfang von dem Script ein error_reporting(E_ALL); rein und poste das Ergebnis.

bye
arty
nimrod
Posts: 9
Joined: 2003-04-23 20:21
 

Re: Apache, PHP & method="post"

Post by nimrod »

Code: Select all

Warning: Undefined index: section in /home/nimrod/www/immo-fr/show.php on line 23
Warning: Undefined index: section in /home/nimrod/www/immo-fr/show.php on line 40
Warning: Undefined index: section in /home/nimrod/www/immo-fr/show.php on line 52
Warning: Undefined index: section in /home/nimrod/www/immo-fr/show.php on line 63
Warning: Undefined variable: pageid in /home/nimrod/www/immo-fr/show.php on line 90
Warning: Undefined variable: pageid in /home/nimrod/www/immo-fr/show.php on line 122
Req method: POST
Warning: Undefined index: section in /home/nimrod/www/immo-fr/test.inc.php on line 6
Req section: 
Warning: Undefined index: id in /home/nimrod/www/immo-fr/test.inc.php on line 7
Req id: 
Warning: Undefined index: visitorname in /home/nimrod/www/immo-fr/test.inc.php on line 8
Req visitorname: 
Warning: Undefined index: replyto in /home/nimrod/www/immo-fr/test.inc.php on line 9
Req replyto: 
Warning: Undefined index: betreff in /home/nimrod/www/immo-fr/test.inc.php on line 10
Req betreff: 
Warning: Undefined index: mailtext in /home/nimrod/www/immo-fr/test.inc.php on line 11
Req mailtext: 
Warning: Undefined index: section in /home/nimrod/www/immo-fr/test.inc.php on line 13
Post section: 
Warning: Undefined index: id in /home/nimrod/www/immo-fr/test.inc.php on line 14
Post id: 
Warning: Undefined index: visitorname in /home/nimrod/www/immo-fr/test.inc.php on line 15
Post visitorname: 
Warning: Undefined index: replyto in /home/nimrod/www/immo-fr/test.inc.php on line 16
Post replyto: 
Warning: Undefined index: betreff in /home/nimrod/www/immo-fr/test.inc.php on line 17
Post betreff: 
Warning: Undefined index: mailtext in /home/nimrod/www/immo-fr/test.inc.php on line 18
Post mailtext: 
Warning: Undefined index: section in /home/nimrod/www/immo-fr/test.inc.php on line 20
Get section: 
Warning: Undefined index: id in /home/nimrod/www/immo-fr/test.inc.php on line 21
Get id: 
Warning: Undefined index: visitorname in /home/nimrod/www/immo-fr/test.inc.php on line 22
Get visitorname: 
Warning: Undefined index: replyto in /home/nimrod/www/immo-fr/test.inc.php on line 23
Get replyto: 
Warning: Undefined index: betreff in /home/nimrod/www/immo-fr/test.inc.php on line 24
Get betreff: 
Warning: Undefined index: mailtext in /home/nimrod/www/immo-fr/test.inc.php on line 25
Get mailtext: 
Sieht für mich relativ unspekatakulär aus... Rührt alles daher, dass am Anfang section nicht belegt wird, damit werden einige andere Variable auch nicht belegt und am Ende macht er die Testseite durch und stellt nochmal fest, dass die Werte nicht belegt sind :(
arty
Userprojekt
Userprojekt
Posts: 729
Joined: 2002-06-12 10:11
Contact:
 

Re: Apache, PHP & method="post"

Post by arty »

Du hast etliche undefinierte Variablen in deinem Skript. Fixe diese Fehler erstmal.

bye
arty
nimrod
Posts: 9
Joined: 2003-04-23 20:21
 

Re: Apache, PHP & method="post"

Post by nimrod »

Ja, kommt daher dass via post "section" nicht definiert wird. nehm ich get sind da keine undefinierten variablen. Daran liegts _NICHT_.
nimrod
Posts: 9
Joined: 2003-04-23 20:21
 

Re: Apache, PHP & method="post"

Post by nimrod »

Für alle die auch mal über das Problem stolpern sollten... ich hab den Fehler endlich gefunden. Man setze den enctype von text/plain auf multipart/form-data und die Sache läuft - auch wenn man im Forum nur Textfelder drin hat.
Post Reply