Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread J DeBord
I've heard stories like this before, but never encountered it myself.

I forgot to mention that it is a good idea to give your submit buttons a
"value" attribute. Regardless of how the form is submitted, you should then
have a value for ['submit'].

Reminding the user that they must do anything other than the simplest things
is usually not a good approach. There will inevitably be users who do not
see/follow your reminder and use the enter button. Give the submit button a
value.


On Sat, Aug 29, 2009 at 6:50 AM, Keith  wrote:

> I've encountered issue with checking $_POST['submit']
>   if(isset($_POST['submit'])) {}
>
> If the form consists of checkbox/radio and text field, some of my forms can
> be submitted by just press [ENTER] at the end of one of the text field. In
> this case, the $_POST['submit'] is set even the  submit button was not
> clicked.
> However, in some of my forms, $_POST['submit'] will not be set if I submit
> the form by pressing [ENTER] in one of the text field.
> So, if the later case happen, I need to remind the user to explicitly click
> the [Submit] button.
> I don't know why or in what condition that pressing [ENTER] will not submit
> the whole form include the $_POST['submit'].
>
> Keith
>
>
> "Ashley Sheridan"  wrote in message
> news:1251467419.27899.106.ca...@localhost...
>
>  On Thu, 2009-08-27 at 23:21 -0400, Adam Jimerson wrote:
>>
>>> On 08/27/2009 11:09 PM, Adam Jimerson wrote:
>>> > This question might give away the fact that I am a php noob, but I am
>>> > looking for the best way to test for form submission in PHP.  I know in
>>> > Perl this can be done with
>>> >
>>> > if (param)
>>> >
>>> > but I don't know if that will work with PHP.  I have read the Learning
>>> > PHP 5 book and the only thing that was mentioned in the book was the >
>>> use
>>> > of something like this
>>> >
>>> > print "Hello ".$_POST['username']."";
>>>
>>> Sorry copied and pasted the wrong line (long day)
>>>
>>> if (array_key_exists('username',$_POST))
>>> >
>>> > I'm sure that this is not the best/recommended way to do this but I'm
>>> > hoping someone here will point me in the right direction.
>>>
>>>
>>>
>> The best way I've found is to do something like this:
>>
>> if(isset($_POST['submit']))
>> {}
>>
>> Note that in-place of submit you can put the name of any form element. I
>> chose submit here, because every form should have a submit button. Note
>> also that this will only work if you have given your submit button a
>> name:
>>
>> 
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP]Some body test php6-dev version for mbs?

2009-08-28 Thread hack988 hack988
nobody have a solution for no-unicode php script with MBCS (Multiple
Byte Character Set) run on php6?
I have an wrong spelling for MBCS in OM.:(

2009/8/27 hack988 hack988 :
>  I'm not sure,but one thing is that ,the code save as ANSI format will
> throw Parse error in php6.
> Sometime I don't like script run with unicode because of some system
> environment limitation.
> I'm make a spell mistake in before message :( (trow->throw).
> Any boday have a solution for it?
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Error when execute header('location: otherpage.php') after email been sent out. Any Workaround?

2009-08-28 Thread Keith

Ash, Ben, Thanks!

For my web server, I can access to:
./httpdocs
./httpsdocs

all the http documents are stored inside httpdocs and SSL documents inside 
httpsdocs.
The web root you mean here is referred to ./httpdocs and ./httpsdocs or the 
parent directory of them?
If I  put the logfile inside ./log/logfile.txt where ./log is same level as 
./httpdocs, can the web users access it?


Thanks!
Keith


"Ashley Sheridan"  wrote in message 
news:1251477059.27899.117.ca...@localhost...

On Fri, 2009-08-28 at 09:28 -0700, Ben Dunlap wrote:

> Which format should I used for log file? *.log or *.txt?

Doesn't matter to PHP -- but you do need to provide a local path, not a 
URL.


> [http://domain.com/log/logfile.*] or

No...

> [C:\some_path\domain.com\log\logfile.*] or just

Yes!

Ben


You should try and put the log somewhere that is not in the web root, to
prevent anyone from accessing it and getting information which could
help a hack.


Thanks,
Ash
http://www.ashleysheridan.co.uk





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Keith

I've encountered issue with checking $_POST['submit']
   if(isset($_POST['submit'])) {}

If the form consists of checkbox/radio and text field, some of my forms can 
be submitted by just press [ENTER] at the end of one of the text field. In 
this case, the $_POST['submit'] is set even the  submit button was not 
clicked.
However, in some of my forms, $_POST['submit'] will not be set if I submit 
the form by pressing [ENTER] in one of the text field.
So, if the later case happen, I need to remind the user to explicitly click 
the [Submit] button.
I don't know why or in what condition that pressing [ENTER] will not submit 
the whole form include the $_POST['submit'].


Keith


"Ashley Sheridan"  wrote in message 
news:1251467419.27899.106.ca...@localhost...

On Thu, 2009-08-27 at 23:21 -0400, Adam Jimerson wrote:

On 08/27/2009 11:09 PM, Adam Jimerson wrote:
> This question might give away the fact that I am a php noob, but I am
> looking for the best way to test for form submission in PHP.  I know in
> Perl this can be done with
>
> if (param)
>
> but I don't know if that will work with PHP.  I have read the Learning
> PHP 5 book and the only thing that was mentioned in the book was the 
> use

> of something like this
>
> print "Hello ".$_POST['username']."";

Sorry copied and pasted the wrong line (long day)

if (array_key_exists('username',$_POST))
>
> I'm sure that this is not the best/recommended way to do this but I'm
> hoping someone here will point me in the right direction.




The best way I've found is to do something like this:

if(isset($_POST['submit']))
{}

Note that in-place of submit you can put the name of any form element. I
chose submit here, because every form should have a submit button. Note
also that this will only work if you have given your submit button a
name:



Thanks,
Ash
http://www.ashleysheridan.co.uk





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: [PHP-WIN] Re: [PHP] Problem outputting MySQL Date field

2009-08-28 Thread John Meyer

Keith Davis wrote:

But how are you getting the data from the db?

Does $rowqry represent a call using the mysql_fetch_array() function?


mysql_fetch_assoc()

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: [PHP-WIN] Re: [PHP] Problem outputting MySQL Date field

2009-08-28 Thread Keith Davis

But how are you getting the data from the db?

Does $rowqry represent a call using the mysql_fetch_array() function?


Sent from my magic iPhone,
Keith Davis 214-906-5183

On Aug 28, 2009, at 7:39 PM, "John Meyer"  
 wrote:



Devendra Jadhav wrote:
No need to do anything special. It should display date as string.  
Can you provide little more information or code snippet?
$tweettable .= preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.] 
*(\?\S+)?)?)?)@', '$1',$row["TWEET_TEXT"]) .  
"" . "Sent at: " . $rowqry["TWEET_CREATEDAT"];
  $tweettable .= "Sent Using: " . $row["TWEET_CREATEDBY"] .  
"";


And I checked the database.  The date is there.

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



This message (including any attachments) may contain confidential or otherwise 
privileged information and is intended only for the individual(s) to which it 
is addressed. If you are not the named addressee you should not disseminate, 
distribute or copy this e-mail. Please notify the sender immediately by e-mail 
if you have received this e-mail by mistake and delete this e-mail from your 
system. E-mail transmission cannot be guaranteed to be secured or error-free as 
information could be intercepted, corrupted, lost, destroyed, arrive late or 
incomplete, or contain viruses. The sender therefore does not accept liability 
for any errors or omissions in the contents of this message or that arise as a 
result of e-mail transmission. If verification is required please request a 
hard-copy version from the sender.

www.pridedallas.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problem outputting MySQL Date field

2009-08-28 Thread Jim Lucas

John Meyer wrote:

Devendra Jadhav wrote:
No need to do anything special. It should display date as string. Can 
you provide little more information or code snippet?
$tweettable .= 
preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', 
'$1',$row["TWEET_TEXT"]) . "" . "Sent at: " . 
$rowqry["TWEET_CREATEDAT"];
   $tweettable .= "Sent Using: " . $row["TWEET_CREATEDBY"] . 
"";


And I checked the database.  The date is there.



