Jump to content

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

Edited by swraman

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.

what link? what new tab? $_POST data will be available only on the page that is the target of the form. anything you do to goto a new page or refresh that page will clear the $_POST data.

 

and did you see the post i made above about your process.php code?

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.

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.