Forum Moderators: coopster
I am pretty new to PHP.
I am running into a problem while writing the data to an excel sheet.
I have two script files.
First script displays the data on the screen and has a button along with it. OnClick of this button a JavaScript function is invoked and this function calls the second script and passes the data along using the following,
document.location.href="secondScript.php?"+form.actionData.value
The second script invokes the excel sheet and writes to it the data passed by document.location.href.
This works absolutely fine when the data to be passed is very small, but when the data size increases to more than 2000 characters, it fails.
Any clues as to what can be done to fix this problem.
Thanks,
Kiran.
You should pass the data with the POST method. GET , which you are using now, is indeed only suitable for small bits of data.
Instead of using the javascript method, use the ordinary submit button.
<form action="secondScript.php" method="POST">
<input type="text" name="actionData">
<input type="submit" value="Go!">
</form>
In secondScript.php, the posted data will be stored in the $_POST array. Print its contents with something like
echo '<pre>';
print_r($_POST);
echo '</pre>';
Thanks for the prompt answer.
Infact I am using the POST action in my firstScript.
As you suggested I believe changing the button type to "submit" and getting rid of JavaScript should fix the problem.
How-ever, the data that I am passing in not a form member as of now. So per my understanding the "POST" array will not contain its values (please correct me if my understanding is wrong). So first I have to make this data variable as a form variable of hidden type, am I correct Ron?
Alternatively to comply with the existing design I am writing the data into a file in the firstScript and reading it in the secondScript. This is currently working like a horse. But the only scare is when thousands of users access this feature, will this lead into performance degradation, as it involves file handlers? The file is opened, written and read on the client side itself, so please advice.
Thanks again,
Kiran.
But that is overridden by the JavaScript, which produces a query string, i.e. GET.
> So first I have to make this data variable as a form variable of hidden type,
Yep.
> writing the data into a file
I find sessions a very good way to store data on the server. Never had any performance problems with them.