Two things jump out.

1.  TWEET_CREATEDAT  is that suppose to be TWEET_CREATEDATE  ??
2. two variables are accessed from the $row array, but the third is referenced from the $rowqry 
array.  This begs the question: Which is it?  $row or $rowqry ?


Try this

$tweettable .= preg_replace(
'@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@',
'$1',
$row["TWEET_TEXT"]);
$tweettable .= 'Sent at: ' . $row["TWEET_CREATEDATE"];
$tweettable .= 'Sent Using: {$row['TWEET_CREATEDBY']}";

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problem outputting MySQL Date field

2009-08-28 Thread John Meyer

Devendra Jadhav wrote:
No need to do anything special. It should display date as string. Can 
you provide little more information or code snippet?
$tweettable .= 
preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', 
'$1',$row["TWEET_TEXT"]) . "" . "Sent at: " . 
$rowqry["TWEET_CREATEDAT"];
   $tweettable .= "Sent Using: " . $row["TWEET_CREATEDBY"] . 
"";


And I checked the database.  The date is there.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Converting URL's to hyperlinks.

2009-08-28 Thread LinuxManMikeC
If you have short php tags enabled, assuming you put the url in a
variable called $url...

click here

otherwise...

click here

or a myriad of other ways...

Depending if there are any special characters involved, there are a
couple functions that would be useful for preparing the url before
outputing it in html, but I don't remember them off the top of my
head.  RTFM for that.

On Thu, Aug 27, 2009 at 11:56 AM, John
Meyer wrote:
> What sort of function would I need if I wanted to convert those URLs from
> plain jane text?
>
> --
> 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] Converting URL's to hyperlinks.

2009-08-28 Thread John Meyer
What sort of function would I need if I wanted to convert those URLs 
from plain jane text?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Problem outputting MySQL Date field

2009-08-28 Thread John Meyer
Is there anything special I have to do to output a mysql date field as 
text?  When I try to output it nothing appears on the web page.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] vote package

2009-08-28 Thread Noel Butler
On Fri, 2009-08-28 at 08:33 -0400, Bob McConnell wrote:


> 
> Forging IP addresses is actually quite simple. VMs do it all the time
> when bridged to the real NIC. There are also some projects on Source
> Forge designed to load test HTTP servers that do similar things. I have
> an application I wrote for testing that can emulate an entire class B
> subnet full of computers. All it takes is a little digging around on
> Google, a FreeBSD system installed in a VM and a little knowledge of the
> local network topology. In my case I have several blocks of addresses
> allocated by the local administrator for this test bed.
> 
> Bob McConnell


sorry if this explodes your bubble, but you dont need freebsd to do
it :)



Re: [PHP] File Open Prompt?

2009-08-28 Thread Dan Shirah
>
> You will need to add some headers to the page to popup the prompt, at least
> with
> these.
>
> $filename = 'somefile.tif';
> $filesize = filesize($filename);
>
> header('Content-Type: application/force-download');
> header('Content-disposition: attachement; filename=' . $filename);
> header('Content-length: ' . $filesize);
>
> Eric
>
>

I don't know what I'm doing wrong.  I've tried:

header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($filename));
header('Content-Disposition: attachment; filename=' . basename($file));
readfile($file);
AND

if (file_exists($new_file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($new_file
));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($new_file));
ob_clean();
flush();
readfile($new_file);
exit;
}

But everything I do just sends heiroglyphics to the screen instead of giving
the download box.


[PHP] PHPDFS on 20 amazon instances

2009-08-28 Thread Shane Hill
Hi folks,

A few weeks ago I started a php project for building a highly scalable
distributed file system similar to mogileFS. Well, I did just that and
called it PHPDFS and I just completed a test of PHPDFS using 20 ec2
instances and PHPDFS performed quite well.

I setup 20 (5 clients, 15 servers)  m1.large amazon instances and uploaded
250GB of data and downloaded 1.5 terabytes of data.  Total overall transfer
was 1.8 TB

The blog has more info and links to 870 graphs and the 300mb of data that
was collected and analyzed.:

http://phpdfs.blogspot.com

Here are some highlights:

   - 500 threads (5 java clients, 100 threads each)
   - 15 servers
   - ~250 GB uploaded (PUT requests) (individual files between 50k and 10mb)
   - ~1.5 Tb downloaded (GET requests)
   - ~1.8 TB transfer total
   - ~47mb / sec upload rate
   - ~201 requests / sec overall
   - The data was very evenly distributed across all nodes
   - 40 replicas were lost and totally unrecoverable amounting to .030% data
   loss

Basically,  PHPDFS performed quite well,  There was a small amount of data
loss due to one of the servers getting really hot.  What happened was a few
uploads to the hot server were corrupted and the corrupted objects were
replicated.  Better error handling and a checksum mechanism will eliminate
something like that from happening.  So that is next on the development
list.

Anyway, I just wanted to let the list know that this is coming along quite
nicely and actually has gotten some attention from the folks at the Storage
Systems Research Center at UC Santa Cruz.  http://www.ssrc.ucsc.edu/

if anyone has questions or wants to get involved please let me know.

you can download phpdfs here:

http://code.google.com/p/phpdfs/downloads/list

peace,

-Shane


Re: [PHP] File Open Prompt?

2009-08-28 Thread Eric

- Original Message - 
From: "Ashley Sheridan" 
To: "Dan Shirah" 
Cc: "PHP General" 
Sent: Saturday, August 29, 2009 3:10 AM
Subject: Re: [PHP] File Open Prompt?


> On Fri, 2009-08-28 at 15:03 -0400, Dan Shirah wrote:
> 
>> Greetings,
>> 
>> I'm having a problem trying to get a file download prompt.
>> 
>> Basically I have a page with image links.
>> 
>> When the link is clicked, the user is directed to another page I have. That
>> page finds the image path based on the image ID from the previous page.
>> 
>> Once the image path is found I copy the image to the local webserver and
>> rename the proprietary extension, .0D9 to .tif
>> 
>> Once the file is renamed to .tif I want the download prompt to come up.  You
>> know, where it says, "Open" "Save" "Cancel".
>> 
>> I've tried using:
>> 
>> $fp = fopen($new_file,"r") ;
>> header("Content-Type: image/tif");
>> while (! feof($fp)) {
>>$buff = fread($fp,filesize($new_file));
>>print $buff;
>>}
>> 
>> But that just gives me heiroglyphics on the screen instead of prompting the
>> user to download.
>> 
>> Here is my code that copies and renames the file:
>> 
>> if ($page != "" || $page != " ") {
>>  exec("xcopy ".$page." ".$topage."");
>> }
>> $orig_file = $topage."\\".$objectid.".0D9";
>> //echo $orig_file;
>> $new_file = $topage."\\".$objectid.".tif";
>> //echo $new_file;
>> 
>> rename($orig_file,$new_file);
>> 


You will need to add some headers to the page to popup the prompt, at least 
with 
these.

$filename = 'somefile.tif';
$filesize = filesize($filename);

header('Content-Type: application/force-download');
header('Content-disposition: attachement; filename=' . $filename);
header('Content-length: ' . $filesize);

Eric

>> Any ideas on how to make the browser give the download prompt for $new_file?
>> 
>> Thanks,
>> Dan
> 
> You need to send down the right headers to the browser, so that it knows
> it's meant to save the file, and not attempt to display it. If the link
> was to a file, you'd have certain header that informed the browser the
> mime type of the file.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 
>

Re: [PHP] File Open Prompt?

2009-08-28 Thread Andrew Ballard
On Fri, Aug 28, 2009 at 3:03 PM, Dan Shirah wrote:
> Greetings,
>
> I'm having a problem trying to get a file download prompt.
>
> Basically I have a page with image links.
>
> When the link is clicked, the user is directed to another page I have. That
> page finds the image path based on the image ID from the previous page.
>
> Once the image path is found I copy the image to the local webserver and
> rename the proprietary extension, .0D9 to .tif
>
> Once the file is renamed to .tif I want the download prompt to come up.  You
> know, where it says, "Open" "Save" "Cancel".
>
> I've tried using:
>
> $fp = fopen($new_file,"r") ;
> header("Content-Type: image/tif");
> while (! feof($fp)) {
>       $buff = fread($fp,filesize($new_file));
>       print $buff;
>       }
>
> But that just gives me heiroglyphics on the screen instead of prompting the
> user to download.
>
> Here is my code that copies and renames the file:
>
> if ($page != "" || $page != " ") {
>  exec("xcopy ".$page." ".$topage."");
> }
> $orig_file = $topage."\\".$objectid.".0D9";
> //echo $orig_file;
> $new_file = $topage."\\".$objectid.".tif";
> //echo $new_file;
>
> rename($orig_file,$new_file);
>
> Any ideas on how to make the browser give the download prompt for $new_file?
>
> Thanks,
> Dan
>

