
Strac72
Members-
Posts
24 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
Strac72's Achievements

Newbie (1/5)
0
Reputation
-
I'll look into it tomorrow now. Thanks, David.
-
"\n\n" Has done the job! Woo hah! I think I'll have a cuppa Thanks very much for the guidance.
-
yes, but when I tried that, it actually wrote: \nuser date&time
-
Thanks Pikachu. I gleaned that I'd have to use date_default_timezone_set('Europe/London'); which automatically added the +1 hour I was looking for. I hope it changes back at Halloween or whenever it is. On the road to perfection, I tried creating a $ that was blank to insert a line break into the text file, I tried $blank = '<br />'; and then asking it to fwrite($fh, $blank); but that hasn't worked. Don't really know how to term it for a web search. Crikey, my brain aches!
-
After a few hours and a lot of swearing, I ended up with this: <?php date_default_timezone_set('GMT+01.00'); $date = date(r); $myusername = $_POST['myusername']; $data = "$myusername\n"; $date = "$date\n"; $fh = fopen("logs/login.txt", "a") ; fwrite($fh, $data); fwrite($fh, $date); fclose($fh); ?> Which has worked, apart from the timezone bit, which still reads as an hour behind. Bloomin' BST. It'll be over in a few weeks! Give a dog a bone!
-
I am using this php to write to a text file to show me who has logged in and when: <?php $time = $_SERVER['REQUEST_TIME']; $myusername = $_POST['myusername']; $data = "$REQUEST_TIME\n"; $data = "$myusername\n"; //open the file and choose the mode $fh = fopen("logs/login.txt", "a") ; fwrite($fh, $data); fwrite($fh, $time); fclose($fh); ?> The result I get in my text file is: paul 1315919200melody 1315919221tracy&graham 1315919232ed&hannah 1315919251 I would feel more successful if the name of the user were to appear on the next line down but I can live with that but I can't make head nor tale of the date. I want it to say: paul 13:59 13/09/2011 next user 14:00 13/09/2011 and so on I feel I have done very well to even get that far really and wouldn't have been able to yesterday. I am frustrated to have reached the extent of my current understanding. If anyone can tell me where I'm going wrong, that would be great. I hope the php isn't too far off, and you can "read between the lines" as it were to see what I'm trying to do. Paul MOD EDIT: code tags added.
-
Actually, I've sussed the write part. I just needed to move the php to the checklogin.php page. Would still appreciate help adding the time of login to that though!
-
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?
-
You deserve the guru bit Adam! Thanks very much indeed. 8) I suppose I've learned 3 things today: 1. Always give out an entire script if asking for help. 2. Don't trust Fireworks generated code. 3. There are good folk in the online community who do it because they love it. Actually, make that 4; my distinction in Designing and creating advanced websites isn't worth the paper it's printed on. Cheers City & Guilds and Trowbridge college. Thanks again Adam.
-
I have ended up with this: <script type="text/javascript"> window.onload = function() { timedHide(document.getElementById('message'), 10); } function timedHide(element, seconds) { if (element) { setTimeout(function() { element.style.display = 'none'; }, seconds*1000); } } </script> </head> <body onload="MM_preloadImages('../images/buttons/downloadNeg.png')"> <div align="center"><img src="../cinema/motw_images/movie_download.png" width="378" height="182" /></div> <h3 align="center"><strong>This week's film is:</strong></h3> <h1 align="center"><strong>"Source Code"</strong></h1> <div align="center"> <a href="http://db.tt/XdFJgqM" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('downmotw','','../images/buttons/downloadNeg.png',1)"><img src="../images/buttons/download.png" name="downmotw" width="150" height="75" border="0" id="downmotw" /></a></div> <p align="center"><strong>If the file starts to play in your media player and you want to watch it later, right click the button and choose 'save as' or 'save link as'.</strong></p> <div align="center"> <table width="100%" border="0" cellspacing="10"> <tr> <td><h2 align="center"><strong><u>Description</u></strong></h2></td> <td> <form name="input" action="motw.php" method="post"> <h4>Want a specific film? <input type="text" width="300" name="requests" /> <input type="submit" value="Request" /></h4> </form> <?php $requests = $_POST['requests']; $data = "$requests\n"; $fh = fopen("../filmoftheweek/users.txt", "a"); fwrite($fh, $data); fclose($fh); if (!empty ($_POST)) print '<span id="message">Ok, I\'ll see what I can do.</span>'; ?> </td> Which leaves the message on the screen in Firefox, Chrome and IE. Haven't tested it on other browsers but I don't think it's that. Anybody got any ideas?
-
Sorry, Adam. It just doesn't work
-
Not to sound thick, but, how do I assign an ID to the element? it only exists as a print command: print "Ok, I'll see what I can do."; I did try adding it to the form, but I know that's not the right place on thinking a bit harder: <form name="input" action="motw.php" method="post"> <h4>Want a specific film? <input type="text" width="300" name="requests" id="message" /> <input type="submit" value="Request" /></h4> </form> I really don't know how to assign it Adam. I did try looking around on the net so as not to just have it all done for me, but to no avail!
-
There isn't an onload handler, that's the whole of the script here. I have no idea how to implement the javascript within it. It's a maybe a simple little thing but it took me about 8 hours to get that working from what I could glean from tutorials and help composing the php if statement from kind folk at the php forum. That's my level of expertise, I'm afraid! I am learning. This isn't for a public site.
-
Yes, it's only a single text field, within a table, and the message comes up beneath the field on clicking the request button. It also writes to a text file but it would be nice if the message disappeared again after 10 seconds as there's plenty of other stuff on the page to look at and do. I just know that if you submit a form and get no message, users are wondering if anything has happened.
-
After much fizzling of brain and some help on here, I managed to get this script to do what I wanted: <td> <form name="input" action="motw.php" method="post"> <h4>Want a specific film? <input type="text" width="300" name="requests" /> <input type="submit" value="Request" /></h4> </form> <?php $requests = $_POST['requests']; $data = "$requests\n"; //open the file and choose the mode $fh = fopen("../filmoftheweek/users.txt", "a"); fwrite($fh, $data); fclose($fh); if (!empty ($_POST)) print "Ok, I'll see what I can do."; ?> </td> I would now like to make the echo/print disappear again after 10 seconds. Is there any way to do this? Thanks in advance, Paul