php-general Digest 27 Dec 2008 19:56:33 -0000 Issue 5868
Topics (messages 285089 through 285109):
Re: uri/url help
285089 by: Nathan Nobbe
Re: Do defined variables exist at application scope, or session scope?
285090 by: Nathan Nobbe
PHP script gives no output or error message
285091 by: John Musbach
285103 by: Daniel Brown
Re: Decorator with public methods
285092 by: Nathan Nobbe
285107 by: Larry Garfield
285109 by: phphelp -- kbk
Is it PHP Bug - memory leak ?
285093 by: Pawel Rutkowski
285097 by: Daniel Brown
PHP Help Needed
285094 by: Ayemowa Toyin
285095 by: Ashley Sheridan
285100 by: Dotan Cohen
285102 by: Daniel Brown
285105 by: Dotan Cohen
285108 by: John Corry
Re: Online Members
285096 by: Daniel Brown
285104 by: Michael Kubler
285106 by: Nathan Nobbe
Page name for form submit: REQUEST_URI or SCRIPT_NAME
285098 by: Dotan Cohen
285099 by: Daniel Brown
285101 by: Dotan Cohen
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Sat, Dec 27, 2008 at 12:08 AM, Robert Cummings <rob...@interjinn.com>wrote:
> On Fri, 2008-12-26 at 22:02 -0800, Kenton P. Kammer wrote:
> > I'm trying to make something to redirect people to my home page if they
> some how access my include pages. For example, I have a generic copyright
> .htm with links in it that I add to all my pages with the include().
> Problem is when I'm trying to make it the uri is always where it is in the
> include folder I made, even when I'm on the home page trying to view the
> links. This is what I have:
> >
> > <?
> > $uri=$_SERVER["REQUEST_URI"];
> > if($uri=='/'.strpbrk($uri, 'include')){header("Location:
> ../index.php");}
> > else{
> > ?>
> > <p>page content</p>
> > <? } ?>
> >
> > But the error is that since it always returns the /include/...htm uri
> even when I'm viewing it on http://www.domain.com/index.php
> >
> > Help please! Thank you!
>
> The most common way to do this (I think) is to define a variable in your
> site's main config. In each include file test for it having been set. If
> it is not set, then the file is being accessed improperly and so you
> redirect.
>
> For instance:
>
> File: myConfig.php
> ------------------
> <?php
>
> define( 'MY_CONFIG_LOADED', 1 );
>
> ?>
>
> File: myClass.php
> -----------------
> <?php
>
> if( !defined( 'MY_CONFIG_LOADED' ) )
> {
> header( 'Location: http://www.foo.bar.nuh.uh.com/403.php' );
> }
>
> ?>
>
> On a related note though... they probably shouldn't be able to dig
> around your include directory in the first place. Better to deny those
> requests via a webserver config (usually a .htaccess file).
>
this is the approach taken by code igniter, and i think it has 2 strong
points,
1. no .htaccess mechanism required, that is, portable across webservers that
support php
2. the code can be placed directly in the webroot; this in contrast to
placing files you dont want accessed outside of the webroot and into the
include_path
-nathan
--- End Message ---
--- Begin Message ---
On Sat, Dec 27, 2008 at 12:54 AM, Murray <planetthought...@gmail.com> wrote:
> Hi Larry,
>
> You're absolutely right, I'm talking about constants rather than variables.
>
> I guess in my very crude way, I'm trying to ask about the following:
>
> UserA goes to the site via index.php, which defines several helpful
> constants.
>
> So do UserB through UserF.
>
> UserG, however, first arrives at the site on help.php.
>
> Because UserA, UserB, UserC etc have been to index.php, which has now been
> executed, are the constants available with their values in help.php, even
> though UserG, in particular, started in the application at this point?
>
> So, another way of putting it, do these constants live for the life of the
> application per se (ie, presumably until the server is restarted etc), or
> will code in help.php be unable to access the values of defined constants
> for this particular user because they were not at index.php first?
no, global variables do not persist at a session level.
you could easily discover this with a simple test (following code untested
:)).
testDefineScope1.php
<?php
define('MY_GLOBAL', 5);
session_start();
$_SESSION['SESSION_VAR'] = 10;
testDefineScope2.php
<?php
var_dump($_SESSION['SESSION_VAR']);
var_dump(MY_GLOBAL);
test,
1. go to testDefineScope1.php
. MY_GLOBAL will be defined for the duration of testDefineScope1.php's
execution
. $_SESSION['SESSION_VAR'] will be placed into the session
2. go to testDefineScope2.php
. $_SESSION['SESSION_VAR'] is in the session and will be displayed
. MY_GLOBAL expired after testDefineScope1.php finished executing and
therefore a fatal should be raised at thte second statement
-nathan
--- End Message ---
--- Begin Message ---
I have the latest version of FUDforum setup and am trying to create a
hack that'll allow users who authenticate through our groups kerberos
authentication gateway to automatically be logged in. The source code
is as follows:
<?php
//Here we grab the authenticated user's name
//and either automatically log them in using an existing account
//or register them
error_reporting(E_ALL);
ini_set('display_errors',1);
require('/users/u15/jmusbach/.html_pages/FUDforum2/GLOBALS.php');
require('/users/u15/jmusbach/FUDforumDAT/scripts/fudapi.inc.php');
require('/users/u15/jmusbach/FUDforumDAT/scripts/forum_login.php');
global $_SERVER;
$user=$_SERVER['WEBAUTH_USER'];
$realname = $_SERVER['WEBAUTH_LDAP_GIVENNAME'] . ' '
.$_SERVER['WEBAUTH_LDAP_SN'];
$email = $user . '@blah.com';
$error="";
if(external_fud_login(fud_fetch_user($user)['id']))!=NULL) //User ID
is valid and logged in
{
echo("Welcome, " . $user . ", please wait while you are logged in...");
header( 'Location: https://blah.com/~jmusbach/FUDforum2/' ) ;
}
else //User ID is invalid, register and log in
{
echo("Welcome, " . $user . ", please wait while you are registered
and logged in...");
if(fud_add_user(array($user,"password",$email,$realname),$error)!=0)
{
external_fud_login(fud_fetch_user($user)['id']));
header('Location: https://blah.com/~jmusbach/FUDforum2/');
}
else
{
echo($error);
die();
}
}
?>
Unfortunately no errors are returned and the output is completely
blank, any ideas as to where I've gone wrong (e.g. obvious syntax
errors)? I'm new to PHP so I've probably done something with the
syntax that you're not supposed to do in PHP. I would gladly ask this
question in the FUDforum support forums but despite it being many days
since I've registered the administrator still has yet to manually
activate my account so hopefully I can get some help here. :)
P.S. In case it helps you can see the source code to the API files I
referenced here:
fudapi.inc.php: http://pastebin.com/m349a4bff
forum_login.php: http://pastebin.com/m176b28b3
--
Best Regards,
John Musbach
--- End Message ---
--- Begin Message ---
Good afternoon, John;
On Sat, Dec 27, 2008 at 03:28, John Musbach <johnmusba...@gmail.com> wrote:
[snip!]
There's a syntax error on line 19:
> if(external_fud_login(fud_fetch_user($user)['id']))!=NULL) //User ID is valid
> and logged in
It should be:
if(external_fud_login(fud_fetch_user($user['id']))!=NULL)
//User ID is valid and logged in
--
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!
--- End Message ---
--- Begin Message ---
On Sat, Dec 27, 2008 at 12:02 AM, Larry Garfield <la...@garfieldtech.com>wrote:
> On Friday 26 December 2008 11:06:07 pm Nathan Nobbe wrote:
>
> > to summarize, using your example above, i would most liely add doThings()
> > to Baz, or create another decoration interface for doThings() if you plan
> > on using the Bar implementation of doThings() in many places,
> >
> > interface G {
> > function doThings();
> > }
> >
> > class Bar extends Decorator implements G {
> > function doThings() {
> > // concreate implementation
> > }
> > }
> >
> > class Baz implements F, G {
> > // recycle Bar::doThings()
> > public function doThings() {
> > return $this->foo->doThings();
> > }
> > public function doOtherThings() {}
> > }
> >
> > i appologize if this response is long winded, but im a big fan of the
> > decorator, and ive actually got some pretty slick code in production in
> the
> > photobucket code that uses the decorator pattern :D it took about 2
> months
> > to code, and i leraned a lot about some of the practical aspects of
> > decroration, specifically within the realm of php. i know i repeated a
> few
> > things there, but i felt it neccessary to better explain myself.
> >
> > -nathan
>
> Thanks, Nathan. Unfortunately, what you describe is impossible. It
> requires
> me to know all the possible decorators ahead of time and implement the
> interface for each in each decorator, at which point I've gotten no benefit
> at
> all over just putting everything in the original base class in the first
> place.
> That defeats the purpose of decorators if I can't come up with a new one a
> month from now and not have to modify any of the existing code.
i see it more on a need-to-expose basis. for example, why not, when
presented w/ the current problem, just expose, Baz::doThings() now, b/c you
know you need it in Baz instances ? later if you find theres another method
thats in Bar that isnt yet exposed, you just go in and add a similar wrapper
for it in Baz at that time. this is a typical flow in a layered
architecture in my experience; often times controllers are revised to expose
a new entry point for something on the backend that previously was
unavailble from the front end, just as an example.
i only pull interfaces into the equation when i what to bring a group of
things together, it certainly isnt necessary to define a second interface,
but i was just trying to highlight doThings() as your example essentailly
had 2 layers of decorators, G(F(Foo)), as i saw it. from a design
perspective, yes, id probly not define G unless / until i saw a need to join
a group of classes explicitly.
-nathan
--- End Message ---
--- Begin Message ---
On Saturday 27 December 2008 2:49:22 am Nathan Nobbe wrote:
> > Thanks, Nathan. Unfortunately, what you describe is impossible. It
> > requires
> > me to know all the possible decorators ahead of time and implement the
> > interface for each in each decorator, at which point I've gotten no
> > benefit at
> > all over just putting everything in the original base class in the first
> > place.
> > That defeats the purpose of decorators if I can't come up with a new one
> > a month from now and not have to modify any of the existing code.
>
> i see it more on a need-to-expose basis. for example, why not, when
> presented w/ the current problem, just expose, Baz::doThings() now, b/c you
> know you need it in Baz instances ? later if you find theres another
> method thats in Bar that isnt yet exposed, you just go in and add a similar
> wrapper for it in Baz at that time. this is a typical flow in a layered
> architecture in my experience; often times controllers are revised to
> expose a new entry point for something on the backend that previously was
> unavailble from the front end, just as an example.
Because this is for a shipping application, not an in-house app where a month
from now I can go back and adjust the interface for every class. (It's open
source, but still has a stable release version.) I need to be able to add
additional wrapping decorators *without* any modifications to the underlying
object or its interfaces.
As I said, the interface problem is solvable by having explicit delegating
methods in the base decorator class and then only using __call() for nested
decorators, which will be a much much smaller portion of the time. It's the
performance cost of __call() and the extra call stack layers that are my
concern at the moment.
--
Larry Garfield
la...@garfieldtech.com
--- End Message ---
--- Begin Message ---
On Dec 26, 2008, at 7:53 PM, Larry Garfield wrote:
I have an object to which I want to add behavior (methods). I
cannot use
inheritance here because the object is already of a type or subtype
(vis, I am
already using inheritance for something else), and because I want
to be able
to add multiple types of behavior at runtime.
If I understand what you are wanting to accomplish, perhaps a simpler
solution:
Whenever I create a function in a core-level class, I add pre- and
post- execution language to it. For example:
class foo_bar {
function foo () {
if (!on_foo()) {
return FALSE;
}
// normal foo code
// normal foo code
// normal foo code
// normal foo code
// normal foo code
if (!more_foo()) {
return FALSE;
}
}
function on_foo() {
return TRUE;
}
function more_foo() {
return TRUE;
}
}
-- then in the child class:
class child_bar extends foo_bar {
function on_foo() {
// runtime code
// runtime code
// runtime code
// runtime code
return TRUE; // (or FALSE)
}
}
Ken
--- End Message ---
--- Begin Message ---
Hello,
I try to run script below with PHP4 and it works.
--TEST--
Test session_encode() function : variation
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
ob_start();
echo "*** Testing session_encode() : variation ***\n";
var_dump(session_start());
$array = array(1,2,3);
$array["foo"] = &$array;
$array["blah"] = &$array;
$_SESSION["data"] = &$array;
var_dump(session_encode());
var_dump(session_destroy());
echo "Done";
ob_end_flush();
?>
--EXPECTF--
*** Testing session_encode() : variation ***
bool(true)
string(64)
"data|a:5:{i:0;i:1;i:1;i:2;i:2;i:3;s:3:"foo";R:1;s:4:"blah";R:1;}"
bool(true)
Done
But in PHP5 x64 I have errors like:
/root/src/php-5.2.6/Zend/zend_hash.c(247) : Freeing 0x0E76BC50 (75 bytes),
script=ext/session/tests/session_encode_variation5.phpt
[Sat Dec 27 11:27:09 2008] Script:
'ext/session/tests/session_encode_variation5.phpt'
/root/src/php-5.2.6/Zend/zend_vm_execute.h(3596) : Freeing 0x0E76B990 (71
bytes), script=ext/session/tests/session_encode_variation5.phpt
/root/src/php-5.2.6/Zend/zend_hash.c(388) : Actual location (location was
relayed)
If I add:
$array["foo"] = null;
$array["blah"] = null;
in test code it works without errors. But is I always need to add 'null' ?
I'm asking because I have some site which genereating many errors like
"Actual location (location was relayed)".
Thanks
Pawel R.
--- End Message ---
--- Begin Message ---
Hi, Pawel;
On Sat, Dec 27, 2008 at 05:40, Pawel Rutkowski
<rut...@freelance-worker.net> wrote:
[snip!]
>
> But in PHP5 x64 I have errors like:
>
> /root/src/php-5.2.6/Zend/zend_hash.c(247) : Freeing 0x0E76BC50 (75 bytes),
> script=ext/session/tests/session_encode_variation5.phpt
> [Sat Dec 27 11:27:09 2008] Script:
> 'ext/session/tests/session_encode_variation5.phpt'
> /root/src/php-5.2.6/Zend/zend_vm_execute.h(3596) : Freeing 0x0E76B990 (71
> bytes), script=ext/session/tests/session_encode_variation5.phpt
> /root/src/php-5.2.6/Zend/zend_hash.c(388) : Actual location (location was
> relayed)
Please file a bug report on this with the reproduce cases at
http://bugs.php.net/. There was a nearly identical case mentioned in
the Zend forums[1] as found by Google, but no resolution was reached
there.
KEY:
1:
http://www.zend.com/forums/index.php?t=msg&goto=19257&S=e5a6d1ca82291c880a9d85093afe1ee7
--
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!
--- End Message ---
--- Begin Message ---
Hi,
I am new to PHP and require your help regarding a PHP Script. Below is what I
am tryin to achieve
1. I have created a FILE UPLOAD page that lets users Upload a FIle to the
site. This and other details regarding the file stored in a MySQL Database.
2. I need to create a FILE DOWNLOAD page that will read details from the MYSQL
database for users to dwnload already uploaded files.
Your help will be most appricated.
Thanks
Toyin AYemowa
UK
--- End Message ---
--- Begin Message ---
On Sat, 2008-12-27 at 07:47 -0800, Ayemowa Toyin wrote:
> Hi,
>
> I am new to PHP and require your help regarding a PHP Script. Below is what
> I am tryin to achieve
>
> 1. I have created a FILE UPLOAD page that lets users Upload a FIle to the
> site. This and other details regarding the file stored in a MySQL Database.
>
> 2. I need to create a FILE DOWNLOAD page that will read details from the
> MYSQL database for users to dwnload already uploaded files.
>
> Your help will be most appricated.
>
> Thanks
>
> Toyin AYemowa
> UK
>
>
>
RTFM
http://www.php.net
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
2008/12/27 Ashley Sheridan <a...@ashleysheridan.co.uk>:
> RTFM
>
> http://www.php.net
>
Or STFW
http://justfuckinggoogleit.com/search?q=php%20mysql%20file%20download%20script
--
Dotan Cohen
http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü
--- End Message ---
--- Begin Message ---
On Sat, Dec 27, 2008 at 10:47, Ayemowa Toyin <ayemowa_to...@yahoo.co.uk> wrote:
> Hi,
>
> I am new to PHP and require your help regarding a PHP Script. Below is what
> I am tryin to achieve
You require an RTFM and STFW session.
* http://php.net/
* http://google.com/
> 1. I have created a FILE UPLOAD page that lets users Upload a FIle to the
> site. This and other details regarding the file stored in a MySQL Database.
>
> 2. I need to create a FILE DOWNLOAD page that will read details from the
> MYSQL database for users to dwnload already uploaded files.
If you've already created the UPLOAD page, then the more difficult
of the two tasks is done. Chances are, you (or whomever wrote the
code for you) should know how to do #2 if you (or another) already did
#1, but if not:
http://www.google.com/search?q=php+mysql+file+download+script
http://www.joeclipart.com/blog/images/2007/06/20070628crack.jpg
http://www.phpbuilder.com/tips/item.php?id=5
--
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!
--- End Message ---
--- Begin Message ---
2008/12/27 Daniel Brown <danbr...@php.net>:
> If you've already created the UPLOAD page, then the more difficult
> of the two tasks is done. Chances are, you (or whomever wrote the
> code for you) should know how to do #2 if you (or another) already did
> #1, but if not:
>
> http://www.google.com/search?q=php+mysql+file+download+script
> http://www.joeclipart.com/blog/images/2007/06/20070628crack.jpg
> http://www.phpbuilder.com/tips/item.php?id=5
>
That was subtle :)
--
Dotan Cohen
http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü
--- End Message ---
--- Begin Message ---
lol, Ashley!
Ayemowa,
http://www.google.com/search?q=becoming+a+programmer&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
You need to take your 2 steps below and break them down into smaller
steps...and smaller steps...and still smaller steps.
What PHP files will your application require?
Will there be forms?
What will the user interface look like?
Don't start with a 'PHP script'.
Start by defining in excruciating detail what your application is
going to do, how it will do it and then describe every little part
(variables, functions, models, views, controllers...whatever) that
will make it work.
Once you have that description, you can start to think about the code
by writing it's documentation.
Then, once you have the documentation, you can write code based on the
documentation...revising the docs as necessary.
It's a lengthy, complicated process that is going to demand a little
more of you than just reducing your app to 2 steps and asking a
mailing list how to do it.
Good luck, let us know how it goes and how we can help you take (much
smaller) steps.
John Corry
--- End Message ---
--- Begin Message ---
On Fri, Dec 26, 2008 at 20:24, Stephen Alistoun
<stephenalist...@gmail.com> wrote:
>
> Hi all,
>
> What is the best way to pick up all the members online on a website?
Check the archives and STFW for examples, but the general gist is
of it is to use $_SESSION tracking with activity checking. I'm just
typing this in quickly as I go, so it's untested (read: don't copy and
paste for production), but here's a simple example (you should be able
to fill in the blanks easily):
<?php
function m($str) { // Just an alias to shorten typing here.
return mysql_real_escape_string($str);
}
session_start();
// You can add their username if they're logged in, or display
// the count of unauthenticated users active on the site as the
// collective "# Guests Online" group.
mysql_query("UPDATE `users_online` SET `ip` =
'".m($_SERVER['REMOTE_ADDR'])."', `last_active` = '".m(time())."`
WHERE `sess_id` = '".m(session_id())."'";
if (mysql_affected_rows() == 0) {
mysql_query("INSERT INTO users_online(sess_id,ip,last_active)
VALUES('".m(session_id())."','".m($_SERVER['REMOTE_ADDR'])."','".m(time())."')";
}
// Et cetera....
// Now, to display users online:
$sql = "SELECT username FROM users_online WHERE last_active -
".m(time())." < 300";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
echo $row['username']."<br />\n";
}
// And guests:
$sql = "SELECT COUNT(*) AS num_guests FROM users_online WHERE
username='' AND last_active - ".m(time())." < 300";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
echo "There are ".$row['num_guests']." guests online.<br />\n";
?>
--
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!
--- End Message ---
--- Begin Message ---
-------- Original Message --------
Subject: Re: Re: [PHP] Online Members
Date: Sat, 27 Dec 2008 15:03:42 +0000
From: jco...@gmail.com
To: Michael Kubler <greyphoenixproducti...@gmail.com>
If you're talking about tracking the number of visitors with presently
open sessions at your website...
I was just browsing the tutorials form at PHP Developer Network and saw
this : http://forums.devnetwork.net/viewtopic.php?f=28&t=29342
Looks like it does what (I think) you were trying to describe.
> Hi all,
>
> What is the best way to pick up all the members online on a website?
>
> Regards,
>
> Stephen
------------------------
Not sure if this email actually made it to the list, so forwarding it
just in case.
--
Michael Kubler
*G*rey *P*hoenix *P*roductions <http://www.greyphoenix.biz>
--- End Message ---
--- Begin Message ---
If you're talking about tracking the number of visitors with presently open
sessions at your website...
>
> I was just browsing the tutorials form at PHP Developer Network and saw
> this : http://forums.devnetwork.net/viewtopic.php?f=28&t=29342
>
> Looks like it does what (I think) you were trying to describe.
the above link winds up at a dead end,
http://webmonkey.wired.com/webmonkey/04/50/index4a.html
there are many ways to do this, depending upon how you store the session,
you may be able to crawl a list of them. w/ the stock session support there
are a number of files in /tmp, which would be a place to start.
however, id probly just drop a counter in the database when a session is
created and remove it when said session is destroyed. then all youd ever
have to do is lookup that number.
this you could achieve via session_set_save_handler()
-nathan
--- End Message ---
--- Begin Message ---
Is there a compelling reason to use either REQUEST_URI or SCRIPT_NAME
in the action of a form that I want to submit to the same URL that it
came from (the script parses whether or not there is a Submit to know
if it should display the form or the results). I need a portable
solution, that is why I am not hardcoding it. Also, the users _may_
save the form to their hard drives, so simply leaving the action blank
will not do.
I know that REQUEST_URI includes the ?variable=value string and that
SCRIPT_NAME does not. This form does not depend upon get variables, so
this should never be an issue, but I ask here anyway to know if there
are other differences that I did not account for.
Thanks!
--
Dotan Cohen
http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü
--- End Message ---
--- Begin Message ---
On Sat, Dec 27, 2008 at 12:31, Dotan Cohen <dotanco...@gmail.com> wrote:
> Is there a compelling reason to use either REQUEST_URI or SCRIPT_NAME
> in the action of a form that I want to submit to the same URL that it
> came from (the script parses whether or not there is a Submit to know
> if it should display the form or the results). I need a portable
> solution, that is why I am not hardcoding it. Also, the users _may_
> save the form to their hard drives, so simply leaving the action blank
> will not do.
>
> I know that REQUEST_URI includes the ?variable=value string and that
> SCRIPT_NAME does not. This form does not depend upon get variables, so
> this should never be an issue, but I ask here anyway to know if there
> are other differences that I did not account for.
Happy Chanukah, Dotan!
For portability's sake, especially if you anticipate users saving
the form to their local systems, I would recommend:
<?php
$action = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
?>
<form method="<?php echo $action; ?>">
If you use REQUEST_URI and the form is on a page not called
directly (for example, on index.php and called only by directory; a
mod_rewrite /contact page; etc.), using REQUEST_URI gives the actual
request, where PHP_SELF gives the actual file.
--
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!
--- End Message ---
--- Begin Message ---
2008/12/27 Daniel Brown <danbr...@php.net>:
> Happy Chanukah, Dotan!
>
And a Merry Christmas!
> For portability's sake, especially if you anticipate users saving
> the form to their local systems, I would recommend:
>
> <?php
> $action = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
> ?>
Naturally I have HTTP_HOST in there, but I did not even think about PHP_SELF.
> If you use REQUEST_URI and the form is on a page not called
> directly (for example, on index.php and called only by directory; a
> mod_rewrite /contact page; etc.), using REQUEST_URI gives the actual
> request, where PHP_SELF gives the actual file.
>
That is a good point, and it is rather likely that the form may wind
up on an index.php page where the filename is not part of the URI.
Thanks!
--
Dotan Cohen
http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü
--- End Message ---