Re: METHOD=POST not worikng

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Saturday, May 13, 2006 4:59 PM GMT,
ray.hauge@xxxxxxxxxxxxxxxxxxxxxxx <ray.hauge@xxxxxxxxxxxxxxxxxxxxxxx> wrote:

AFAIK it should be working just fine.  I'm not aware of POST not
working in any circumstance other than PHP not working at all.

Can you post your test script?  We could better judge what's happening
based off that.  Just make sure you're referencing the variables with
$_POST or $_REQUEST, not $_GET.

Slightly off topic.  If you're not already, always make sure to
verify/escape your input from POST/GET/RSS/etc.  That will help make
your pages more secure.  It might seem like you don't need to do it
right now at the beginning, but it's a good habit to get into... One
that I need to follow better (especially when I have a really short
deadline).

Ray


PHP is indeed working. If I use METHOD=GET instead of POST, the script works without any issues. Here is the test script I'm using:
<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>
<p>Type your text here:<br>
<textarea name="text" rows=10 cols=40 wrap></textarea></br>
<input type=submit name="submit" value="SUBMIT">
</form>
<?php
	else:
		//connect to the database server
		$dbcnx=@mysql_connect("localhost","username","password");
		if(!$dbcnx){
			echo("<p>Unable to connect to the database server at this time.</p>");
			exit();
			}
		//select test database
		if(!@mysql_select_db("test")){
			echo("<p>Unable to locate test database at this time.</p>");
			exit();
			}
		//if a sample text has been submitted, add it to the database.
if("SUBMIT"==$_REQUEST['submit']){ //I have tried _GET, _POST, and _REQUEST
			$text=$_REQUEST['text'];   //Same thing here, _GET, _POST, and _REQUEST
			$sql="insert into test_table set ".
				"Text='$text', ".
				"Date=CURDATE();";
			if(mysql_query($sql)){
				echo("<p>Your text has been added.</P>");
				}
			else {
				echo("<p>Error Adding submitted text: ".
					mysql_error()."</p>");
				}
			}
		echo("<p>Here are all the texts in our database: </p>");

		//Request the text of all the texts
		$result=mysql_query("select Text from test_table");
		if(!$result){
			echo("<p>Error performing query: ".mysql_error()."</p>");
			exit();
			}
		//display the texts in a paragraph
		while($row=mysql_fetch_array($result)){
			echo("<p>".$row["Text"]."</p>");
			}

		//when clicked, this link will load this page with the text
		//submission form displayed.

		$self=$_SERVER['PHP_SELF'];
		echo("<p><a href='$self?addtext=1'>".
			"Add a text</a></p>");
	endif;
?>
</body>
</html>Thanks.

Regards,
IraqiGeek
www.iraqigeek.com

My computer isn't that nervous... it's just a bit ANSI.

-------- Original Message --------
Subject:  METHOD=POST not worikng
From: "IraqiGeek" <geek@xxxxxxxxxxxxx>
Date: Sat, May 13, 2006 7:16 am
To: "PHP-General" <php-general@xxxxxxxxxxxxx>

Hi all,

I'm learning PHP on a  Debian Etch with Apache 2.0.54 and PHP
4.3.10, and using Firefox 1.5.3 on a Windows XP box to browse the
sample site. I wrote a small form to get user input. If I use
METHOD=GET, then the form works fine, without any glitches. However,
if I use METHOD=POST in the form, I don't get the data back to the
script.

Googling around, I found a reference to mod_bandwidth, but AFAIK,
this module is used to regulate/limit user traffic.

Are there any modules missing that prvent METHOD=POST from working
properly? any config files that need to be edited?

Thanks.

Regards,
IraqiGeek
www.iraqigeek.com

The average woman would rather have beauty than brains, because the
average man can see better than he can think.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux