So for a few days now i have been looking through forum posts on how to make this work. I have found many post that were helpful. And had working Answers, but every time i tried it it didn't want to work for me. Now most of these post i saw were 2-5 years old. So i though to make a new one i thought to make a new one also since i don't really know any php, but i am trying to learn and so adapting the php is quite hard since i really know how to read it. so here is my code and some pics, also the links to the post i have looked at.BTW this is for a wiki project for a game called World At Arms, go check it out it is fun.
HTML Code:
<form action="totxt.php?saving=1" id="contact_form" method="post">
First Name:
<input type="text" name="first" id="first" value="First Name" onblur="if(this.value == '') { this.value = 'First Name'; }" onfocus="if(this.value == 'First Name') { this.value = ''; }" />
<br /> Last Name:
<input type="text" name="last" id="last" value="Last Name" onblur="if(this.value == '') { this.value = 'Last Name'; }" onfocus="if(this.value == 'Last Name') { this.value = ''; }" />
<br /> In Game Name:
<input type="text" name="ing" id="ign" value="In Game Name" onblur="if(this.value == '') { this.value = 'In Game Name'; }" onfocus="if(this.value == 'In Game Name') { this.value = ''; }" />
<br /> Current Level:
<input type="text" name="level" id="level" value="Current Level" onblur="if(this.value == '') { this.value = 'Current Level'; }" onfocus="if(this.value == 'Current Level') { this.value = ''; }" />
<br /> Glory:
<input type="text" name="glory" id="glory" value="Glory" onblur="if(this.value == '') { this.value = 'glory'; }" onfocus="if(this.value == 'glory') { this.value = ''; }" />
<br /> Message:
<br />
<textarea name="message" id="message" rows="10" cols="50"></textarea>
<br />
<input value="Submit" type="submit" />
</form>
So This is the Html code i have smashed together from post i have found. it is messy and i'm pretty sure there are some chucks that can be taken away but i'm no coding mastermind.
The PHP Code i have gathered together:
<?php
$first = $_POST["first"];
$last = $_POST["last"];
$ign = $_POST["ign"];
$level = $_POST["level"];
$glory = $_POST["glory"];
$message = $_POST["message"];
$text = "NAME: $first $last <br>
In Game Name: $ign<br>
Current Level: $company<br>
Glory: $glory<br>
MESSAGE: $message<br><hr><br><br><br>";
$file = "data.txt";
$fp = fopen($file, "a") or die("Couldn't open $file for writing!");
fwrite($fp, $text) or die("Couldn't write values to file!");
fclose($file);
?>
<meta http-equiv="refresh" content="0; url=Success.html" />`
So this is the error i get when i hit submit:
Couldn't open data.txt for writing!
The links i used to get this far.
1: Get user input from form, write to text file using php
2: https://forums.digitalpoint.com/threads/save-php-form-data-to-a-txt-file.757223/
3: PHP write file from input to txt
4: There was another one but i cant seem to find the link.