[PHP] PHP + javascript

2001-05-01 Thread Ide, Jim


Hi -

I want to use javascript to validate some fields on a form.
The javascript code will take the value the user typed
into the form and search for it in an array.  If the value
is found in the array, then the value is ok, otherwise
an alert() message will be displayed.

The amount of data in the array is quite large.

The data in the array rarely changes.

I want to avoid transferring the array from the web server
to the client's web browser every time the user loads the
form.  I put the array in a file called myarray.js:

$ cat myarray.js
var MyArray = new Array(
value 1,
value 2,
many lines snipped
value 789,
value 790
);
$

Then, I put the following line in the php script that generates the form:

script language=JavaScript src=myarray.js/script

By examining Apache's access_log, I see that myarray.js is
transferred to the user's web browser once when the form is first
displayed, and for subsequent uses of the form, the web browser
uses the myarray.js that is cached, so that the array does not
have to be transferred from the web server to the client computer
every time the user uses the form.

So, if the data in the array contained in myarray.js _does_ need
to be changed, I need some way of signaling the user's web browser
that it needs to transfer the updated myarray.js file from the web
server.  How do I do this?

The only way I know to do this is to instruct the users to clear their
web browser cache, which will force the web browser to transfer
the updated myarray.js from the web server to the web browser.

Is there another way?  Is there some kind of expire mechanism
that will tell the web browser that it needs to get the updated
myarray.js file?

Thanks -
Jim Ide




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] url question

2001-04-10 Thread Ide, Jim


I have a php script that browses a database table.
You can page through the database table by
clicking these links:

http://localhost/browse.php?action=first
http://localhost/browse.php?action=prev
http://localhost/browse.php?action=next
http://localhost/browse.php?action=last

When you click the 'action=next' link, the script
displays the next X records (the script remembers
its position within the table).

The script also displays a link to a jpeg of the item
described in the database table.  For example:

http://localhost/images/123456.jpg

If the user clicks the image link, the browser
displays the jpeg.

Suppose the user clicks the 'action=next' link,
and then clicks an image link.  The browser
displays the jpeg.  When the user clicks the
back button, the browser executes the previous
link (ie. the 'action=next' link) which displays
the next page of database records.

I want the browser to NOT display the next page
of data.  I want the browser to stay on the page
that contains the link to the jpeg the user clicked.

How can I prevent the previous link from being
executed when the user clicks the back button?

Thanks -
Jim



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] how do i get a variable type? - not that simple

2001-03-19 Thread Ide, Jim

These are the functions I use to determine if
a string value is a valid integer, real, date, etc.
Hope this helps.

ps - please let me know if you find any errors.  thanx.

?php

function IsValidBoolean($p) {
if ( isset($p) ) {
if ((strtolower($p) == "true") or (strtolower($p) ==
"false"))   return TRUE;
}
return FALSE;
}

function IsValidMemo($p) {

// If $p contains any characters other than printable ascii,
// or \r or \n, return FALSE.

if (trim($p) == "") return TRUE;
if ( ereg("[^\r\n\x20-\x7E]", $p) ) return FALSE;
return TRUE;
}

function IsValidString($p) {

// If $p contains any characters other than printable ascii,
// return FALSE.

if (trim($p) == "") return TRUE;
if ( ereg("[^\x20-\x7E]", $p) ) return FALSE;
return TRUE;
}

function IsValidInteger($p) {

// return TRUE if:
// 1. $p is not equal to ""
// 2. $p consists of 1 or more digits, optionally preceded by a
minus sign

if ( isset($p) )return ereg("^\-?[0-9]+$",$p);
return FALSE;
}

function IsValidReal($p) {

// return TRUE if:
// 1. $p is not equal to ""
// 2. $p begins with optional minus sign, followed by 1 or more
digits, followed by a decimal point,
//followed by 1 or more digits
// 3. $p can be optionally preceded by a minus sign

if ( isset($p) )return ereg("^\-?[0-9]+\.[0-9]+$",$p);
return FALSE;
}

function IsLeapYear($y) {
if ( (($y % 4) == 0)  (($y % 100) != 0) || (($y % 400) == 0))
return TRUE;
return FALSE;
}

function IsValidDate($p) {

// return TRUE if:
// 1. $p is not equal to ""
// 2. $p consists of 4 digits followed by minus sign, followed by 2
digits, followed by
//minus sign, followed by 2 digits
// example 1995-02-03

if ( ! isset($p) )
return FALSE;
if ( ! ereg("^([0-9]{4})\-([0-9]{2})\-([0-9]{2})$",$p) )
return FALSE;

$t = explode("-",$p);
if ( count($t) != 3 )   return FALSE;
$y = $t[0];
$m = $t[1];
$d = $t[2];

return IsValidDate2($y,$m,$d);
}

