What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP - storing a string

PHP - storing a string
Author: Message:
Weyzza
Veteran Member
*****

Avatar
SoCal sunset > *

Posts: 1170
Reputation: 29
– / Male / –
Joined: May 2003
O.P. PHP - storing a string
I need help in creating a simple page.

I make a page resembling http://thcnet.net/zork/index.php
But I have limited knowledge of PHP to create the same one.

So far, I have this:
code:
<?php

$prompt = $_POST['inputPrompt'];

if( strcmp( $prompt, "" ) == 0 ) {
    echo "&gt; " . $prompt;
    echo "<br />";
}

?>
<form action="index.php">...</form>

How do I make it remember the last entries before the form?
I know I might be able to use hidden input text, but it's dirty.

Thanks. I really appreciate it.
Registered 7660 days, 8 hours, 40 minutes, 46 seconds ago.
Happy Birthday, WDZ

07-12-2006 05:14 AM
Profile PM Find Quote Report
rav0
Veteran Member
*****

Avatar
i have an avatar

Posts: 1419
Reputation: 29
34 / Male / Flag
Joined: Aug 2003
RE: PHP - storing a string
You can't make PHP remember anything, each request is separate, and disappears once it's been served. You'll have to save it somewhere (eg. text file or database), as plain text or serialized.

You should give each visitor an ID number, and put that in a hidden form field, and use that when saving and loading the data already entered, else you will have different visitors' data all being mushed together.

I think that file-get-contents and file-get-contents might be sueful for saving/loading a text file, but there might be a better alternative for this situation (that I don't know).
| [Image: dorsh] |

(\ /)
(O.o)
(> <)

This is Bunny. Copy Bunny into your signature to help him on his way to world domination
07-12-2006 07:20 AM
Profile E-Mail PM Web Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: PHP - storing a string
rav0, it seems that you forgot about sessions... :p

http://php.net/manual/en/ref.session.php
07-12-2006 07:55 AM
Profile PM Web Find Quote Report
rav0
Veteran Member
*****

Avatar
i have an avatar

Posts: 1419
Reputation: 29
34 / Male / Flag
Joined: Aug 2003
RE: RE: PHP - storing a string
WDZ, it seems that I didn't know that sessions is a PHP feature ... (Y)
| [Image: dorsh] |

(\ /)
(O.o)
(> <)

This is Bunny. Copy Bunny into your signature to help him on his way to world domination
07-12-2006 08:12 AM
Profile E-Mail PM Web Find Quote Report
Weyzza
Veteran Member
*****

Avatar
SoCal sunset > *

Posts: 1170
Reputation: 29
– / Male / –
Joined: May 2003
O.P. RE: PHP - storing a string
quote:
Originally posted by WDZ
http://php.net/manual/en/ref.session.php
(Y) Nice feature to know...

I got it working :p
Thanks.
Registered 7660 days, 8 hours, 40 minutes, 46 seconds ago.
Happy Birthday, WDZ

07-13-2006 02:53 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On