Firstly, thanks so much in advance for any help you might be able to give me one this!
Right, what I want to do, is to call a php script to run server side, which takes in a single value (which will be an email) and write it to a text file.
This is the .php file that I want run. I haven't finished it yet, but after hours of trying I can't even seem to get it to create this text file, and write "test"to it.
<html>
<?php
$myfile = "GatheredEmailAddresses.txt";
$fopen2 = fopen($myfile, 'a');
$stringData = "Here";
fwrite($fopen2, $stringData);
fclose($fopen2);
?>
Done!
</html>
So far, I've only made any sort of progress using this. I know it loads the file, because it displays the text "Done!" in the div area called content area, however I just can't figure out why the rest isn't running. This is the jquery I am using(obviously all relevant tags such as etc are included above:
$("#compute").click(function()
{
$('#contentArea1').load('test.php');
});
I'm not even going to bother asking about the email side of things yet, just want to know how I can run this using jquery. Any help would be so greatly appreciated!!
EDIT:
Hi guys,
After trying some stuff this morning, I've identified that it must be a problem with how my php file is being run. When I run it in my IDE, it runs perfectly, creates the file and works fine. However, when I run it using a Jquery post, it simply returns the "TEST TEXT" and displays it in the relevant div. I'm running it using a "load" jquery command. Any ideas? Very frustrated! :(
This is the php file:
<?php
$dir = 'myDir';
if ( !file_exists($dir) ) {
mkdir ($dir, 0777);
}
file_put_contents ($dir.'/test.txt', 'Hello File');
?>
TEST TEXT