function IsValidDate2($y,$m,$d) {

if ( ($m  1) or ($m  12) )return FALSE;
if ( ($d  1) or ($d  31) )return FALSE;

// 30 days has sept, apr, jun, and nov (all the rest have 31 [except
for feb])
//   94611

if ( ($m == 4) or ($m == 6) or ($m == 9) or ($m == 11) ) {
if ($d  30)return FALSE;
} elseif ($m == 2) {
if ( IsLeapYear($y) ) {
if ( $d  29 )  return FALSE;
} else {
if ( $d  28 )  return FALSE;
}
}
return TRUE;
}

function IsValidTime($p) {

// return TRUE if:
// 1. $p is not equal to ""
// 2. $p consists of 2 digits in the range 00 to 23,
//  followed by a colon,
//  followed by 2 digits in the range 00 to 59,
//  followed by a colon,
//  followed by 2 digits in the range 00 to 59.
// example 14:45:02

if ( ! isset($p) )
return FALSE;
if ( ! ereg("^([0-9]{2})\:([0-9]{2})\:([0-9]{2})$",$p) )
return FALSE;

$t = explode(":",$p);
if ( count($t) != 3 )   return FALSE;
$h = $t[0];
$m = $t[1];
$s = $t[2];

return IsValidTime2($h,$m,$s);
}

function IsValidTime2($h,$m,$s) {

if ( ($h  0) or ($h  23) )return FALSE;
if ( ($m  0) or ($m  59) )return FALSE;
if ( ($s  0) or ($s  59) )return FALSE;

return TRUE;
}

function IsValidDateTime($p) {

// return TRUE if:
// 1. $p is not equal to ""
// 2. $p consists of a valid date (validated by IsValidDate() above)
//  followed by a space
//  followed by a valid time (validated by IsValidTime() above)
// example: 1998-04-21 22:01:34

if ( ! isset($p) )  return FALSE;

$temp = explode(" ",$p);
if ( count($temp) != 2 )return FALSE;
$d = $temp[0];
$t = $temp[1];
if ( ! IsValidDate($d) )return FALSE;
if ( ! IsValidTime($t) )return FALSE;

return TRUE;
}

function IsValidTimeStamp($p) {

// return TRUE if:
// 1. $p is not equal to ""
// 2. $p consists of a datetime in MMDDHHMMSS format
// example: 19980421220134

if ( ! isset($p) )  return FALSE;
if ( ! ereg("^([0-9]{14})$",$p) )   return FALSE;

$y = substr($p,0,4);
$m = substr($p,4,2);
$d = substr($p,6,2);
$h = substr($p,8,2);
$min = substr($p,10,2);
$s = substr($p,12,2);


[PHP] Detect if user has changed form data

2001-03-13 Thread Ide, Jim



Is there an easy way to detect if a user has changed
the values in the fields of an HTML form?  I want to
be able to check this during the onUnload event and
warn the user that he/she has not clicked the "Save"
button to save changes to the form fields.

The only way I can see to do this is to use JavaScript
to loop thru the variables and compare the current
(possibly changed) value to the value in the defaultValue
property.  I'm hoping that there is a "UserHasChangedFormVariables"
property (or something similar) that I don't know about that someone
will tell me about :)

A pointer to existing code that does this would be appreciated.

Many thanks -
Jim


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Best browser

2001-02-27 Thread Ide, Jim


I am developing a PHP application for a client that allows
users at remote locations to access and update a database.
I would like to standardize on one www browser so that the
help desk people only have to be knowledgeable about one
browser.  The users all have MS Win 95, 98, or NT.  The
quality (ie. the 'bug-free-ness") of the browser's SSL code
is very important.  What browser should I choose?

Thanks -
Jim


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] How do I request a new feature?

2001-02-22 Thread Ide, Jim


Hi -

How can/should I contact the developers of PHP
to request that they add a new feature to PHP?

Thanks -
Jim



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Get name of current function

2001-02-20 Thread Ide, Jim


Hi -

Is there some way I can get the name of the currently executing function?

For example:

?php

function MyFunction () {
echo "The currently executing function is: " . here  ;
}

MyFunction();

?

I want this to produce:
The currently executing function is: MyFunction()

Is there some way to do this in PHP?

Thanks -
Jim


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]