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.

Edited by swraman
Link to comment
Share on other sites

And yes, I am clicking submit.  

 

I assume that somehow the server is reading the submitting webpage to be the webpage in the iframe, and not the actual page on my server.  Is this the case?

Edited by swraman
Link to comment
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.

Edited by swraman
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.