$_POST array is empty

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
counterlink
Forum Newbie
Posts: 4
Joined: Sun Nov 13, 2011 7:37 pm

$_POST array is empty

Post by counterlink »

I cannot get a submitted form to be put in the $_POST array. The raw string is passed, but $_POST remains empty. To try debugging I tried the minimal example below. Each time I submit, the print_r produces ARRAY()

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title>I</title>
</head>

<body>
<?php print_r($_POST); ?>
<form action="temp.php" method="post">
<label>User ID:</label><input name="userid" size="16" type="text" >
<label>Password:</label><input name="password" size="16" type="password"><br><br>
<input name="submit" type="submit" value="Submit">
</form>
</body>
</html>

I tried using the GET method and have the same problem. I see the parameters correctly in the URL display of the browser, but the $_GET array is empty.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: $_POST array is empty

Post by twinedev »

Assuming that the code above IS temp.php, then sounds like you have a problem with the server. Just to make sure that I'm not missing something because I'm tired, I just threw your code on my server and it worked fine, once I filled out the form and hit submit, $_POST had the correct info.

-Greg
counterlink
Forum Newbie
Posts: 4
Joined: Sun Nov 13, 2011 7:37 pm

Re: $_POST array is empty

Post by counterlink »

Thanks friend.
I am runnng the development server within Expression Web 4. And I just discovered what I need to do to get it to work.
In php.ini I need to set
doc_root = localhost
cgi.force_redirect = 0

Through trial and error this fixed the problem.
Post Reply