You need to send the content-disposition header in addition to the content-type:

header("Content-Disposition: attachment; filename={$clean_file_name};", true);

The filename shouldn't contain spaces or other special characters.
Some browsers will handle it OK if they do, some won't.

There are several lots of posts in the archives that give more details
on how to do it as well as how to avoid some common problems people
have run into.


Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] File Open Prompt?

2009-08-28 Thread Ashley Sheridan
On Fri, 2009-08-28 at 15:03 -0400, Dan Shirah wrote:

> Greetings,
> 
> I'm having a problem trying to get a file download prompt.
> 
> Basically I have a page with image links.
> 
> When the link is clicked, the user is directed to another page I have. That
> page finds the image path based on the image ID from the previous page.
> 
> Once the image path is found I copy the image to the local webserver and
> rename the proprietary extension, .0D9 to .tif
> 
> Once the file is renamed to .tif I want the download prompt to come up.  You
> know, where it says, "Open" "Save" "Cancel".
> 
> I've tried using:
> 
> $fp = fopen($new_file,"r") ;
> header("Content-Type: image/tif");
> while (! feof($fp)) {
>$buff = fread($fp,filesize($new_file));
>print $buff;
>}
> 
> But that just gives me heiroglyphics on the screen instead of prompting the
> user to download.
> 
> Here is my code that copies and renames the file:
> 
> if ($page != "" || $page != " ") {
>  exec("xcopy ".$page." ".$topage."");
> }
> $orig_file = $topage."\\".$objectid.".0D9";
> //echo $orig_file;
> $new_file = $topage."\\".$objectid.".tif";
> //echo $new_file;
> 
> rename($orig_file,$new_file);
> 
> Any ideas on how to make the browser give the download prompt for $new_file?
> 
> Thanks,
> Dan

You need to send down the right headers to the browser, so that it knows
it's meant to save the file, and not attempt to display it. If the link
was to a file, you'd have certain header that informed the browser the
mime type of the file.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread J DeBord
If you want to check that a *form* was submiited, you need to at minimum
check that one of the form elements exist in the post data, assuming the
method is post. The submit button is a good one to use. Just checking that
there *is* POST data isn't a great idea. Anyone can post anything. Checking
for a key named 'submit' in the POST array is no more difficult than any
other method. That being said anyone could POST a key value pair with the
key being 'submit'. So validate everything!

On Fri, Aug 28, 2009 at 7:29 PM, Martin Scotta wrote:

> On Fri, Aug 28, 2009 at 1:59 PM, Ben Dunlap  >wrote:
>
> > > Well, as far as I'm aware $_SERVER isn't reliable from server to
> server.
> > > That said, I've never had a problem using it.
> >
> > Thanks -- I just looked it up and the manual says: "There is no
> > guarantee that every web server will provide any of these; servers may
> > omit some, or provide others not listed here. That said, a large
> > number of these variables are accounted for in the » CGI 1.1
> > specification, so you should be able to expect those."
> >
> > So I guess it wouldn't make sense to rely on anything in $_SERVER if
> > you're building an app for widespread use; e.g., CodeIgniter, as
> > mentioned above.
> >
> > > tend to use the $_REQUEST array instead of $_POST or $_GET. You get the
> > > benefit of being able to work with both arrays (as well as $_SESSION
> and
> > > $_COOKIE) without any drawbacks.
> >
> > For now I'm inclined against $_REQUEST, since it's not yet supported
> > by filter_input(). I think filter_input() is the bee's knees and I've
> > stopped touching $_POST or $_GET directly since I discovered it.
> >
> > Ben
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> When the request is PUT your $_SERVER['REQUEST_METHOD'] detection will
> fail,
> but the $_POST will be populated.
>
> I think the best way is by count( $_POST ) > 0 but this only applies for
> application/x-www-form-urlencoded forms.
> Other content-type will not populate the $_POST and therefore need to be
> validated by other method.
>
> PHP provides non-yet-standard HttpRequest class that can handle this
> perfectly
>
>
> --
> Martin Scotta
>


[PHP] File Open Prompt?

2009-08-28 Thread Dan Shirah
Greetings,

I'm having a problem trying to get a file download prompt.

Basically I have a page with image links.

When the link is clicked, the user is directed to another page I have. That
page finds the image path based on the image ID from the previous page.

Once the image path is found I copy the image to the local webserver and
rename the proprietary extension, .0D9 to .tif

Once the file is renamed to .tif I want the download prompt to come up.  You
know, where it says, "Open" "Save" "Cancel".

I've tried using:

$fp = fopen($new_file,"r") ;
header("Content-Type: image/tif");
while (! feof($fp)) {
   $buff = fread($fp,filesize($new_file));
   print $buff;
   }

But that just gives me heiroglyphics on the screen instead of prompting the
user to download.

Here is my code that copies and renames the file:

if ($page != "" || $page != " ") {
 exec("xcopy ".$page." ".$topage."");
}
$orig_file = $topage."\\".$objectid.".0D9";
//echo $orig_file;
$new_file = $topage."\\".$objectid.".tif";
//echo $new_file;

rename($orig_file,$new_file);

Any ideas on how to make the browser give the download prompt for $new_file?

Thanks,
Dan


Re: [PHP] safe_mode and inclusion of files don't work as documented

2009-08-28 Thread Lars Torben Wilson
2009/8/28 Nico Sabbi :
> Hi,
> I'm testing one of my sites in safe_mode, but I'm experiencing some
> strangeness that is not documented.
>
> The settings are:
> in php.ini:
> include_path =
> ".:/server/home/apache/php4/:/var/php/5.2/pear/:/usr/php/lib/ezcomponents-2008.2.2/"
>
> in the virtualhost config:
>        php_admin_value safe_mode On
>        php_admin_value safe_mode_include_dir
> "/server/home/nsabbi:/server/home/apache/php4:.:.."
>
> The files belong entirely to apache:apache, the user who is running apache.
> The problem is:
>
>
> *Fatal error*: require_once() [function.require
> ]: Failed opening required
> '../include.php'
> (include_path='.:..:/server/home/apache/php4/:/var/php/5.2/pear/:/usr/php/lib/ezcomponents-2008.2.2/')
> in */server/home/nsabbi/nb4/login/index.php* on line *3
>
> How is it that i can't include files in .. 

Hi Nico,

First the obligatory "safe_mode is deprecated and not recommended"
speech. . .but I guess you've already seen that in the docs and
decided to use it anyway.

What does the script do if you turn off safe_mode?

> btw, can I redefine the include_path in safe mode?

Yes.

> Thanks,
>  Nico


Regards,

Torben

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Martin Scotta
On Fri, Aug 28, 2009 at 1:59 PM, Ben Dunlap wrote:

> > Well, as far as I'm aware $_SERVER isn't reliable from server to server.
> > That said, I've never had a problem using it.
>
> Thanks -- I just looked it up and the manual says: "There is no
> guarantee that every web server will provide any of these; servers may
> omit some, or provide others not listed here. That said, a large
> number of these variables are accounted for in the » CGI 1.1
> specification, so you should be able to expect those."
>
> So I guess it wouldn't make sense to rely on anything in $_SERVER if
> you're building an app for widespread use; e.g., CodeIgniter, as
> mentioned above.
>
> > tend to use the $_REQUEST array instead of $_POST or $_GET. You get the
> > benefit of being able to work with both arrays (as well as $_SESSION and
> > $_COOKIE) without any drawbacks.
>
> For now I'm inclined against $_REQUEST, since it's not yet supported
> by filter_input(). I think filter_input() is the bee's knees and I've
> stopped touching $_POST or $_GET directly since I discovered it.
>
> Ben
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
When the request is PUT your $_SERVER['REQUEST_METHOD'] detection will fail,
but the $_POST will be populated.

