Jump to content

$_POST reads an empty array


swraman

Recommended Posts

This has me stumped.  It was workign fine but 30 minutes ago!

 

Body of my form:

<form name="form1" id="form1" action="process.php" method="post">
<textarea cols="50" rows="4" id="src" name="src"></textarea>
<input type="submit" value="Submit">
</form>

process.php:

<?php print_r($_POST); ?>

process.php displays:

Array()

regardless of what I have in the text box.

Link to comment
https://forums.phpfreaks.com/topic/277917-_post-reads-an-empty-array/
Share on other sites

I typically don't use iframes either, but for this project I have to use access a part of another website which requires users to login.  Here is the full code:

 
<html><head>
 
<script type="text/javascript">
function getsome(){
w = document.getElementById('inline').contentWindow.document.body.innerHTML;
document.getElementById("src").value=w;
}
</script></head>
 
<body>
<br>
<a href="#" onclick="getsome()">Push me</a><br>
 
<form name="form1" id="form1" action="process.php" method="post">
<textarea cols="50" rows="4" id="src" name="src"></textarea>
<input type="submit" value="Submit">
</form>
<iframe name="inline" id="inline" frameborder="0" scrolling="auto" width="1000" height="300" marginwidth="5" marginheight="5" src="http://website.com/"></iframe> 
</body>
</html>

This script is meant to copy the source of a website into the form (done with JS, which works), then submit that form to process.php.

your process.php page is probably redirecting back to itself and clearing the $_POST data and/or you don't have an exit; statement after a redirect to prevent the rest of your code from running.

 

you need to post the code that reproduces the problem. not all your code, but the code you do post must have been tested by you and it reproduces the problem.

Thanks for the reply.  No, my process.php was not redirecting anywhere.  It was just a single line, <?php print_r($_POST); ?>.

 

I meant that when I clicked on the submit button to submit the form, I was opening the form in a new tab.  This made the $_POST array in the receiving process.php file be empty.  If I submit the form in the same tab, it works fine.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.