Page 1 of 1

is there a sane way to "preview before post"

Posted: Sat Jul 19, 2003 12:16 am
by goodmanbrown
I am working on a site that allows users to post text. So it's a little bit like a forum, except that the text they are posting may be quite long. Say, 20 - 30 standard pages of text, typically, and possibly longer. It is important that the users be able to preview their submission before comitting it to the database. The only way I have been able to implement this, so far, is to echo the text to the preview page, and then hide the same text in a form input field.

Something like this:

<!-- display the preview text to the user -->
<?php echo($text); ?>

<!-- ask if the user wants to comit the text to the db -->
<form ...>
<input type='hidden' value='<?php echo($text); ?>' ... />
<input type="submit' value='Save Text' />
</form>

The obvious problem with this is that it doubles the amount of text being sent to the browser. For a brief forum posting, this is no biggie, but when it is 30 pages, that could seriously bog down users on slow connections.

Is there a better way to do the preview? Is there some way to keep the $text variable alive on the server, so that it isn't necessary to store it in the hidden form field? If there isn't, do people think it would be better or worse to store the text in a temporary table in the database, and then re-insert it into a live table once the user confirms?

If anyone has any pointers to offer, I look forward to reading them.

Posted: Sat Jul 19, 2003 5:31 am
by Fredix
You can open a new window with the preview text if the post-writer is satisfied he can return to his post editing window and click submit.
I think thats a way, isn't it? ;)

...

Posted: Sun Jul 20, 2003 10:00 pm
by kettle_drum
Why not just save the text they entered to a table called check or something in your database - then simply pass the record id of it in the page. Then after they have checked it save the edited version to the real database and delete the check version.

Posted: Sun Jul 20, 2003 11:26 pm
by McGruff
Split into chapters & submit / preview one chapter at a time?

Posted: Mon Jul 21, 2003 3:51 pm
by xisle
Add the post to the database and set a flag "approved=NOW()", once they have previewed and given the ok.
Get fancy and delete the record if they 'cancel' before approval.