Re: What's the best way to do a preview/submit?

From: Date: Thu, 07 Sep 2000 14:09:01 +0000
Subject: Re: What's the best way to do a preview/submit?
Groups: php.general 
Request: Send a blank email to php-general+get-15713@lists.php.net to get a copy of this message
OJ, Addslashes() won't work if you are trying to put double quotes in the string of a hidden variable. That's HTML's problem; backslash is not special to it. You can use urlencode() as in <input type="hidden" name="news" value="<?php print(urlencode($text)) ?>"> Then you have to urldecode() $text after the next submission. BUT... Having a preview page with hidden variables is no safer than not having a preview page at all. Somebody can fake that second, "OK, that looks great, now submit it" post. Also, hitting Reload after posting will post it twice. An application just like this is how I discovered the usefulness of hidden variables. I store the article in a hash like $article["author"], $article["date"], ..., $article["text"], ...., then register it. The "preview and confirm page" displays the article, but the form only has a single input element: the submit button. The script that handles it next posts the article which has not in fact left the server, so is still clean. Then $article is deleted, so that if the user reposts, $article is gone and the script can reply, "You already posted the article; please go away." If you don't have session support (i.e., you are running PHP3 like me), may I suggest PHPLIB. HTH, Matt ---------------------------------------------------------------- Matthew Leingang http://www.math.rutgers.edu/ Rutgers University leingang@math.rutgers.edu Department of Mathematics "This signature needs no quote." On Wed, 6 Sep 2000, O.J. Alcaraz wrote: > I have simple news posting form. Just a couple of fields. I want to give the > user a chance to preview what he/she entered and then go ahead and submit. I > can pass the form data fine but the problem I'm running into is with double > quotes since in the preview page the data is placed in hidden inputs and > then submitted into the database. Is there anyway I can get around this? I > can't just use htmlspecialchars() or anything like that because I'm letting > the user enter HTML if they wish. Any help appreciated. > > O.J. Alcaraz > Abaris Technologies > > [ Part 16: "Included Message" ] >

« previous php.general (#15713) next »