Jump to content

php not writing to txt file


Strac72

Recommended Posts

I am using a script I adapted from a tutorial to print the contents of a text box to a txt file. Basically, it's a really simple way of seeing who has logged in. I only have a handful of users.

 

The problem is, although the text file is being created in the proper folder, it isn't being written to and just remains blank.

 

<div align="center">

<table width="300" border="2" bordercolor="#FFFFFF" style="-moz-border-radius: 18px;

-webkit-border-radius: 18px;" height="120" cellpadding="0" cellspacing="0">

<tr>

<form name="form1" method="post" action="checklogin.php">

<td>

<table width="100%" border="0" cellpadding="3" cellspacing="1" background="images/loginbg.jpg"  style="-moz-border-radius: 15px;

-webkit-border-radius: 15px;">

<tr align="center">

<td colspan="3"><font color="#FFFFFF"><strong>Family Login </strong></font></td>

</tr>

<tr>

<td width="78"><font color="#000000">Username</font></td>

<td width="6">:</td>

<td width="294"><input name="myusername" type="text" id="myusername">

<?php

$myusername = $_POST['myusername'];

 

$data = "$myusername\n";

 

 

//open the file and choose the mode

$fh = fopen("logs/login.txt", "a");

 

fwrite($fh, $data);

 

fclose($fh);

 

?></td>

</tr>

<tr>

<td><font color="#000000">Password</font></td>

<td>:</td>

<td><input name="mypassword" type="password" id="mypassword"></td>

</tr>

<tr>

<td> </td>

<td> </td>

<td><input type="submit" name="Submit" value="Login">

</td>

</tr>

</table>

</td>

</form>

</tr>

</table>

</div>

 

I'm not sure what's going wrong but I'm guessing it's the placing of the php, or at least some of it.

I'd quite like to add the time they logged in as well. Any idea's anyone?  :)

Link to comment
https://forums.phpfreaks.com/topic/247038-php-not-writing-to-txt-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.