I think the best way is by count( $_POST ) > 0 but this only applies for
application/x-www-form-urlencoded forms.
Other content-type will not populate the $_POST and therefore need to be
validated by other method.

PHP provides non-yet-standard HttpRequest class that can handle this
perfectly


-- 
Martin Scotta


Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Ashley Sheridan
On Sat, 2009-08-29 at 01:09 +0800, Eric wrote:
> - Original Message - 
> From: "Ashley Sheridan" 
> To: "Ben Dunlap" 
> Cc: 
> Sent: Saturday, August 29, 2009 12:51 AM
> Subject: Re: [PHP] Re: Best way to test for form submission?
> 
> 
> > On Fri, 2009-08-28 at 09:33 -0700, Ben Dunlap wrote:
> >> I was surprised when no one recommended this:
> >> 
> >>if ($_SERVER['REQUEST_METHOD'] == 'POST')
> >> 
> >> So now I'm wondering if there's a pitfall to this method that I'm not
> >> aware of...
> >> 
> >> Thanks,
> >> 
> >> Ben
> >> 
> > 
> > Well, as far as I'm aware $_SERVER isn't reliable from server to server.
> > That said, I've never had a problem using it.
> > 
> > I probably wouldn't use this however, as it does only check for the
> > existence of POST data. Sometimes I'll trigger the same PHP script from
> > both POST and GET. For example, a search form would use POST in the
> > initial form, and then if it was paginated, the links forwards and
> > backwards through the results would be GET (like Google) I usually just
> > tend to use the $_REQUEST array instead of $_POST or $_GET. You get the
> > benefit of being able to work with both arrays (as well as $_SESSION and
> > $_COOKIE) without any drawbacks.
> 
> 
> If only use the $_REQUEST global array. It may or may not be take a risk of 
> CSRF. Take a look this linke http://www.cgisecurity.com/csrf-faq.html
> 
> I read it a few days before.
> 
> Eric
> 
> > 
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> > 
> > 
> > 
> > 
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> >
It's no less safe than just using $_POST (which the article itself
says). The sensible thing to do is mistrust ANY data coming from the
client machine, and always validate it before using it.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Date Comparison

2009-08-28 Thread David Stoltz
Hey Stuart - 

RTFM yourselfI did read it, and obviously misunderstood...

I'm really sorry to bother you. I thought that was what a listserv like this 
was for - to ask questions...

I'll try not to ask questions I should know the answer to next time.


-Original Message-
From: Stuart [mailto:stut...@gmail.com] 
Sent: Friday, August 28, 2009 10:19 AM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] Date Comparison

2009/8/28 David Stoltz :
> How to I ensure a variable date is not in the past, compared to the
> current date? Here's how I'm trying, unsuccessfully:
>
> $nextdate = "8/2/2009";
>
> if(strtotime($nextdate)<=getdate()){
>
>        echo "Sorry, your next evaluation date cannot be in the past,
> Click BACK to continue.";
>        exit;
>
> }

RTFM.

The strtotime function will give you a timestamp, getdate will give
you an array, so your comparison is non-sensical. Use the time
function to get the current date/time as a timestamp.

-Stuart

-- 
http://stut.net/


Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Ben Dunlap
> Well, as far as I'm aware $_SERVER isn't reliable from server to server.
> That said, I've never had a problem using it.

Thanks -- I just looked it up and the manual says: "There is no
guarantee that every web server will provide any of these; servers may
omit some, or provide others not listed here. That said, a large
number of these variables are accounted for in the » CGI 1.1
specification, so you should be able to expect those."

So I guess it wouldn't make sense to rely on anything in $_SERVER if
you're building an app for widespread use; e.g., CodeIgniter, as
mentioned above.

> tend to use the $_REQUEST array instead of $_POST or $_GET. You get the
> benefit of being able to work with both arrays (as well as $_SESSION and
> $_COOKIE) without any drawbacks.

For now I'm inclined against $_REQUEST, since it's not yet supported
by filter_input(). I think filter_input() is the bee's knees and I've
stopped touching $_POST or $_GET directly since I discovered it.

Ben

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Best way to test for form submission?

2009-08-28 Thread Shawn McKenzie
Adam Jimerson wrote:
> This question might give away the fact that I am a php noob, but I am
> looking for the best way to test for form submission in PHP.  I know in
> Perl this can be done with
> 
> if (param)
> 
> but I don't know if that will work with PHP.  I have read the Learning
> PHP 5 book and the only thing that was mentioned in the book was the use
> of something like this
> 
> print "Hello ".$_POST['username']."";
> 
> I'm sure that this is not the best/recommended way to do this but I'm
> hoping someone here will point me in the right direction.

Just to throw it into the mix:

if(!empty($_POST)) for a general test of whether any form was posted.

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Ashley Sheridan
On Fri, 2009-08-28 at 09:33 -0700, Ben Dunlap wrote:
> I was surprised when no one recommended this:
> 
>if ($_SERVER['REQUEST_METHOD'] == 'POST')
> 
> So now I'm wondering if there's a pitfall to this method that I'm not
> aware of...
> 
> Thanks,
> 
> Ben
> 

Well, as far as I'm aware $_SERVER isn't reliable from server to server.
That said, I've never had a problem using it.

I probably wouldn't use this however, as it does only check for the
existence of POST data. Sometimes I'll trigger the same PHP script from
both POST and GET. For example, a search form would use POST in the
initial form, and then if it was paginated, the links forwards and
backwards through the results would be GET (like Google) I usually just
tend to use the $_REQUEST array instead of $_POST or $_GET. You get the
benefit of being able to work with both arrays (as well as $_SESSION and
$_COOKIE) without any drawbacks.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Ben Dunlap
I was surprised when no one recommended this:

   if ($_SERVER['REQUEST_METHOD'] == 'POST')

So now I'm wondering if there's a pitfall to this method that I'm not
aware of...

Thanks,

Ben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Ashley Sheridan
On Fri, 2009-08-28 at 12:28 -0400, tedd wrote:
> At 4:49 PM +0100 8/28/09, Ashley Sheridan wrote:
> >
> >  >
> >I seem to always use the word! *smacks self on wrist*
> >
> >When I first came across it, it confused the hell out of me! Always
> >running into these kinds of Javascript bugs in IE, it has a much
> >narrower field of 'safe' variable names, probably because of all the
> >dithering about it's done in the past.
> >
> >Thanks,
> >Ash
> 
> Ash:
> 
> What catches me every once in a while is using variable names that 
> are the same as $_SESSION indexes, such as:
> 
> $session_name =  $_SESSION['session_name'];
> 
> Believe it or not, that does NOT always work! Sometimes I have to do this --
> 
> $my_session_name =  $_SESSION['session_name'];
> 
> -- to get around the problem.
> 
> I have experienced this error more than once -- it's strange.
> 
> Cheers,
> 
> tedd
> 
Does that happen even with register globals off?

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Error when execute header('location: otherpage.php') after email been sent out. Any Workaround?

