Re: Empty $_POST after submit.

[email protected] (Jim Giner)
Newsgroups php.general
Message-ID <[email protected]>
I took your script and added some stuff.  Call it "testisset.php", 
upload it and try to run it.

Script below - Please copy and run it EXACTLY as written:

<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', '1');
$errmsg = "POST is:<br>";
foreach($_POST as $k=>$v)
	$errmsg .= "$k is $v<br>";
if (isset($_POST['submit']))
{
	if (isset($_POST['lastname'], $_POST['lastname']))
	{
		echo "isset is true<br>";
		echo "Entered values are:<br>";
		echo("First name: '" . $_POST['firstname']."' - " . 
strlen($_POST['firstname'])." chars long<br />");
		echo("Last name: '" . $_POST['lastname']."' - " . 
strlen($_POST['lastname'])." chars long <br />");
		echo $errmsg;
	}
}
else
{
	$code=<<<heredocs
	<html>
	<head>
	</head>
	<body onload="document.thisform.firstname.focus()">
	Data Entry Form:<br>
	<form name="thisform" action="testisset.php" method="post">
	  First name: <input type="text" tabindex=1 name="firstname" /><br>
	  Last name: <input type="text" tabindex=2 name="lastname" /><br>
	  <input type="submit" name="submit" tabindex=3 value="Submit" />
	</form>
	$errmsg
	</body>
	</html>
heredocs;
	echo $code;
}
exit();

***********
On the initial execution you should see your input form and the POST 
values will be missing (no vars at all).

Once you enter anything and hit "Submit" your will see your top two 
displays followed by the contents of the POST array which should show 
something at that time.  If not - you have a configuration problem.

Note:  While I questioned your isset test method (testing the same var 
twice?), I used it in this script just as you did.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.