MohtasaUnique
Grand Master
- Joined
- Sep 1, 2007
- Sythe Gold
- 690
- Messages
- 6,681
I'm trying to create a webpage for my personal trainer to use in order to let his members sign in for their sessions so he can keep track of how many sessions they've attended.
I have all the visual shit set up, but I'm trying to understand how to make it write to a file. As I understand it, PHP requires a web server to write to files, but I want to know that I've correctly programmed the webpage so when I do upload it, it'll do as intended.
Here's the code:
I've currently got it running on a local directory on my computer, but obviously I don't have apache so PHP isn't functional.... Can anyone confirm if this is all I need in order to write files?
I have all the visual shit set up, but I'm trying to understand how to make it write to a file. As I understand it, PHP requires a web server to write to files, but I want to know that I've correctly programmed the webpage so when I do upload it, it'll do as intended.
Here's the code:
HTML:
<form method="post" action="script/write.php">
<select name="member">
<option class="holder" selected="selected">-MEMBER PROFILE-</option>
<option value="test1">Test 1</option>
<option value="test2">Test 2</option>
<option value="test3">Test 3</option>
</select>
<input name="sessionDate" type="date"/>
<input name="workoutPerformed" type="text" placeholder="WORKOUT PERFORMED"/>
<button name="submitButton" class="checkinButton" type="submit">SUBMIT</button>
</form>
PHP:
<?php
if(isset($_POST["write"]) && !empty($_POST["workoutPerformed"])) {
$f = fopen("log.txt", "a");
fwrite($f, $_POST["member"]);
fwrite($f, $_POST["sessionDate"]);
fwrite($f, $_POST["workoutPerformed"]);
fwrite($f, "\n");
fclose($f);
echo 'alert("Success")';
die():
}
else() {
echo 'alert("Error")';
}
?>
I've currently got it running on a local directory on my computer, but obviously I don't have apache so PHP isn't functional.... Can anyone confirm if this is all I need in order to write files?
Last edited:

