Re: [PHP] Cookies and sent headers

2007-08-19 Thread Otto Wyss

M. Sokolewicz wrote:
On a sidenote, 99% of the world never calls ob_flush (or any such 
function) since PHP flushes the buffer automatically at the end of its 
execution.


I'll keep the ob_end_flush just for showing what's going on, but thanks 
for the hint.


The reason why setting cookies for you doesn't work is because of the 
way a HTTP response is structured. It consists of 2 parts: header and 
body separated by 2 new lines (\n\n). It is _required_ that _all_ 
headers come _before_ the body. Cookies are actually headers (a 
set-cookie: [...] header) aswell as any headers set via php's header() 
function. Any output made by the script (be it a single whitespace, a 
bunch of text, etc.) will automatically flush the headers, followed by 
the separator (\n\n) followed by the specified output. After that has 
been sent, everything outputted will be dumped into the body of the 
response (simply because you can't go back to the headers which were 
already sent earlier), so you can't set cookies (which are headers 
themselves).



Thanks, now it's understandable.

So, why does output buffering help here? Simply put, instead of dumping 
headers and any other output directly to the client, PHP buffers it all 
into memory. As such, since it hasn't been sent yet, PHP can still 
alter/add headers even though it also has body-output. Once it receives 
the command, PHP will send all headers, the separator and the output to 
the client. This is done when PHP encounters an ob_flush or ob_end_flush 
call, _and_ when the script has finished execution automatically.


The documentation seems pretty clear to me, however, if you feel it 
should be clarified better, feel free to send a patch to the 
[EMAIL PROTECTED] list.


- Tul


O. Wyss

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



[PHP] Redirection with header (was Re: [PHP] Cookies and sent headers)

2007-08-19 Thread Otto Wyss

M. Sokolewicz wrote:

emits). Now, I'm not going to go into how redirecting that way won't
work (or at least shouldn't), but a hint would be to do it properly
using header('Location: [...]') instead.


I'm aware that using Javascript within a PHP code block doesn't seems
logical yet I haven't known header ('Location...). In my case I could 
easilly do without redirection but just exit and fall back on the 
calling page. Yet I want to remove the login page from the browser 
history. Does the header function have the same effect?


O. Wyss

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



[PHP] Cookies and sent headers

2007-08-18 Thread Otto Wyss
If built a simple login page and store any information within 
$_SESSION's. Yet I'd like to move these into cookies but I always get an 
error about sent headers. Is there a way to circumvent this problem 
without changing too much in the page?


The setting of the cookies happens just at the end of the page.

  if (!$errortext and $Anmelden) {
if (!empty($Permanent)) {
  $expires = time()+ 365 * 86400;  // 365 days
  setcookie (l.Lastname, $_SESSION['l_Lastname'], $expires);
  setcookie (l.Firstname, $_SESSION['l_Firstname'], $expires);
  setcookie (l.Email1, $_SESSION['l_Email1'], $expires);
  setcookie (l.Email2, $_SESSION['l_Email2'], $expires);
}
echo script type=\text/javascript\
  parent.location.replace('$index_php;
  /script;
exit;
  }

O. Wyss

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



Re: [PHP] Cookies and sent headers

2007-08-18 Thread Otto Wyss
ob_start() at the beginning and ob_end_flush() at the end of the PHP 
section seems to do the trick albeit I've still problems to understand 
why. The description in the manual is rather sparse unfortunately. Is 
there any more information about what's going on?


O. Wyss

Wouter van Vliet / Interpotential wrote:

You best option would be to go through all of your include'd or require'd
files and make sure there is no whitespace before and after you open your
php tags. Those are often the cause for such problems. The easy way would
indeed be to use output buffering. In that case, put the call to ob_start();
on the first line of the file you're calling. You will still have to make
sure to not have any whitespace before your ?php opening.

To even bypass that, the output_buffering ini setting might be useful. Alter
it in your php.ini if you can, otherwise try your apache vhost configuration
or .htaccess. The syntax there is:

 php_flag output_buffering On

Good luck!

On 18/08/07, Kelvin Park [EMAIL PROTECTED] wrote:

Kelvin Park wrote:

Otto Wyss wrote:

If built a simple login page and store any information within
$_SESSION's. Yet I'd like to move these into cookies but I always get
an error about sent headers. Is there a way to circumvent this
problem without changing too much in the page?

The setting of the cookies happens just at the end of the page.

  if (!$errortext and $Anmelden) {
if (!empty($Permanent)) {
  $expires = time()+ 365 * 86400;  // 365 days
  setcookie (l.Lastname, $_SESSION['l_Lastname'], $expires);
  setcookie (l.Firstname, $_SESSION['l_Firstname'], $expires);
  setcookie (l.Email1, $_SESSION['l_Email1'], $expires);
  setcookie (l.Email2, $_SESSION['l_Email2'], $expires);
}
echo script type=\text/javascript\
  parent.location.replace('$index_php;
  /script;
exit;
  }

O. Wyss


ob_start() might help


--
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] Using PHP files from Ajax and from other PHP files

2007-04-17 Thread Otto Wyss
I want move all database access into separate PHP files so I could use 
these files either through an Ajax call from the client or in another 
PHP files (require_once) on the server. Is this possible? What interface 
 would be needed? Has anybody else tried something similar?


Since I plan use Json as the data format for Ajax what overhead would 
that mean to decode again already Json encoded result if used on the 
server? Is there a workaround for Json in case of Ajax but none when 
using in other PHP files?


O. Wyss

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



Re: [PHP] Appending into associative arrays

2007-04-16 Thread Otto Wyss

Alister Bulman wrote:



$dirs[$d] = filemtime($d);

Has he even retrieved the directories in sorted order by modification
time? If not he still needs to sort.


Then he'll need an asort($dirs);  They would not have come in any
particular order, so you have to sort them for whatever you need
anyway.

Fine. But how do I now implement recursive looking for directories? My 
code doesn't work.


  function recurseDir ($base, $accending = true, $dirs = array()) {
$handle = opendir ($base);
while ($dir = readdir($handle)) {
  if (($dir != '..') and ($dir != '.')) {
$d = $base.'/'.$dir;
if (is_dir ($d)) {
  $dirs[$d] = filemtime($d);
  recurseDir ($d, true, $dirs);
}
  }
}
closedir ($handle);
asort ($dirs);
return array_keys ($accending? $dirs: array_reverse ($dirs));
  }

O. Wyss

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



Re: [PHP] Appending into associative arrays

2007-04-16 Thread Otto Wyss

Zoltán Németh wrote:

what do you mean by doesn't work? what error is thrown if any? what
result do you get instead of the expected?
at first glance I cannot see anything wrong with your function...

It simply doesn't add any sub folder to $dirs. Could it be that the 
function doesn't return the $dirs parameter?


O. Wyss

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



Re: [PHP] Json.php

2007-04-16 Thread Otto Wyss

Jochem Maas wrote:


that's going to make it completely impossible to use then isn't it.
no way you could possibly wrap the class/objects functionality in a wrapper
function.

At the moment it's sufficient, since I've now time to figure out how the 
Json package can be installed. Then I can switch to use the usual 
json_encode function. Thanks.


O. Wyss

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



[PHP] Appending into associative arrays

2007-04-15 Thread Otto Wyss
I want to sort directories according there modification time and thought 
accociative arrays would be perfect. But when I add an element like


$dirs = array (filemtime($d) = $d)

the previous ones are lost. I tried array_push but that doesn't seems to 
work, at least I always get syntax errors. Next try was 
array_merge(array (...)). So what next?


O. Wyss

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



Re: [PHP] Json.php

2007-04-15 Thread Otto Wyss

Tijnema ! wrote:


*ROFLMFAO*...Did you actually try google for json.php?
Second result:
http://mike.teczno.com/JSON/JSON.phps

This doesn't have a json_encode but needs a $json object which then 
could be used as $json-encode(...). Thanks anyway.


O. Wyss

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



Re: [PHP] Json.php

2007-04-15 Thread Otto Wyss

Satyam wrote:

www.json.org lists all json resources in any language you care to think of.

I must admit I haven't checked each reference but the ones I have have 
only packages to install and not a PHP source. Maybe I wasn't clear when 
asking.


O. Wyss

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



[PHP] Json.php

2007-04-14 Thread Otto Wyss
I've seen a json.php file somewhere in a project for cases where the 
json module isn't installed (e.g. PHP4), yet I can't find that project 
again. Is there an official or unofficial download site for json.php?


Why isn't this available in the PHP manual 
(http://ch2.php.net/manual/de/ref.json.php)?


O. Wyss

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



Re: [PHP] Posting a variable

2007-04-12 Thread Otto Wyss

Richard Lynch wrote:

On Wed, April 11, 2007 12:53 pm, [EMAIL PROTECTED] wrote:

Quoting Robert Cummings [EMAIL PROTECTED]:


mysql_fetch_row()?


It's a religious question.

I find mysql_fetch_assoc to be less clear because you end up not
necessarily using the data until much later, and by the time you get
to the line that has:

There isn't much religious since you can't use mysql_fetch_assoc when 
you retrieve identical named columns from different table. So you have 
to use mysql_fetch_row and move them immediately into a

better named array.

O. Wyss

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



[PHP] Copying PHP array into a Javascript array

2007-04-10 Thread Otto Wyss
I don't know if I should ask this question here or in the JavaScript 
group. I'll try it here since people usually are more helpful.


I've an array of file names

  $files = getFiles ($d);

but would like to use this array in a JavaScript array. How can I copy 
this $files into a JavaScript variable?


O. Wyss

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



Re: [PHP] Copying PHP array into a Javascript array

2007-04-10 Thread Otto Wyss

Jochem Maas wrote:

// if you have this available: http://php.net/manual/en/function.json-encode.php
echo json_encode($files);

I thought there might be a solution with Json but couldn't locate it. I 
prefer it versus the iteration, thanks. Sometimes solutions are so 
simple if one knows them.


O. Wyss

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



[PHP] PHP sample code for XMLHttprequest with jQuery

2007-03-30 Thread Otto Wyss
I'm currently evaluating jQuery as a Javascript library for my web site 
but first would like to see a working sample with PHP doing 
XMLHttprequest. Is anyone else using jQuery and has some sample code to 
look at?


O. Wyss

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



Re: [PHP] Computing and calculating dates

2007-03-25 Thread Otto Wyss

Sorry that doesn't work with dates like 1.4.2007.

O. Wyss

Jake McHenry wrote:

Change it to the format strtotime needs? Not hard Or mktime(0, 0, 0,
date(m, $date), date(d, $date)+7, date(Y, $date)); for +7 days... Same
with + 14 days Strtotime is usefull, you can just put first day next
month and it just works... Lol... Then you could explode that back into
mktime, or just into a string. There are many ways to do what your
asking :)

Jake


-Original Message-
From: Otto Wyss [mailto:[EMAIL PROTECTED] 
Sent: Saturday, March 24, 2007 4:37 PM

To: php-general@lists.php.net
Subject: Re: [PHP] Computing and calculating dates

Travis Doherty wrote:

Otto Wyss wrote:

  local_formated_date + 7; // days
  local_formated_date  local_formated_first_day_next_month;
  local_formated_date  (current_date + 14)

etc. Which functions are best suited for such calculations?

O. Wyss


www.php.net/strtotime is probably a good start.


Thanks, strtotime isn't able to parse a european formatted date
(dd.mm.). How do I get the timestamp of such a date?

O. Wyss

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

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/731 - Release 
Date: 3/23/2007 3:27 PM
 





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



[PHP] Computing and calculating dates

2007-03-24 Thread Otto Wyss
This probably has been asked several times yet I can't find a satisfying 
solution. What's the simplest way to compute dates like


  local_formated_date + 7; // days
  local_formated_date  local_formated_first_day_next_month;
  local_formated_date  (current_date + 14)

etc. Which functions are best suited for such calculations?

O. Wyss

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



Re: [PHP] Computing and calculating dates

2007-03-24 Thread Otto Wyss

Travis Doherty wrote:

Otto Wyss wrote:

  local_formated_date + 7; // days
  local_formated_date  local_formated_first_day_next_month;
  local_formated_date  (current_date + 14)

etc. Which functions are best suited for such calculations?

O. Wyss


www.php.net/strtotime is probably a good start.


Thanks, strtotime isn't able to parse a european formatted date
(dd.mm.). How do I get the timestamp of such a date?

O. Wyss

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



[PHP] Posting variable outside of the post form

2007-03-12 Thread Otto Wyss

I submit a form back to itself with

  action=?PHP echo $_SERVER['PHP_SELF']; ? methode=get

yet I've a large PHP variable which I'd like to access afterwards as 
well. Is this possible somehow?


O. Wyss

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



[PHP] Array mysteries

2007-03-11 Thread Otto Wyss

I want to convert weekdays with a simple function like

  $wdays = array
(0 = Sonntag
,1 = Montag
,2 = Dienstag
,3 = Mittwoch
,4 = Donnerstag
,5 = Freitag
,6 = Samstag
  );

  function convert_from_weekday ($weekday) {
return $wdays[$weekday];
  }

but this doesn't work while

  $wdays[$weekday];

outside of the function works correct. Has anybody an idea where's my 
mistake? I'd like to use a function so I may return substrings of the 
weekday.


O. Wyss

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



Re: [PHP] Array mysteries

2007-03-11 Thread Otto Wyss

Steve Edberg wrote:

At 9:51 AM +0100 3/11/07, Otto Wyss wrote:


  function convert_from_weekday ($weekday) {
return $wdays[$weekday];
  }

If the above is your exact code, then the problem is one of scope; 
move the $wdays declaration inside your convert_from_weekday() 
function.



I'm more used to C++ than PHP, with global $wdays; it works.


However, you may want to investigate the formatting functions of date():

http://php.he.net/manual/en/function.date.php

Date should return names using the native locale; if you want to 
return date strings for other locales/languages, use setlocale() -


http://php.he.net/manual/en/function.setlocale.php



Thanks, I'll keep this in mind.

O. Wyss

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



[PHP] Creating variable names from values

2007-03-08 Thread Otto Wyss

From an arry I create a table like

  foreach ($persons as $key = $pers) {
echo tdinput name=\K$key\ type=\checkbox\ .../td
  td.../td
  }

so each checkbox field has its own name created from $key. Yet how can I 
access these fields (names) later on?


  foreach ($persons as $key = $pers) {
if ($K???) {
  $cnt += 1; ...
}
  }

Is there a better way to access multiple fields from a table?

O. Wyss

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



[PHP] What sripts,helpers to use for AJAX

2007-03-08 Thread Otto Wyss
I want to add some AJAX communication to my pages and would like to 
know, what scripts, helpers you would recommend. I don't want to use a 
full featured framework, just something to do the AJAX work. So far I've 
come across the following solutions


http://prajax.sourceforge.net/
http://sanjer.berlios.de/

yet they both doesn't seem very much used. Does anybody know these or 
knows better alternatives?


O. Wyss

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



[PHP] GET doesn't work as POST

2007-02-24 Thread Otto Wyss

On the page

http://www.orpatec.ch/turniere/5erfussball/index.php?page=bvallist.phpkind=regions 



I have a form with method=post and action=?PHP $_SERVER['PHP_SELF']; 
?. While it works fine this way, as soon as I change the form to 
method=get it looses the parameter kind when I change e.g. the 
second parameter from -Alle- to Gültig. Has anybody an idea why it 
works with POST but not with GET?


form action=?PHP $_SERVER['PHP_SELF']; ? method=get
...
 select name=state onchange=this.form.submit()

O. Wyss

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



Re: [PHP] GET doesn't work as POST

2007-02-24 Thread Otto Wyss
With method=post just $kind works fine (register_global) yet I've also 
tried any combination of $_GET['kind'] and $_POST['kind']. With 
method=get it doesn't work.


O. Wyss

Peter Lauri wrote:

How are you fetching the GET and POST? With $_GET and $_POST?

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free



-Original Message-
From: Otto Wyss [mailto:[EMAIL PROTECTED] 
Sent: Saturday, February 24, 2007 12:51 PM

To: php-general@lists.php.net
Subject: [PHP] GET doesn't work as POST

On the page

http://www.orpatec.ch/turniere/5erfussball/index.php?page=bvallist.phpkind=
regions 



I have a form with method=post and action=?PHP $_SERVER['PHP_SELF']; 
?. While it works fine this way, as soon as I change the form to 
method=get it looses the parameter kind when I change e.g. the 
second parameter from -Alle- to Gültig. Has anybody an idea why it 
works with POST but not with GET?


form action=?PHP $_SERVER['PHP_SELF']; ? method=get
...
  select name=state onchange=this.form.submit()

O. Wyss



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



Re: [PHP] GET doesn't work as POST

2007-02-24 Thread Otto Wyss

Dotan Cohen wrote:

Try $_GET[kind]


Tried, doesn't help.

O. Wyss

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



Re: [PHP] GET doesn't work as POST

2007-02-24 Thread Otto Wyss

Pintér Tibor wrote:

echo XMP;
print_r($_REQUEST);
echo /XMP;

and think...


After reload
Array
(
   [page] = bvallist.php
   [kind] = regions
   ...
)

After change in form with method=get
Array
(
   [state] = validated
   ...
)

After change in form with method=post
Array
(
   [page] = bvallist.php
   [kind] = regions
   [state] = validated
   ...
)

Yet I still have no idea why GET and POST are different.

O. Wyss

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



[PHP] Understanding session variables with input field and register_global

2007-02-20 Thread Otto Wyss

I've an input field in a form

input name=username type=text ...

and with register_global I can use this field in PHP as variable 
$username. Yet if I use a session variable


$_SESSION['username'] = 'value'

the variable $username gets the same value. On the other side when I 
enter a value in the input field, the session variable isn't changed. So 
how can I set the session variable from the input field after it has 
changed?


O. Wyss

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



Re: [PHP] Multi lingual pages

2007-02-19 Thread Otto Wyss

Paul Novitski wrote:

Unless your site is insanely popular or huge, does the method really 


Sure I hope to once have an insanely popular or huge site, albeit that 
probably won't happen.


O. Wyss

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



Re: [PHP] Multi lingual pages

2007-02-19 Thread Otto Wyss

Jochem Maas wrote:


don't go down the define('LANG_KEY', 'lang string value'); route - defines
are comparatively SLOW to create. IF you go down the road of loading in text
from 'per lang' files I would suggest using an array as the storage mechanism:

$Lang = array(
'LANG_KEY' = 'lang string value',
// .. etc
);

assoc array are much less heavy to create.


Thanks, I'll try the assoc array.


also consider that there are, imho, 2 kinds of language specific data:

1. 'static' values - button texts, [error] messages - these are specified 
during site/application
design.

Yes these are the static texts I'm talking about. They don't depend on 
data, only on layout and design.



2. 'dynamic' values - document titles, headers, content - these are specified 
by the owner/user during
the lifetime of the site/application


Sure, I've these values too and store them in the database.


for the rest I'll just say 'ditto' to most of what the other list members 
replied :-)


Thanks a lot.

O. Wyss

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



[PHP] Accessing cookies in PHP and Javascript

2007-02-15 Thread Otto Wyss

Assuming I have a cookie

setcookie (username,$_SESSION['Username'], $expires);

how can I access the same cookie in Javascript? Or how do I have to 
create a cookies so it's accessable as


$_COOKIE[username]

O. Wyss

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



Re: [PHP] Multi lingual pages

2007-01-26 Thread Otto Wyss

Paul Novitski wrote:

I formulated my question in general since I couldn't find an other 
message here about supporting multiple languages.



http://www.w3.org/International/articles/

http://www.w3.org/TR/i18n-html-tech-lang/

http://php.net/setlocale


Thanks a lot, these are good points for reading.


1) Switching language downloads a new version of the current page, 
generally with the same markup but new text.  Example:

http://partcon.ca/


I'll favor this way especially if several languages have to be provided.

In both cases I store the text in database tables that contain a 
language field I can select on to match the user's request.


I wonder if retrieving static texts from the database draws too much 
performance. I know from somebody who stores texts in large data arrays 
an uses shared memory, yet I haven't figured it out how.


I consider storing static texts as defines and just load a different 
definition file when the user switches language. Is this practical?


O. Wyss

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



[PHP] Multi lingual pages

2007-01-24 Thread Otto Wyss
I'd like to make my pages multi lingual, showing everything in the 
language the user chooses. My pages show mostly static text. So what's 
the usual implementation for this case.


O. Wyss

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



Re: [PHP] Going back with multiple submits to the same page

2007-01-18 Thread Otto Wyss

Paul Novitski wrote:

At 1/15/2007 01:52 PM, Otto Wyss wrote:
When values are entered on one of my page I submit the result back 
to the same page (form action=same_page). Unfortunately each submit

adds an entry into the history, so history back doesn't work in a
single step. Yet if the count of submits were known I could use
goto(n). What's the best way to get this count? PHP or Javascript?



What you're suggesting doesn't sound easy.


I know, but what's a better way to to go back?


If you're going to programmatically take the user to a previous page,
 say for example if they click a form button within your page, then 
using JavaScript you could simply walk backward through the 
window.history() array until you came to an URL that doesn't match 
with the current page.  Of course such a solution would break if 
JavaScript were disabled so you'd need to build a redundant system 
server-side to make sure your site didn't break.



My site already heavily depends on Javascript in many places and my
users can be required to have Javascript enabled.

Just looping through history.back() until a different page is reached
could do the trick. Yet is it possible to have a Javascript value across
multiple pages? Has anybody coded something like this?

Since I already store the last different page, I wounder if I could code 
a loop sever side in PHP which issues Javascript history.back.


Of course PHP isn't naturally aware of browser history but you could 
store in the session or cookie the name of the last page in the


I already do and currently I just jump to that page but it would be nice
to go backwards so the user doesn't have to enter the same values all
the time.

functioning of the browser, you could simply let it do its thing and 
take steps server-side to prevent the user from re-submitting the 
current form or whatever your goal is.


I thought that too albeit it means to implement XMLHttpRequests instead 
of submits to get results from the database. Yet for me this seems to be 
more complicated than just going back through the history. My data is 
rather large and complicate structured.


O. Wyss

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



[PHP] Going back with multiple submits to the same page

2007-01-15 Thread Otto Wyss
When values are entered on one of my page I submit the result back to 
the same page (form action=same_page). Unfortunately each submit adds an 
entry into the history, so history back doesn't work in a single step. 
Yet if the count of submits were known I could use goto(n). What's the 
best way to get this count? PHP or Javascript?


O. Wyss

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



Re: [PHP] Security with dbHost, dbUser, dbPassword

2007-01-11 Thread Otto Wyss

Jochem Maas wrote:
  this file outside of the webroot ...
 
I thought so too but wasn't sure if possible.

if (!defined (config_include)) die (Error...);
 
It helps me a little if I make mistakes.

  granted define() is slower than creating a var - which is why some
  people would recommend against using it.
 
Defines are certainly better in this case even if I don't like them very
much.

  ?
 
  I never include the closing php tag in include files to avoid
  stray empty lines being output - which can cause any headers
  that you try to send after the offending include file is included
  to fail.
 
I'm used to code everything as correct as possible.  ;-)

  Is this save enough or are there better ways? Where should I 
store this

  file so it isn't accessible via the net but inside scripts?
 
  outside the webroot. what people often do is create an include dir
  at the same level as the webroot dir and add this directory to the 
include_path

  ini setting.
 
  e.g.
 
Thanks for the sample. IMO it would be a good idea if the PHP
documentation had a common or best practice section, which contains
such samples. I know there are samples in other places yet these samples
tend to be outdated. I looked through some simple authentication samples
at Zend but all were from year 2001, 2002. I'd prefer just one sample
but up to date.


O. Wyss

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



[PHP] Security with dbHost, dbUser, dbPassword

2007-01-10 Thread Otto Wyss
What is the usual save way to store/use DB access info in a script. I 
currently just use some PHP variables in a file which I include in all 
other scripts.


config.php
?PHP
  if (!defined (config_include)) die (Error...);
  $dbhost = localhost;
  $dbuser = name;
  $dbpass = password;
  $dbname = database;
  $dbcoll = utf8_unicode_ci;
?

Is this save enough or are there better ways? Where should I store this 
file so it isn't accessible via the net but inside scripts?


O. Wyss

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