lewisstevens1 Posted December 14, 2008 Share Posted December 14, 2008 Hi i think i have to use the php function $_post and $_get functionis... but i am not sure... i have a image showing what i want to do, can someone help me, its verry basic but looking around on all forums i cant find. it needs to be stored on a server for a bit untill then next submition of the data. i want it so they can post a daily update of the progress of the development. heres a link to the image: http://i261.photobucket.com/albums/ii64/lewisstevens1/sever.jpg Quote Link to comment Share on other sites More sharing options...
Mad Mick Posted December 14, 2008 Share Posted December 14, 2008 Perhaps not as basic as you think since it involves data storage not just processing post or get. If you want some control over passwords and users and want to save a progression of progress comments then MySQL is the best route and won't be too difficult to implement once you learn the basics. If you really only want to display a page and that can be overwritten, and you're prepared to hard code a password then you can forget MySQL and treat it as a very simple content management system. The admin page would require a password matching something saved in your php file, the page would then convert the entered data to a file e.g. xml, the user page would then just call this page up. 2nd method is simpler but 1st may be more useful and rewarding in the long run... Quote Link to comment Share on other sites More sharing options...
revraz Posted December 14, 2008 Share Posted December 14, 2008 Looks to me like you need sessions. Quote Link to comment Share on other sites More sharing options...
lewisstevens1 Posted December 14, 2008 Author Share Posted December 14, 2008 lol well the page will only be one password which i can easily do on my server... nothing to code. but i just want something which overwrites the last post... it should just be like a display window.. where you see whats posted in there, though when you log off it will stay there untill someone changes it. Quote Link to comment Share on other sites More sharing options...
Mad Mick Posted December 14, 2008 Share Posted December 14, 2008 Then go for the 2nd choice of saving an xml file via the admin page then loading it in on the user page... No sessions, no database needed. Quote Link to comment Share on other sites More sharing options...
lewisstevens1 Posted December 14, 2008 Author Share Posted December 14, 2008 im sorry i dont understand how that can work? is there anynew code i need to add? Quote Link to comment Share on other sites More sharing options...
Mad Mick Posted December 14, 2008 Share Posted December 14, 2008 Well its not something I have done much myself so don't know the most secure way etc. but the following is the basic idea: admin.html <form method="post" action="processAdmin.php"> <textarea rows="5" cols="20" name="progress"></textarea> <input type="submit" /> </form> processAdmin.php $progress=CLEANED VERSION of $_POST['progress']; $f=fopen("progress.txt","w"); fputs($f,$progress); //$progress is the text you want to display from the admin form fclose($f); and the user page: user.php $f=fopen("progress.txt","r"); while (!eof($f)){ $line=fgets($f); echo $line,"<br/>"; } fclose($f); Not tested I'm afraid so if that works first time you're a lucky person. As I say I may have overlooked some security issues since I've never used this in anger only when I was first learning PHP. I'm sure others will let you know if I have!! Quote Link to comment Share on other sites More sharing options...
lewisstevens1 Posted December 14, 2008 Author Share Posted December 14, 2008 Thankyou Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted December 14, 2008 Share Posted December 14, 2008 If you want a session login, here is how http://djw-webdesign.awardspace.com/code.php?snippet=9 Quote Link to comment Share on other sites More sharing options...
lewisstevens1 Posted December 15, 2008 Author Share Posted December 15, 2008 Kk thankyou guys =D Quote Link to comment Share on other sites More sharing options...
lewisstevens1 Posted December 15, 2008 Author Share Posted December 15, 2008 =S well the code does not work, though unlike HTML and CSS... i dont av a clue what half of it does. i understand while get echo $ $_post and all this <form method="post" action="processAdmin.php"> <textarea rows="5" cols="20" name="progress"></textarea> <input type="submit" /> </form> just not sure about the rest Quote Link to comment Share on other sites More sharing options...
lewisstevens1 Posted December 15, 2008 Author Share Posted December 15, 2008 The error i get from admin.html is: $progress=CLEANED VERSION of $_POST['progress']; $f=fopen("progress.txt","w"); fputs($f,$progress); //$progress is the text you want to display from the admin form fclose($f); So it just displays the code of the page after i have pressed submit, after entering some data. then it just stays there, so i edit the url to /user.php then it just comes up with: $f=fopen("progress.txt","r"); while (!eof($f)){ $line=fgets($f); echo $line," "; } fclose($f); Quote Link to comment Share on other sites More sharing options...
lewisstevens1 Posted December 15, 2008 Author Share Posted December 15, 2008 Please help someone Quote Link to comment Share on other sites More sharing options...
Mad Mick Posted December 15, 2008 Share Posted December 15, 2008 OK - I didn't post the exact script, just a suggestion on what to do... This should at least work: processAdmin.php <?php $progress=$_POST['progress'];//forget about cleaning up for now... but it must be done somewhen $f=fopen("progress.txt","w"); fputs($f,$progress); //$progress is the text you want to display from the admin form fclose($f); echo "Progress updated"; ?> <!-- You can now add some html to link to wherever you want.. --> user.php <?php $f=fopen("progress.txt","r"); while (!eof($f)){ $line=fgets($f); echo $line,"<br/>"; } fclose($f); ?> No disrespect, we all have to start somewhen, but if you did not spot that I missed the <?php ?> tags then perhaps you need to do a bit of learning first. I have posted a basic framework - you should adapt to suit your needs with html doctypes/tags etc. Quote Link to comment Share on other sites More sharing options...
lewisstevens1 Posted December 15, 2008 Author Share Posted December 15, 2008 Well i did notice that you missed out the <? > but i added them in after... i though u just misstyped lol... Quote Link to comment Share on other sites More sharing options...
revraz Posted December 15, 2008 Share Posted December 15, 2008 My advice would be to learn a bit more PHP so you can understand the code. =S well the code does not work, though unlike HTML and CSS... i dont av a clue what half of it does. i understand while get echo $ $_post and all this <form method="post" action="processAdmin.php"> <textarea rows="5" cols="20" name="progress"></textarea> <input type="submit" /> </form> just not sure about the rest Quote Link to comment Share on other sites More sharing options...
lewisstevens1 Posted December 15, 2008 Author Share Posted December 15, 2008 Fatal error: Call to undefined function eof() in /home/stonersg/public_html/Lee/user.php on line 3 i have: <?php $f=fopen("progress.txt","r"); while (!eof($f)){ $line=fgets($f); echo $line,"<br/>"; } fclose($f); ?> so line 3 is: while (!eof($f)){ which calls f? mmm im just wondering about the progress.txt ive created a file on my server called progress.txt and saved as a blank .txt doc... is that whats needed? Quote Link to comment Share on other sites More sharing options...
Mad Mick Posted December 15, 2008 Share Posted December 15, 2008 ooops - should be - !feof($f) you don't need to create progress.txt manually - the admin page should do that for you (if it worked). Quote Link to comment Share on other sites More sharing options...
lewisstevens1 Posted December 15, 2008 Author Share Posted December 15, 2008 yey that works.. thanks.. but do you know if you can make it look like its in a disabled text box, i used to be able to do, but it may be cus its in a .php file, normally i put it around e.g. <html> <form = wateva disabled> <php? ?> </form> </html> Quote Link to comment Share on other sites More sharing options...
Mad Mick Posted December 16, 2008 Share Posted December 16, 2008 You mean to display as a text box in the user.php file? If so: <form> <!-- not sure what you want to do with it if anything... --> <textarea rows="5" cols="20" disabled="disabled"><?php $f=fopen("progress.txt","r"); while (!eof($f)){ $line=fgets($f); echo $line,"<br/>"; } fclose($f); ?></textarea> </form> Quote Link to comment Share on other sites More sharing options...
lewisstevens1 Posted December 16, 2008 Author Share Posted December 16, 2008 Cool thankyou guys.. it all works now =D i can start playing around the code to suit my needs a bit more =D thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.