2009-08-28 Thread Ashley Sheridan
On Fri, 2009-08-28 at 09:28 -0700, Ben Dunlap wrote:
> > Which format should I used for log file? *.log or *.txt?
> 
> Doesn't matter to PHP -- but you do need to provide a local path, not a URL.
> 
> > [http://domain.com/log/logfile.*] or
> 
> No...
> 
> > [C:\some_path\domain.com\log\logfile.*] or just
> 
> Yes!
> 
> Ben
> 
You should try and put the log somewhere that is not in the web root, to
prevent anyone from accessing it and getting information which could
help a hack.


Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread tedd

At 4:49 PM +0100 8/28/09, Ashley Sheridan wrote:


 >
I seem to always use the word! *smacks self on wrist*

When I first came across it, it confused the hell out of me! Always
running into these kinds of Javascript bugs in IE, it has a much
narrower field of 'safe' variable names, probably because of all the
dithering about it's done in the past.

Thanks,
Ash


Ash:

What catches me every once in a while is using variable names that 
are the same as $_SESSION indexes, such as:


   $session_name =  $_SESSION['session_name'];

Believe it or not, that does NOT always work! Sometimes I have to do this --

   $my_session_name =  $_SESSION['session_name'];

-- to get around the problem.

I have experienced this error more than once -- it's strange.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Error when execute header('location: otherpage.php') after email been sent out. Any Workaround?

2009-08-28 Thread Ben Dunlap
> Which format should I used for log file? *.log or *.txt?

Doesn't matter to PHP -- but you do need to provide a local path, not a URL.

> [http://domain.com/log/logfile.*] or

No...

> [C:\some_path\domain.com\log\logfile.*] or just

Yes!

Ben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Ashley Sheridan
On Fri, 2009-08-28 at 11:39 -0400, tedd wrote:
> At 4:32 PM +0100 8/28/09, Ashley Sheridan wrote:
> >
> >
> >I have noticed a bug with using a form element named action, which
> >funnily enough only effects IE. If you need to do anything to or based
> >on that action element in IE with Javascript, it has a lot of problems
> >differentiating the form element from the form action attribute, and
> >gets them a bit confused. It's similar to the IE name/id bug.
> >
> >Thanks,
> >Ash
> 
> Good catch.
> 
> I actually never use the word $action -- that's just a placeholder.
> 
> Cheers,
> 
> tedd
> 
> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
I seem to always use the word! *smacks self on wrist*

When I first came across it, it confused the hell out of me! Always
running into these kinds of Javascript bugs in IE, it has a much
narrower field of 'safe' variable names, probably because of all the
dithering about it's done in the past.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread tedd

At 4:32 PM +0100 8/28/09, Ashley Sheridan wrote:



I have noticed a bug with using a form element named action, which
funnily enough only effects IE. If you need to do anything to or based
on that action element in IE with Javascript, it has a lot of problems
differentiating the form element from the form action attribute, and
gets them a bit confused. It's similar to the IE name/id bug.

Thanks,
Ash


Good catch.

I actually never use the word $action -- that's just a placeholder.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Ashley Sheridan
On Fri, 2009-08-28 at 11:29 -0400, tedd wrote:
> At 3:10 PM +0100 8/28/09, Stuart wrote:
> >2009/8/28 Eric :
> >  > Here is another way
> >>
> >>  if (isset($_POST['username'])  && $_POST['username'] != '')
> >>  { ...
> >
> >If you use this method then you'll completely ignore a form submission
> >if they've forgotten to enter a username. Detection and validation are
> >two distinct steps and should be treated as such.
> >
> >-Stuart
> 
> 
> I usually treat forms this way:
> 
> $action = isset($_POST['action']) ? $_POST['action'] : null;
> 
> and then deal with $action.
> 
> Dealing with $action means that I might clean/scrub it for storage in 
> MySQL, or use it to determine a course of processing, or any number 
> of other things.
> 
> The point is to check IF a $_POST has occurred, without triggering an 
> error if it hasn't, and to deal with the outcome either way.
> 
> Cheers,
> 
> tedd
> 
> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 

I have noticed a bug with using a form element named action, which
funnily enough only effects IE. If you need to do anything to or based
on that action element in IE with Javascript, it has a lot of problems
differentiating the form element from the form action attribute, and
gets them a bit confused. It's similar to the IE name/id bug.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread tedd

At 3:10 PM +0100 8/28/09, Stuart wrote:

2009/8/28 Eric :
 > Here is another way


 if (isset($_POST['username'])  && $_POST['username'] != '')
 { ...


If you use this method then you'll completely ignore a form submission
if they've forgotten to enter a username. Detection and validation are
two distinct steps and should be treated as such.

-Stuart



I usually treat forms this way:

   $action = isset($_POST['action']) ? $_POST['action'] : null;

and then deal with $action.

Dealing with $action means that I might clean/scrub it for storage in 
MySQL, or use it to determine a course of processing, or any number 
of other things.


The point is to check IF a $_POST has occurred, without triggering an 
error if it hasn't, and to deal with the outcome either way.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Date Comparison

2009-08-28 Thread tedd

At 10:12 AM -0400 8/28/09, David Stoltz wrote:

How to I ensure a variable date is not in the past, compared to the
current date? Here's how I'm trying, unsuccessfully:

$nextdate = "8/2/2009";

if(strtotime($nextdate)<=getdate()){

echo "Sorry, your next evaluation date cannot be in the past,
Click BACK to continue.";
exit;

}


David:

Try to understand what strtotime() does and you'll get your answer.

Function returns the number of seconds from January 1, 1970 to the 
date you enter. If the number of seconds are less than the current 
date, then the entry is past.


Understand?

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Stuart
2009/8/28 Eric :
>
> - Original Message -
> From: "Stuart" 
> To: "Eric" 
> Cc: ; "Adam Jimerson" 
> Sent: Friday, August 28, 2009 10:10 PM
> Subject: Re: [PHP] Re: Best way to test for form submission?
>
>
> 2009/8/28 Eric :
>>
>> - Original Message -
>> From: "Adam Jimerson" 
>> To: 
>> Sent: Friday, August 28, 2009 11:21 AM
>> Subject: [PHP] Re: Best way to test for form submission?
>>
>>
>>> On 08/27/2009 11:09 PM, Adam Jimerson wrote:
 This question might give away the fact that I am a php noob, but I am
 looking for the best way to test for form submission in PHP. I know in
 Perl this can be done with

 if (param)

 but I don't know if that will work with PHP. I have read the Learning
 PHP 5 book and the only thing that was mentioned in the book was the use
 of something like this

 print "Hello ".$_POST['username']."";
>>>
>>> Sorry copied and pasted the wrong line (long day)
>>>
>>> if (array_key_exists('username',$_POST))
>>
>> Here is another way
>>
>> if (isset($_POST['username']) && $_POST['username'] != '')
>> { ...
>
> If you use this method then you'll completely ignore a form submission
> if they've forgotten to enter a username. Detection and validation are
> two distinct steps and should be treated as such.
>
> Stuart
> thanks,
>
> how about this way
>
> $submit = isset($_POST['submit']) ? true : false;
> if ($submit)
>  { ...

Why the variable? It's unnecessary, as is the ?: operator - isset
returns a boolean.

if (isset($_POST['submit'])) will achieve the same result.

-Stuart

-- 
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Date Comparison

2009-08-28 Thread Stuart
2009/8/28 David Stoltz :
> How to I ensure a variable date is not in the past, compared to the
> current date? Here's how I'm trying, unsuccessfully:
>
> $nextdate = "8/2/2009";
>
> if(strtotime($nextdate)<=getdate()){
>
>        echo "Sorry, your next evaluation date cannot be in the past,
> Click BACK to continue.";
>        exit;
>
> }

RTFM.

The strtotime function will give you a timestamp, getdate will give
you an array, so your comparison is non-sensical. Use the time
function to get the current date/time as a timestamp.

-Stuart

-- 
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Paul M Foster
On Fri, Aug 28, 2009 at 02:53:56PM +0100, Stuart wrote:

> 2009/8/28 Adam Jimerson :
> > On 08/27/2009 11:09 PM, Adam Jimerson wrote:
> >> This question might give away the fact that I am a php noob, but I am
> >> looking for the best way to test for form submission in PHP.  I know in
> >> Perl this can be done with
> >>
> >> if (param)
> >>
> >> but I don't know if that will work with PHP.  I have read the Learning
> >> PHP 5 book and the only thing that was mentioned in the book was the use
> >> of something like this
> >>
> >> print "Hello ".$_POST['username']."";
> >
> > Sorry copied and pasted the wrong line (long day)
> >
> > if (array_key_exists('username',$_POST))
> >>
> >> I'm sure that this is not the best/recommended way to do this but I'm
> >> hoping someone here will point me in the right direction.
> 
> Two options...
> 
> 1) if (isset($_POST['username'])) // Specific to any given form
> 
> 2) if (count($_POST) > 0) // Just tests whether any data was POSTed

FWIW, the CodeIgniter framework uses this latter method internally.

Paul

-- 
Paul M. Foster

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Error when execute header('location: otherpage.php') after email been sent out. Any Workaround?

2009-08-28 Thread Stuart
2009/8/28 Martin Scotta :
> On Fri, Aug 28, 2009 at 10:39 AM, Ashley Sheridan
> wrote:
>
>> On Fri, 2009-08-28 at 10:34 -0300, Martin Scotta wrote:
>> > Actually there aren't a safe way to make a redirect
>> >
>> > We have 4 alternatives (correct me if I miss anything) to do a safe
>> > redirection.
>>
>> Erm wtf?!
>>
>> The best bet is always going with a header() redirect. The only time
>> I've seen that fail is when the developer of the PHP script has made a
>> mistake. The browser should always honor this type of redirect, and you
>> have none of the issues with Javascript turned off, browser plugins
>> blocking redirects, or stupid users etc.
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>>
> What you are is truth if it only applies to computer browsers.
> There are many "clients" where the Location header don't work.
>
> Curl is a good example, you can determine to follow the Redirect or just
> skip it.
> curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false)
>
> Another example could be mobile phones, especially wml based, do not follow
> a redirection and you have to provide a "click here to redirect" link and
> relies on the user to follow the redirection.
>
> Do not trust that your client is always a browser. It could be anything that
> can open a connection and send a request.
>
> Also you can't know who is at the other side. The client can provide fake
> UA, IP, everything... or can't send anything but the need to make a valid
> request.

In the realm of assumptions made by developers, that the client
understands and will correctly process a 301/302 response is one of
the safer assumptions. It's certainly safer than assuming the client
will respect a meta tag or javascript.

If you really try to deal with every possible client to that extent
you'll never ship anything. Yes it's important to be as supportive as
possible, but care should be taken to pick the battles that are worth
fighting.

-Stuart

-- 
http://stut.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Date Comparison

2009-08-28 Thread David Stoltz
How to I ensure a variable date is not in the past, compared to the
current date? Here's how I'm trying, unsuccessfully:

$nextdate = "8/2/2009";

if(strtotime($nextdate)<=getdate()){

echo "Sorry, your next evaluation date cannot be in the past,
Click BACK to continue.";
exit;

}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Stuart
2009/8/28 Eric :
>
> - Original Message -
> From: "Adam Jimerson" 
> To: 
> Sent: Friday, August 28, 2009 11:21 AM
> Subject: [PHP] Re: Best way to test for form submission?
>
>
>> On 08/27/2009 11:09 PM, Adam Jimerson wrote:
>>> This question might give away the fact that I am a php noob, but I am
>>> looking for the best way to test for form submission in PHP.  I know in
>>> Perl this can be done with
>>>
>>> if (param)
>>>
>>> but I don't know if that will work with PHP.  I have read the Learning
>>> PHP 5 book and the only thing that was mentioned in the book was the use
>>> of something like this
>>>
>>> print "Hello ".$_POST['username']."";
>>
>> Sorry copied and pasted the wrong line (long day)
>>
>> if (array_key_exists('username',$_POST))
>
> Here is another way
>
> if (isset($_POST['username'])  && $_POST['username'] != '')
> { ...

If you use this method then you'll completely ignore a form submission
if they've forgotten to enter a username. Detection and validation are
two distinct steps and should be treated as such.

-Stuart

-- 
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Martin Scotta
what about a simple

if( count( $_POST ))

All you need is to check a form submission

On Fri, Aug 28, 2009 at 10:55 AM, Eric  wrote:

>
> - Original Message -
> From: "Adam Jimerson" 
> To: 
> Sent: Friday, August 28, 2009 11:21 AM
> Subject: [PHP] Re: Best way to test for form submission?
>
>
> > On 08/27/2009 11:09 PM, Adam Jimerson wrote:
> >> This question might give away the fact that I am a php noob, but I am
> >> looking for the best way to test for form submission in PHP.  I know in
> >> Perl this can be done with
> >>
> >> if (param)
> >>
> >> but I don't know if that will work with PHP.  I have read the Learning
> >> PHP 5 book and the only thing that was mentioned in the book was the use
> >> of something like this
> >>
> >> print "Hello ".$_POST['username']."";
> >
> > Sorry copied and pasted the wrong line (long day)
> >
> > if (array_key_exists('username',$_POST))
>
> Here is another way
>
> if (isset($_POST['username'])  && $_POST['username'] != '')
> { ...
>
>
> >>
> >> I'm sure that this is not the best/recommended way to do this but I'm
> >> hoping someone here will point me in the right direction.
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>



-- 
Martin Scotta


Re: [PHP] Error when execute header('location: otherpage.php') after email been sent out. Any Workaround?

2009-08-28 Thread Martin Scotta
On Fri, Aug 28, 2009 at 10:39 AM, Ashley Sheridan
wrote:

> On Fri, 2009-08-28 at 10:34 -0300, Martin Scotta wrote:
> > Actually there aren't a safe way to make a redirect
> >
> > We have 4 alternatives (correct me if I miss anything) to do a safe
> > redirection.
>
> Erm wtf?!
>
> The best bet is always going with a header() redirect. The only time
> I've seen that fail is when the developer of the PHP script has made a
> mistake. The browser should always honor this type of redirect, and you
> have none of the issues with Javascript turned off, browser plugins
> blocking redirects, or stupid users etc.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>
What you are is truth if it only applies to computer browsers.
There are many "clients" where the Location header don't work.

Curl is a good example, you can determine to follow the Redirect or just
skip it.
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false)

Another example could be mobile phones, especially wml based, do not follow
a redirection and you have to provide a "click here to redirect" link and
relies on the user to follow the redirection.

Do not trust that your client is always a browser. It could be anything that
can open a connection and send a request.

Also you can't know who is at the other side. The client can provide fake
UA, IP, everything... or can't send anything but the need to make a valid
request.

-- 
Martin Scotta


Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Eric

- Original Message - 
From: "Adam Jimerson" 
To: 
Sent: Friday, August 28, 2009 11:21 AM
Subject: [PHP] Re: Best way to test for form submission?


> On 08/27/2009 11:09 PM, Adam Jimerson wrote:
>> This question might give away the fact that I am a php noob, but I am
>> looking for the best way to test for form submission in PHP.  I know in
>> Perl this can be done with
>> 
>> if (param)
>> 
>> but I don't know if that will work with PHP.  I have read the Learning
>> PHP 5 book and the only thing that was mentioned in the book was the use
>> of something like this
>> 
>> print "Hello ".$_POST['username']."";
> 
> Sorry copied and pasted the wrong line (long day)
> 
> if (array_key_exists('username',$_POST))

Here is another way

if (isset($_POST['username'])  && $_POST['username'] != '')
{ ...


>> 
>> I'm sure that this is not the best/recommended way to do this but I'm
>> hoping someone here will point me in the right direction.
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Stuart
2009/8/28 Adam Jimerson :
> On 08/27/2009 11:09 PM, Adam Jimerson wrote:
>> This question might give away the fact that I am a php noob, but I am
>> looking for the best way to test for form submission in PHP.  I know in
>> Perl this can be done with
>>
>> if (param)
>>
>> but I don't know if that will work with PHP.  I have read the Learning
>> PHP 5 book and the only thing that was mentioned in the book was the use
>> of something like this
>>
>> print "Hello ".$_POST['username']."";
>
> Sorry copied and pasted the wrong line (long day)
>
> if (array_key_exists('username',$_POST))
>>
>> I'm sure that this is not the best/recommended way to do this but I'm
>> hoping someone here will point me in the right direction.

Two options...

1) if (isset($_POST['username'])) // Specific to any given form

2) if (count($_POST) > 0) // Just tests whether any data was POSTed

There are other ways to do it but I usually use one of these two.

-Stuart

-- 
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Ashley Sheridan
On Thu, 2009-08-27 at 23:21 -0400, Adam Jimerson wrote:
> On 08/27/2009 11:09 PM, Adam Jimerson wrote:
> > This question might give away the fact that I am a php noob, but I am
> > looking for the best way to test for form submission in PHP.  I know in
> > Perl this can be done with
> > 
> > if (param)
> > 
> > but I don't know if that will work with PHP.  I have read the Learning
> > PHP 5 book and the only thing that was mentioned in the book was the use
> > of something like this
> > 
> > print "Hello ".$_POST['username']."";
> 
> Sorry copied and pasted the wrong line (long day)
> 
> if (array_key_exists('username',$_POST))
> > 
> > I'm sure that this is not the best/recommended way to do this but I'm
> > hoping someone here will point me in the right direction.
> 
> 

The best way I've found is to do something like this:

if(isset($_POST['submit']))
{}

Note that in-place of submit you can put the name of any form element. I
chose submit here, because every form should have a submit button. Note
also that this will only work if you have given your submit button a
name:



Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Nitsan Bin-Nun
";

On Fri, Aug 28, 2009 at 5:21 AM, Adam Jimerson  wrote:

> On 08/27/2009 11:09 PM, Adam Jimerson wrote:
> > This question might give away the fact that I am a php noob, but I am
> > looking for the best way to test for form submission in PHP.  I know in
> > Perl this can be done with
> >
> > if (param)
> >
> > but I don't know if that will work with PHP.  I have read the Learning
> > PHP 5 book and the only thing that was mentioned in the book was the use
> > of something like this
> >
> > print "Hello ".$_POST['username']."";
>
> Sorry copied and pasted the wrong line (long day)
>
> if (array_key_exists('username',$_POST))
> >
> > I'm sure that this is not the best/recommended way to do this but I'm
> > hoping someone here will point me in the right direction.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Error when execute header('location: otherpage.php') after email been sent out. Any Workaround?

2009-08-28 Thread Keith

Hi all,
Yes, you are right, it was due to echo for testing purpose not been 
commented out prior to header().
However, there is hidden root cause too --  PHPMailer will echo invalid 
address to the screen.
When I have tested with 1 valid email address and 1 invalid with 
someth...@locahost, PHPMailer will echo out the invalid someth...@localhost.
However, in this case, $mail->send() still will return value of TRUE as long 
as at least 1 email been sent out.
After I have commented out all these [echo], no more header issue occur 
again.


It's works too using Floyd's recommended javascript! However, the message 
will echoed out first before redirect to index.php, but this is fast enough 
to be neglectable.


I have one more question regarding error logging.
I have set as below:

ini_set('log_errors', 1);
ini_set('error_log', "http://domain.com/log/logfile.txt";);
ini_set('error_reporting', 'E_ALL');
ini_set('error_append_string', '\r\n');

I have simulated an error which can be displayed on screen because I've put 
ini_set('display_errors',1).

However, the error was not been logged.

Which format should I used for log file? *.log or *.txt?

Since I'm using third party web hosting, I can only access web directory, 
should I use

[http://domain.com/log/logfile.*] or
[C:\some_path\domain.com\log\logfile.*] or just
[/log/logfile.*]?

Thanks!
Keith


"Floyd Resler"  wrote in message 
news:a536e452-54a2-4f55-8ae0-28e875a59...@adex-intl.com...
Another solution would be to use JavaScript.  In your process.php  script 
you could do this:

print<<
window.location.href="index.php"

here;

Not strictly a PHP solution but it works.

Take care,
Floyd

On Aug 28, 2009, at 5:34 AM, Ashley Sheridan wrote:


On Fri, 2009-08-28 at 17:32 +0800, Keith wrote:
I have a user sign up page that collects sign up information from  user 
with

form.
This form will then be submitted to another process.php page for 
setting up

the user account and send email to the user.
After the email been sent out, the user will be directed back to 
homepage

with header("location: index.php").
However, error happen with warning: [Cannot modify header  information -
headers already sent by...]
Any workaround for this?

Thanks for help!
Keith





You don't need a workaround. The header("Location...") thing will only
work if you have not sent any content to the browser yet. That  includes
even a single space or newline.

It looks like in your process.php page, something is being output to  the
browser. Are you able to do a code dump of that page?

Thanks,
Ash
http://www.ashleysheridan.co.uk




--
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] Re: Best way to test for form submission?

2009-08-28 Thread Adam Jimerson
On 08/27/2009 11:09 PM, Adam Jimerson wrote:
> This question might give away the fact that I am a php noob, but I am
> looking for the best way to test for form submission in PHP.  I know in
> Perl this can be done with
> 
> if (param)
> 
> but I don't know if that will work with PHP.  I have read the Learning
> PHP 5 book and the only thing that was mentioned in the book was the use
> of something like this
> 
> print "Hello ".$_POST['username']."";

Sorry copied and pasted the wrong line (long day)

if (array_key_exists('username',$_POST))
> 
> I'm sure that this is not the best/recommended way to do this but I'm
> hoping someone here will point me in the right direction.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Best way to test for form submission?

2009-08-28 Thread Adam Jimerson
This question might give away the fact that I am a php noob, but I am
looking for the best way to test for form submission in PHP.  I know in
Perl this can be done with

if (param)

but I don't know if that will work with PHP.  I have read the Learning
PHP 5 book and the only thing that was mentioned in the book was the use
of something like this

print "Hello ".$_POST['username']."";

I'm sure that this is not the best/recommended way to do this but I'm
hoping someone here will point me in the right direction.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Error when execute header('location: otherpage.php') after email been sent out. Any Workaround?

2009-08-28 Thread Ashley Sheridan
On Fri, 2009-08-28 at 10:34 -0300, Martin Scotta wrote:
> Actually there aren't a safe way to make a redirect 
> 
> We have 4 alternatives (correct me if I miss anything) to do a safe
> redirection.

Erm wtf?!

The best bet is always going with a header() redirect. The only time
I've seen that fail is when the developer of the PHP script has made a
mistake. The browser should always honor this type of redirect, and you
have none of the issues with Javascript turned off, browser plugins
blocking redirects, or stupid users etc.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Error when execute header('location: otherpage.php') after email been sent out. Any Workaround?

2009-08-28 Thread Martin Scotta
On Fri, Aug 28, 2009 at 9:36 AM, Floyd Resler  wrote:

> Another solution would be to use JavaScript.  In your process.php script
> you could do this:
> print<< 
>window.location.href="index.php"
> 
> here;
>
> Not strictly a PHP solution but it works.
>
> Take care,
> Floyd
>
>
> On Aug 28, 2009, at 5:34 AM, Ashley Sheridan wrote:
>
>  On Fri, 2009-08-28 at 17:32 +0800, Keith wrote:
>>
>>> I have a user sign up page that collects sign up information from user
>>> with
>>> form.
>>> This form will then be submitted to another process.php page for setting
>>> up
>>> the user account and send email to the user.
>>> After the email been sent out, the user will be directed back to homepage
>>> with header("location: index.php").
>>> However, error happen with warning: [Cannot modify header information -
>>> headers already sent by...]
>>> Any workaround for this?
>>>
>>> Thanks for help!
>>> Keith
>>>
>>>
>>>
>>>
>> You don't need a workaround. The header("Location...") thing will only
>> work if you have not sent any content to the browser yet. That includes
>> even a single space or newline.
>>
>> It looks like in your process.php page, something is being output to the
>> browser. Are you able to do a code dump of that page?
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>>
>> --
>> 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
>
>
Actually there aren't a safe way to make a redirect. Every technique relies
on the client-side to perform the redirection.

We have 4 alternatives (correct me if I miss anything) to do a safe
redirection.

   1. header Location
   2. meta tag refresh
   3. javascript
   4. the user


We will try every one in the given order...

Let's suppose we want to redirect the client to $url...



Redirecting...




/*';
/*]]>*/



You are about to be redirected to  in 2
seconds



Click here if your browser do not redirect automatically







It's recommended that your use a common redirect method in your site, this
is not mandatory but it is a good practice.

This simple script also helps to prevent session problems under some evil
web-server by closing the session before any output.



-- 
Martin Scotta


RE: [PHP] vote package

2009-08-28 Thread Bob McConnell
From: Ben Dunlap

>> You might try to use the reported IP of the submitter, again unique,
but
>> that can be forged -- so again anyone can vote more than once.
> 
> Can you say more about forging the reported IP? I've always been under
> the impression that forging the source IP in a TCP session is a pretty
> sophisticated operation, but maybe I'm mistaken about that.

Forging IP addresses is actually quite simple. VMs do it all the time
when bridged to the real NIC. There are also some projects on Source
Forge designed to load test HTTP servers that do similar things. I have
an application I wrote for testing that can emulate an entire class B
subnet full of computers. All it takes is a little digging around on
Google, a FreeBSD system installed in a VM and a little knowledge of the
local network topology. In my case I have several blocks of addresses
allocated by the local administrator for this test bed.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Error when execute header('location: otherpage.php') after email been sent out. Any Workaround?

2009-08-28 Thread Floyd Resler
Another solution would be to use JavaScript.  In your process.php  
script you could do this:

print<<
window.location.href="index.php"

here;

Not strictly a PHP solution but it works.

Take care,
Floyd

On Aug 28, 2009, at 5:34 AM, Ashley Sheridan wrote:


On Fri, 2009-08-28 at 17:32 +0800, Keith wrote:
I have a user sign up page that collects sign up information from  
user with

form.
This form will then be submitted to another process.php page for  
setting up

the user account and send email to the user.
After the email been sent out, the user will be directed back to  
homepage

with header("location: index.php").
However, error happen with warning: [Cannot modify header  
information -

headers already sent by...]
Any workaround for this?

Thanks for help!
Keith





You don't need a workaround. The header("Location...") thing will only
work if you have not sent any content to the browser yet. That  
includes

even a single space or newline.

It looks like in your process.php page, something is being output to  
the

browser. Are you able to do a code dump of that page?

Thanks,
Ash
http://www.ashleysheridan.co.uk




--
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



RE: [PHP] user permissions

2009-08-28 Thread Bob McConnell
From: Ben Dunlap

>> Yes, they offer an additional layer of granularity on permissions.
The apps
>> I write use groups and role to limit acces to certain functionality.
The
>> roles determine functional access to records, ie what the user can do
with
>> them. The groups membership determines what records the user can see.
E.g.
> 
> But is this substantially different from just allowing "groups" to
> determine access to functionality, /and/ access to records, and
> letting the admin create different groups for different reasons? I
> guess I'm thinking of the way Active Directory works, which I've
> found, in my second life as a system administrator, to be both easy to
> grasp and extremely flexible/powerful.

Yes it is. The extra layer allows me to be an admin in group A, only a
reader in group B, and a moderator in group C. The question is whether
you will need the extra level of control now or in the future.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] safe_mode and inclusion of files don't work as documented

2009-08-28 Thread Nico Sabbi
hack988 hack988 ha scritto:
> add this
> php_admin_value open_basedir
>
>   

done, but it doesn't make a difference:
php_admin_value open_basedir
"/server/home/nsabbi:/server/home/apache/php4:.:.."

*Fatal error*: require_once() [function.require
]: Failed opening required
'../include.php'
(include_path='.:/server/home/apache/php4/:/var/php/5.2/pear/:/usr/php/lib/ezcomponents-2008.2.2/')
in */server/home/nsabbi/nb4/login/index.php* on line *3


and the same with
*php_admin_value open_basedir none

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] safe_mode and inclusion of files don't work as documented

2009-08-28 Thread hack988 hack988
add this
php_admin_value open_basedir


2009/8/28 Nico Sabbi :
> Hi,
> I'm testing one of my sites in safe_mode, but I'm experiencing some
> strangeness that is not documented.
>
> The settings are:
> in php.ini:
> include_path =
> ".:/server/home/apache/php4/:/var/php/5.2/pear/:/usr/php/lib/ezcomponents-2008.2.2/"
>
> in the virtualhost config:
>        php_admin_value safe_mode On
>        php_admin_value safe_mode_include_dir
> "/server/home/nsabbi:/server/home/apache/php4:.:.."
>
> The files belong entirely to apache:apache, the user who is running apache.
> The problem is:
>
>
> *Fatal error*: require_once() [function.require
> ]: Failed opening required
> '../include.php'
> (include_path='.:..:/server/home/apache/php4/:/var/php/5.2/pear/:/usr/php/lib/ezcomponents-2008.2.2/')
> in */server/home/nsabbi/nb4/login/index.php* on line *3
>
> How is it that i can't include files in .. 
> btw, can I redefine the include_path in safe mode?
>
> Thanks,
>  Nico
> *
>
> --
> 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] safe_mode and inclusion of files don't work as documented

