Re: METHOD=POST not worikng

From: Date: Sun, 14 May 2006 08:41:26 +0000
Subject: Re: METHOD=POST not worikng
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-236141@lists.php.net to get a copy of this message
On 5/13/06, IraqiGeek <geek@iraqigeek.com> wrote: [snip]
<html> <title>test script</title> <body> <?php
        //If the user wants to add a joke
        if(isset($_GET['addtext'])):
?>//If I use METHOD=GET here, the script works flawlessly <form action="<?php echo($_SERVER['php_self']);?>" METHOD=POST> [/snip]
The form action should be $_SERVER['PHP_SELF']. Here case matters, since this is a string and not a variable name. If action is empty, I believe browsers simply send the request to whatever URL the page was accessed at. Since you're already at a GET (with ?addtext), the POST request actually includes both the GET and the POST, so the the form is shown again. Just var_dump $_GET and $_POST and you'll see what's happening. Rabin

« previous php.general (#236141) next »