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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.