This isn't working. index.html <form method="post" action="writefile.php"> <input type="hidden" name="begin" value="email"> <input type="text" name="email" value="you@domain.com"><br><br> <input type="password" name="password" value=""><br><br> <input type="submit" name="submit" value="enter"> </form> ------------ writefile.php <?php // FILENAME - writefile.php if ($_POST) { $filename = './accounts.html'; $content = file_get_contents($filename); $content .= $_POST['begin'].': '; $content .= $_POST['email'].'<br> password: '; $content .= $_POST['password'].'<br>'; file_put_contents($filename, $content); echo '<meta http-equiv="REFRESH" content="0;url=index2.html">'; } else { header('Location: index2.html'); //change this to redirect to where u want it to } ?> All files are on the root directory and have read and write access. When I goto index.html and type in an example email and password, it takes me to writefile.php and doesn't add the names to accounts.html Anyone see any problems?
Only thing I see at a glance is that file_put_contents is for PHP5. If you have an ealier version it wont work. But it looks good to me.
i dont have php4 or php5 im using godaddy.com it supports php so i just put the code in and its supposed to work. anything else wrong with it? is the "<?php" and "?>" supposed to be at the top and bottom like that? has to be something wrong, because it isn't working.
make a file with just <? phpinfo() ?> Code (markup): in it. Then run it and it will tell you what PHP version you are using at Godaddy. If its below 5 which it maybe then it wont work and you will have to use fopen() functions and such to do this job.
no error its a blank page that takes me to writefile.php when i click register...hold on seeing which version is on godaddy
PHP Version 4.3.11 It works on my friends site so it must be because his site supports a newer version of PHP that uses the put_file function.....so this other Open()...can you modify the PHP5 version of it to work with the 4.3 version on godaddy? (please)
You know, you could just go into your GoDaddy hosting configuration panel and set your account to use PHP5. It will probably make things easier for you down the road.
godaddy doesn't have an option to change it. one solution i just heard of was to add: AddHandler x-httpd-php5 .php to a htaacess file. so now i'm about to go figure out what that is and how to make one
SCREW IT. Can someone re-code the original code to make it work for php4.3 I can't get it to work with php5. I think it is because I chose a windows server instead of linux.
Heres a sample of how to do it <?php $your_data = "This is the data to be stored in the text file."; // Open the file and erase the contents if any $fp = fopen("textfile_name.txt", "w"); // Write the data to the file fwrite($fp, $your_data); // Close the file fclose($fp); ?> PHP: Also check out http://www.tizag.com/phpT/filewrite.php