[PHP] Variables that persist through reload?
Hey, I'm somewhat new to PHP and I'm doing a lot of forms stuff. Looking at some of the examples at: http://www.linuxguruz.org/z.php?id=33 The variables seem to persist through a reload. For example, the first demo has: if (!isset($pick)) { echo "Fill out and submit the form below."; } else { $j = count($pick); for($i=0; $i<$j; $i++) { echo "Pick $pick[$i] is Checked"; } } ?> Painting Plumbing Electric So the $pick variable is maitained through the submit. When I demo the script on that site, it works as advertised. When I use the same code on my web server, it doesn't work ($pick is never set after submitting). Is there some configuration option that dictates whether variables persist in this manner? Thanks, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables that persist through reload?
Ahhh.that explains it. Just read up on register_globals. I understand now. To make the script work with register_globals off I can just do: $pick = $_GET['pick']; And then the rest works. Thanks! -Dave Joseph W. Goff wrote: Your local version does not have register_globals turned on in php.ini. You can either set the value = on or access posted values by using $_POST or $HTTP_POST_VARS depending on your version of php. - Original Message ----- From: "David Chamberlin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, January 03, 2003 1:58 PM Subject: [PHP] Variables that persist through reload? Hey, I'm somewhat new to PHP and I'm doing a lot of forms stuff. Looking at some of the examples at: http://www.linuxguruz.org/z.php?id=33 The variables seem to persist through a reload. For example, the first demo has: $pick[$i] is Checked"; } } ?> Painting Plumbing Electric So the $pick variable is maitained through the submit. When I demo the script on that site, it works as advertised. When I use the same code on my web server, it doesn't work ($pick is never set after submitting). Is there some configuration option that dictates whether variables persist in this manner? Thanks, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] One more form question
OK, last one was answered quickly and successfully (thank you!), so here's another one. Is there an easy way to set something in a select list to be selected? Right now I'm doing a real brute-force method. e.g., echo ""; $choices = array( 'pub' => 'On Public Page', 'members' => 'Only on Members Page', 'nodisp' => 'Do not Display' ); foreach ( $choices as $key => $choice ) { $selected = ''; if ( strcmp( $key, $member_info->display_address ) == 0 ) { $selected = 'selected'; } echo "$choice"; } echo ''; I've got to imagine there's a better way Thanks, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: E-mail redirection....?
You might see if your server is running procmail. If it is, then you can have your .procmailrc file auto-generated from PHP, and then procmail will do all the forwarding for you. The procmail recipe will be pretty simple for what you want (e.g.,) # user_id -> [EMAIL PROTECTED] :0 * ^TO([EMAIL PROTECTED]) ! [EMAIL PROTECTED] If you want to also handle cases where the user was BCC'd, then you might also put this in: :0 * ^Received.*for..user_id.mydomain.com ! [EMAIL PROTECTED] So when a new id is created (or user changes their target e-mail address) you can run through a script that foreach of the user_id values, it creates the above procmail recipe - dump it into the .procmailrc file and you're set. -Dave Michal Stankoviansky wrote: Hi I'm totally confused. What I need is the following: User registers and I need to create an e-mail alias for him, something like [EMAIL PROTECTED] If someone sends an e-mail to the above address, I need to redirect it to the user's real e-mail address. I'm totally lost...can this be done in PHP? Thanx for help, please save me :) Michal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Recommended freeware guestbook?
Hey, Anybody have a php-based guestbook that they like and can be freely downloaded? Don't need anything really fancy, just for a personal website. Easy-to-use, and not hard to integrate into the site would be bonuses (mysql not a problem). I've looked around, and there's a bunch out there - I'm just looking for recommendations of what people like. Thanks, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sessions problem
Hey all, Some of my users have reported a problem with my site and it's taken a while to debug it, but I think I've finally tracked it down. If they go to the site as: http://www.mysite.org/ Then it works But if they go as: http://mysite.org/ It doesn't. I believe it has to do with my use of session variables. Apparently (I didn't know this, but it's obvious from the debugging) that there are different session ID's and thus different session variables for the two. And the problem is (due to sloppy programming on my part ... sigh ...) that sometimes I set up the links as and sometimes I do the explicit http://www.mysite.org/">. So when it goes to the link as www.mysite.org, it registers the variables, but then later when it tries to access and it's just mysite.org, the variables aren't set. Lots of confusion ensues. Is there any way to unify this, or do I have to go through and fix all of the absolute links to be relative? Thanks, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: sessions terminating randomly please help
It's possible you're being afflicted with the same problem I am. See the message just one or two above this about "Sessions problem". What I found in my debugging is that it had to do with how I was mix-and-matching the way I specified links. Short version of the problem is that http://mysite.org/ has one session and http://www.mysite.org/ has another. In my code, I sometimes have the links as and sometimes it's explicit, as http://www.mysite.org/";>. So if a user went to the site as http://mysite.org - the pages that used the explicit www.mysite.org would fail. So if there's anything in your pages/links that may change how the link is referred, you may be have different sessions occuring. I would imagine it should be pretty easy for you to debug whether or not this is the problem. Have each of your pages echo out the current session id (echo 'session is '.session_id().'';) and see if it changes at any point, and especially on the pages that fail. -Dave Freaky Deaky wrote: hi i am experiencing a major problem with sessions expiring randomly in some of my apps. i will log in and start clicking around and then i will eventually arrive at a page that tells me that i'm not logged in anymore. this happens apparently randomly. i have seen it on ie6, ie for mac, netscape 4.7 for pc, and mozilla the apps are hosted on freebsd 4.7-release p2 apache 1.3.27 php version 4.2.3 compiled with --enable-trans-sid i can't go into production if there's the possibility that users will be randomly logged off. i went through all of my code over the weekend, and i don't think i can attribute this to a miscoding: when a user logs in, i create a session with session_start(); $valid_user=$_POST['username']; session_register("valid_user"); i have the following code at the top of each page to check to see if the session is valid: session_start(); $valid_user=$_SESSION['valid_user']; global $valid_user; if (session_is_registered("valid_user") {...function to spit out an error message if the session is not valid...;} i have a logout page that destroys the session session_start(); session_destroy(); i also have a javascript timer in the header of every page that redirects to the logout page if the user has been inactive for 20 minutes. i have played around with session.gc_probability, setting it to 100, but that doesn't seem to have fixed the problem. this is a huge problem. if anyone can give some advice, i'd really appreciate it. thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php