So i have a page where the visitor inputs data into a text area and i want that data to be saved to a file.
All is working fine but when the data is passed to the php script it opens a new window and i don't want that. I want the data to be passed without opening a new window or without the page having to refresh.
My javascript code to pass the data to php:
window.open('post.php?' + data, target='_blank');
My php script that receives the data and writes it to a file:
<?php
$handle = fopen("data.txt", "a");
foreach($_GET as $variable => $value) {
fwrite($handle, $variable);
fwrite($handle, $value);
fwrite($handle, "
");
}
fwrite($handle, "
");
fclose($handle);
exit;
?>
Thank you!