I cant get this to work, I put the code inside html, head and body tags and saved it as .php file it just displays a page of the code and nothing else.
How did you test it. Am I doing something wrong
Printable View
I cant get this to work, I put the code inside html, head and body tags and saved it as .php file it just displays a page of the code and nothing else.
How did you test it. Am I doing something wrong
damn spam...
Edit: no more spam! thanks
The actual php code displays? Check your <?php ?> tags and make sure you have all the php code contained within. You also need to create a subdirectory named "write" in the same directory as this file. Otherwise, I'm not sure what the problem would be. The code I posted is *exactly* what I have online here.
Got the web page to display but when i click Submit I get this message
Comments submitted so far:
Fatal error: Call to undefined function filter_var() in /www/htdocs/TEST.php on line 50
Not sure what could be wrong your code is just copy and pasted to my file.
What version of PHP do you have installed? If it is below PHP 5, then filter_var will not work.
Hope this helps.
yeah. contact your webhost; sometimes they can upgrade. 1and1, for example, advertises php5 but runs php4 by default and you have to use .htaccess to switch to php5.
alternatively, replace this line:
with this:PHP Code:$filecontent = filter_var($RAWfilecontent, FILTER_SANITIZE_STRING);
which will also make the user input safer, but won't look as nice. For example, if someone tried to attack your site by saving a message like this:PHP Code:$filecontent = htmlentities($RAWfilecontent);
FILTER_SANITIZE_STRING would strip the tags (preventing the code from running) and display it like this:Code:<script type="text/javascript">
window.location = "www.endlesspopups.com"
</script>
and htmlentities would encode the < > characters (preventing the code from running) and display the original message just as you see it above.Code:window.location = "www.endlesspopups.com"
It'S PHP Version 5.1.6 , I am using a freehost service just for testing and learning.
I modified that line and it works, but the posted messages are not in the order they were posted it semes to be random.
If you're running php5, then filter_var ought to work (and would be preferable, IMO). Likewise, I don't know why the messages would be being displayed in random order. Would you link to your test page?
Link to test page
http://yabadabadoo.blackapplehost.co...New%20TEST.php
Link to Php info page
http://yabadabadoo.blackapplehost.co...ver%20Info.php
... no idea.
it does seem to be random. but it seems to always be in the same random order (except for each new submission, of course).
I have come up with a solution to show the files from the last one posted, first i open the filecount.txt file and get the number stored in it, then i use it to count backwards and then include the .txt file on the page. Here is the code
And a link to itPHP Code:<?php
$filename= "filecount.txt" ;
$fd = fopen ($filename , "r") or die ("Can't open $filename") ;
$fstring = fread ($fd , filesize ($filename)) ;
include('write/'.--$fstring.'.txt');
include('write/'.--$fstring.'.txt');
include('write/'.--$fstring.'.txt');
include('write/'.--$fstring.'.txt');
include('write/'.--$fstring.'.txt');
include('write/'.--$fstring.'.txt');
include('write/'.--$fstring.'.txt');
include('write/'.--$fstring.'.txt');
include('write/'.--$fstring.'.txt');
include('write/'.--$fstring.'.txt');
include('write/'.--$fstring.'.txt');
include('write/'.--$fstring.'.txt');
fclose($fd) ;
?>
http://yabadabadoo.blackapplehost.co.../Showfiles.php
Now the problem here i all the text is bunched together.
What i would like is to have a break between each file include, I tryed putting in echo <br> but nothing would display.
Also the code is long I am sure a loop or something could be writen to do what all the above includes are doing, If posible i would like it to just display the last 20 files posted with a link then for the next 20 and so on, I hope somebody is up to this challenge a my php is very basic and getting the above code working was not easy for me.