Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 11-06-2005, 12:24 PM Moody
Miki's Avatar
Skilled Talker

Posts: 72
Name: Michael Stubbs
Location: Warrington, UK
Trades: 0
Hi everyone. I'm a bit of a newbie when it comes to PHP and was wondering if you could help me.

On my site, I'm making a page about me, and I would like it to display my current mood. I would like it to be easyly updateable.

I would like it done using a form, PHP and mySQL (unless there is another, easyer way).

So for example, I tick a box in a form that says I'm in an angry mood. That then saves that information to a database and when someone loads the page, it gets that information and displays an image accordingly.

If you do not make the script, please will you give me a link to something that could possibly help? (Before you say anything, I HAVE tryed Googling it for like an hour now, and havnt found any useful results.)

I think PHP would be the best way to do this. I'm not sure about that though. I might be making things over-complicated for myself.

Thank you in advance,
from MIKI
Miki is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-06-2005, 01:22 PM
Ultra Talker

Posts: 251
Location: Belgium, Antwerp, Zoersel
Trades: 0
Well, that's not to hard. All you have to do is to save the text from the form in a file (e.g. "mood.txt"), then read it again.

Example:
Form page:
Code:
<html>
<head>
<title>Form</title>
</head>
<body>
<?php
if($_POST['mood']){
  $file=fopen('mood.txt', 'w');
  if(fwrite($file, $_POST['mood']))
    echo 'Mood saved successfully<br/>';
  else
    echo 'Failed to save mood<br/>';
  fclose($file);
}
?>
<form action="<?php echo $PHP_SELF; ?>" method="POST">
  New Mood: <input type="text">
</form>
</body>
</html>
The script to read from it would be:
PHP Code:
<?php
$mood 
fread('mood.txt'filesize('mood.txt'));
echo 
$mood;
?>
I hope this helps.
Orodreth is offline
Reply With Quote
View Public Profile Visit Orodreth's homepage!
 
Reply     « Reply to Moody
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.55694 seconds with 12 queries