Re: Are variables persistent?
| From: | Paul Furman | Date: | Mon, 16 Feb 2004 22:18:53 +0000 |
| Subject: | Re: Are variables persistent? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177876@lists.php.net to get a copy of this message | ||
Paul Furman wrote:
OK I'm confused. I want to set a variable with a form. How do I do that? I guess I need to put it in the url? I did a mail form & that worked by putting stuff in the $POST and when it refreshed to the same mail page, I grabbed the stuff back out of that (at least that's what I thought I was doing. Maybe I just put the new value in the url with the action property of the form and forget about the $POST part. I guess I don't know how that worked for the mail script.I had the script below working to extract the results of $POST[thumbs]. Assuming I can get that going again, would I then redirect with header() putting the new value in the url? The problem is I want it to stick to the pictures page (not this settings page) every time I go to that page so I'd have to tack it on to any page on my site and keep checking for it everywhere to keep it. I'm guessing this is not a sensible approach. Every place I construct a url, I'd have to remember to add this. <broken now but I can fix it again if it'll work> <h1>Change Settings</h1> <center> <div class="textbox"> <?php if ($POST){
if (isset ($POST['thumbs'])){
$pics = $POST['thumbs'];
print "settings-out:".$pics." "; #work(ed) after posting
print "settings have been changed";
####### redirect here to the picture page ########
####### with $pics value in the url ########
####### header() exit() ########
}
} ?>
<form name="mail" action="<?php SCREEN_DIR . "/settings.php" ?>"
method="post">
<label for="thumbs">number of thumbnails per page: </label>
<input type="text" name="thumbs" id="thumbs" size="2"
value="<?php print $pics ?>">
<button type="submit">OK</button>
</form>
</div>
</center>