Shoutbox

PHP - storing a string - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: PHP - storing a string (/showthread.php?tid=63094)

PHP - storing a string by Weyzza on 07-12-2006 at 05:14 AM

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.
RE: PHP - storing a string by rav0 on 07-12-2006 at 07:20 AM

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).


RE: PHP - storing a string by WDZ on 07-12-2006 at 07:55 AM

rav0, it seems that you forgot about sessions... :p

http://php.net/manual/en/ref.session.php


RE: RE: PHP - storing a string by rav0 on 07-12-2006 at 08:12 AM

WDZ, it seems that I didn't know that sessions is a PHP feature ... (Y)


RE: PHP - storing a string by Weyzza on 07-13-2006 at 02:53 AM

quote:
Originally posted by WDZ
http://php.net/manual/en/ref.session.php
(Y) Nice feature to know...

I got it working :p
Thanks.