2009-08-28 Thread Nico Sabbi
Hi,
I'm testing one of my sites in safe_mode, but I'm experiencing some
strangeness that is not documented.

The settings are:
in php.ini:
include_path =
".:/server/home/apache/php4/:/var/php/5.2/pear/:/usr/php/lib/ezcomponents-2008.2.2/"

in the virtualhost config:
php_admin_value safe_mode On
php_admin_value safe_mode_include_dir
"/server/home/nsabbi:/server/home/apache/php4:.:.."

The files belong entirely to apache:apache, the user who is running apache.
The problem is:


*Fatal error*: require_once() [function.require
]: Failed opening required
'../include.php'
(include_path='.:..:/server/home/apache/php4/:/var/php/5.2/pear/:/usr/php/lib/ezcomponents-2008.2.2/')
in */server/home/nsabbi/nb4/login/index.php* on line *3

How is it that i can't include files in .. 
btw, can I redefine the include_path in safe mode?

Thanks,
  Nico
*

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Error when execute header('location: otherpage.php') after email been sent out. Any Workaround?

2009-08-28 Thread Keith
I have a user sign up page that collects sign up information from user with 
form.
This form will then be submitted to another process.php page for setting up 
the user account and send email to the user.
After the email been sent out, the user will be directed back to homepage 
with header("location: index.php").
However, error happen with warning: [Cannot modify header information - 
headers already sent by...]

