raman Posted March 16, 2009 Share Posted March 16, 2009 I have a php script query.html linked to a php script quer.php. This php script retrieves a table by pulling data from Mysql database. On this page I have provided a button through which I write the user's selected data to a file also. And I also want the button to paste my file data on a third html page (muscle.html), in a textbox but on that page I have variables obtained by the POST method. How do I pass the data to the text box on that page ? Basically I want that when the user clicks on that button he would be automatically taken to muscle.html where his chosen data would be already pasted ? Can someone HELP ? Link to comment https://forums.phpfreaks.com/topic/149637-how-to-post/ Share on other sites More sharing options...
pkSML Posted March 16, 2009 Share Posted March 16, 2009 You can use a form to POST the pertinent data on the 3rd page. The third page would have to be PHP, not HTML (because you want dynamic content). Then, just read the appropriate POST data element into the textarea. You'll want to use this format: <?php echo "<textarea style=\"height: 500px; width: 500px;\">" . htmlentities($_POST['dataField']) . "</textarea>"; ?> Note: If you need more help, you'll need to be a little clearer in your explanation. Link to comment https://forums.phpfreaks.com/topic/149637-how-to-post/#findComment-785790 Share on other sites More sharing options...
raman Posted March 17, 2009 Author Share Posted March 17, 2009 I still need help. So I will make it clear. I have a page query.php generated by retrieving data from mysql. This script has checkboxes for user to select data, and then there are 2-3 buttons. These have the form action=download.php. In this I am writing the user's selected data to a file and then here I want the user to be redirected to another php script called antigenic.php but I also want that the file data should be posted to antigenic.php so it can be used there. How do I pass on the file data ? It cannot be done by GET method as header("Location: antigenic.php?data=$string"); because the data size may be too large. Here is my relevant code from download.php $antig=$_POST['antig']; if(isset($antig)){ $randomno=rand(0,111111); $file4align='align_'.$randomno.'.'.'fa'; foreach($_POST['pro'] as $kyu){ $re=mysql_query("SELECT * FROM cryptovir WHERE SNo='$kyu'"); while($row=mysql_fetch_array($re)) { $head=$row['header'];$seque=$row['Sequence']; $openfile=fopen("alignfiles/$file4align", "a+") or die ("Can't open file"); if ($seque!= 'N.i.'){ fwrite($openfile,"$head\n$seque\n"); fclose($openfile); } } } $retyu='./alignfiles/'.$file4align; $string=file_get_contents($retyu); #$data=urlencode($string); #echo"<form action=antigenic.php method=post enctype=multipart/form-data><input type=hidden name=data value=$string></form>"; header("Location: antigenic.php"); Link to comment https://forums.phpfreaks.com/topic/149637-how-to-post/#findComment-786517 Share on other sites More sharing options...
pkSML Posted March 17, 2009 Share Posted March 17, 2009 You don't have many attractive options here. Here's what I can come up with. 1. Use javascript. It can complete an AJAX request with POST data. This requires the user to have javascript turned on in their browser. 2. Condense your download.php and antigenic.php into one script. That way, all variables would still be available. 3. Make a form with hidden elements to get the user from page 2 to page 3. They would have to click on a button to submit the form data. 4. Save the data that you need transferred as session data. This requires cookies to be turned on in the user's browser. 5. Save the important data as a text file on the server, and in your redirection (from download.php), put the filename in the query string. Have the script delete the file when you're done with it. If none of these options work for you, I think you're stuck. Sessions would be the easiest method in my opinion. Link to comment https://forums.phpfreaks.com/topic/149637-how-to-post/#findComment-787078 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.