Any workaround for this?

Thanks for help!
Keith



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Calling extension function from another

2009-08-28 Thread hack988 hack988
I don't kown your mean,could you descript the question more detail?

2009/8/28 leledumbo :
>
> Is it possible to call a function that resides in an extension from another
> extension?
> --
> View this message in context: 
> http://www.nabble.com/Calling-extension-function-from-another-tp25185839p25185839.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
>
> --
> 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



Re: [PHP] Error when execute header('location: otherpage.php') after email been sent out. Any Workaround?

2009-08-28 Thread hack988 hack988
Some Php's tigger info output to client before you set header.try this
code first
---
ob_start();//first line write this code
<<>>
header("location:index.php");
ob_end_flush();
---
second.
You must check php.ini found that if flush implicit option turn on.
implicit_flush = On
=>
implicit_flush = Off

test your codes again.

If codes run correctly,check your codes line by lines ,found that such
as 'echo','print'... and so on before 'you
header("location:index.php")' line.
2009/8/28 Keith :
> I have a user sign up page that collects sign up information from user with
> form.
> This form will then be submitted to another process.php page for setting up
> the user account and send email to the user.
> After the email been sent out, the user will be directed back to homepage
> with header("location: index.php").
> However, error happen with warning: [Cannot modify header information -
> headers already sent by...]
> Any workaround for this?
>
> Thanks for help!
> Keith
>
>
>
> --
> 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



Re: [PHP] Error when execute header('location: otherpage.php') after email been sent out. Any Workaround?

2009-08-28 Thread Ashley Sheridan
On Fri, 2009-08-28 at 17:32 +0800, Keith wrote:
> I have a user sign up page that collects sign up information from user with 
> form.
> This form will then be submitted to another process.php page for setting up 
> the user account and send email to the user.
> After the email been sent out, the user will be directed back to homepage 
> with header("location: index.php").
> However, error happen with warning: [Cannot modify header information - 
> headers already sent by...]
> Any workaround for this?
> 
> Thanks for help!
> Keith
>  
> 
> 

You don't need a workaround. The header("Location...") thing will only
work if you have not sent any content to the browser yet. That includes
even a single space or newline.

It looks like in your process.php page, something is being output to the
browser. Are you able to do a code dump of that page?

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Calling extension function from another

2009-08-28 Thread leledumbo

Is it possible to call a function that resides in an extension from another
extension?
-- 
View this message in context: 
http://www.nabble.com/Calling-extension-function-from-another-tp25185839p25185839.html
Sent from the PHP - General mailing list archive at Nabble.com.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php