Re: [PHP] PHP delete confirmation
yes,i agree with you,Richard L. Buskirk. process by client-side script,such as javascript is the best and convenient way. Best regards, Sharl.Jimh.Tsin (From China **Obviously Taiwan INCLUDED**) 2011/4/29 : > This can be done in the delete.php file OR use javascript onClick to confirm > the intent. > > > Delete.php > If($_GET['confirm'] == "Yes") > { > //Delete actions > }else If($_GET['confirm'] == "No") > { > //No Delete actions. > }else{ > //display a delete confirmation and remember to carry required information > like the value you passed for delete. > } > ?> > > > Personally I would use the javascript page navigation is senseless if they > miss click. > > Javascript: Small and simple javascript. > > onclick="return confirm('Are you sure you want to delete?')" > > > > Richard L. Buskirk > > > -Original Message- > From: Chris Stinemetz [mailto:chrisstinem...@gmail.com] > Sent: Friday, April 29, 2011 12:33 AM > To: php-general@lists.php.net > Subject: [PHP] PHP delete confirmation > > I have been trying to figure out how to add delete confirmation for > the bellow snippet of code. I would prefer not to use javascript. Can > anyone offer any advise on how to right the delete confirmation in > PHP? > > Thank you in advance. > > P.S. I apologize for the indention. For some reason gmail messes it up. > > // loop through results of database query, displaying them in the > table > while($row = mysql_fetch_array( $result )) { > > // echo out the contents of each row into a table > echo ""; > echo '' . $row['Name'] . ''; > echo '' . $row['Date'] . ''; > echo '' . $row['StoreInfo'] . ''; > echo '' . $row['Address'] . ''; > echo '' . $row['Type'] . ''; > echo '' . $row['EngTech'] . ''; > echo '' . $row['StoreManager'] . ''; > echo '' . $row['BBtime'] . ''; > echo '' . $row['BBup'] . ''; > echo '' . $row['BBdown'] . ''; > echo '' . $row['SiteSect'] . ''; > echo '' . $row['VoiceCall'] . ''; > echo '' . $row['Comments'] . ''; > echo 'Edit'; > echo 'Delete'; > echo ""; > } > > // close table> > echo ""; > ?> > > -- > 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: What's faster using if else or arrays?
On Thu, 2011-04-28 at 22:12 -0400, Jim Giner wrote: > Obviously you have designed a search/decision mechanism that suits your > needs. The OP did not present a problem of such magnitude. He only asked > how to handle a decision process the most efficient way - with no mention of > higher goals such as yours. > > didn't mean to offend anyone who has made a powerful use of the array > constuct. > > "Geoff Lane" wrote in message > news:1286892056.20110429010...@gjctech.co.uk... > > On Thursday, April 28, 2011, Jim Giner wrote: > > > I see no problem using in_array() for situations like this, and they can be used in conjunction with a switch if you want as well: switch(true) { case in_array($needle, array('foo','bar','wtf')): { // do something break; } case ($needle == 88): { // something else break; } } And it's still quite readable as long as you get your indentation right. -- Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] PHP delete confirmation
This can be done in the delete.php file OR use javascript onClick to confirm the intent. Delete.php Personally I would use the javascript page navigation is senseless if they miss click. Javascript: Small and simple javascript. onclick="return confirm('Are you sure you want to delete?')" Richard L. Buskirk -Original Message- From: Chris Stinemetz [mailto:chrisstinem...@gmail.com] Sent: Friday, April 29, 2011 12:33 AM To: php-general@lists.php.net Subject: [PHP] PHP delete confirmation I have been trying to figure out how to add delete confirmation for the bellow snippet of code. I would prefer not to use javascript. Can anyone offer any advise on how to right the delete confirmation in PHP? Thank you in advance. P.S. I apologize for the indention. For some reason gmail messes it up. "; echo '' . $row['Name'] . ''; echo '' . $row['Date'] . ''; echo '' . $row['StoreInfo'] . ''; echo '' . $row['Address'] . ''; echo '' . $row['Type'] . ''; echo '' . $row['EngTech'] . ''; echo '' . $row['StoreManager'] . ''; echo '' . $row['BBtime'] . ''; echo '' . $row['BBup'] . ''; echo '' . $row['BBdown'] . ''; echo '' . $row['SiteSect'] . ''; echo '' . $row['VoiceCall'] . ''; echo '' . $row['Comments'] . ''; echo 'Edit'; echo 'Delete'; echo ""; } // close table> echo ""; ?> -- 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] PHP delete confirmation
I have been trying to figure out how to add delete confirmation for the bellow snippet of code. I would prefer not to use javascript. Can anyone offer any advise on how to right the delete confirmation in PHP? Thank you in advance. P.S. I apologize for the indention. For some reason gmail messes it up. "; echo '' . $row['Name'] . ''; echo '' . $row['Date'] . ''; echo '' . $row['StoreInfo'] . ''; echo '' . $row['Address'] . ''; echo '' . $row['Type'] . ''; echo '' . $row['EngTech'] . ''; echo '' . $row['StoreManager'] . ''; echo '' . $row['BBtime'] . ''; echo '' . $row['BBup'] . ''; echo '' . $row['BBdown'] . ''; echo '' . $row['SiteSect'] . ''; echo '' . $row['VoiceCall'] . ''; echo '' . $row['Comments'] . ''; echo 'Edit'; echo 'Delete'; echo ""; } // close table> echo ""; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] gd Graphics Library Question (EXIF)
I have written a lightweight, easy to use photo album "system" in HTML/PHP/MySQL.In addition to the Photo Album side I have written a series of Admin Utilities to manage it with. One of the administrative utilities uploads photos from my local drive, resizes them to be more efficient on disk space, creates thumbnails and populates the database with as much "default" data as can be deduced. After all of this was written, I decided to see if I could pull EXIF data to supply some of the technical data for the DB. To my surprise, the only EXIF data in the JPEG files was data in the File, Computed and Comments sections. Why don't the gd utilities retain the original EXIF data? Is there any way to do so? I use the following gd utilities to resize and create the new JPEG image files: imagecreatefromjpeg imagesx imagesy imagercreatetruecolor imagecopyresized imagejpeg Thanks in advance, Mitch -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: What's faster using if else or arrays?
Obviously you have designed a search/decision mechanism that suits your needs. The OP did not present a problem of such magnitude. He only asked how to handle a decision process the most efficient way - with no mention of higher goals such as yours. didn't mean to offend anyone who has made a powerful use of the array constuct. "Geoff Lane" wrote in message news:1286892056.20110429010...@gjctech.co.uk... > On Thursday, April 28, 2011, Jim Giner wrote: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: What's faster using if else or arrays?
On Thursday, April 28, 2011, Jim Giner wrote: > Arrays - using a silly construct that probably still takes as much > time to evaluate machine-wise as anything else. And as far as > readability goes, it is even sillier. IMO. I don't know so much about that ... I'll use a global array to define an application-wide set and then use in_array to branch dependent on whether some variable has a value that is or is not a member of that set. Using a series of predicates in a multiple OR, or using switch is a non-started for me for maintenance reasons, and the alternative of storing the set of values in a database is a lot slower. Here's an example: FWIW, I've got a mapping application. Users can click on a map tile to indicate a point of interest. However, they can also click on zoom buttons, or pan buttons. These buttons are named 'plus', 'minus', 'left', 'right', 'up', and 'down' and I have these names in an application-wide array: $controls = array ('plus', 'minus', 'left', 'right', 'up', 'down'); The way that these map view controls are handled is very different to the way a click on a map tile is handled. Somehow, the code is more readable with: if (in_array($clicked, $controls)){ // ... } than with: if ($clicked == 'plus' || $clicked == 'minus' || $clicked == 'left' || $clicked == 'right' || $clicked == 'up' || $clicked == 'down'){ // ... } Even using switch isn't as clear IMO as that can intersperse the options with several lines of code, which can make the logic harder to spot. However, the real benefit of using an array comes in making the code easier to maintain. Drawing my map is a library routine, as is the handler for the controls. However, the handling of clicks on map tiles is different for each of the eight or nine contexts in which the mapping is used. So the best way IMO of coding this is to test in each page which element has been clicked and to either call a library routine or a context-specific handler from there. Now say, for example, that I want to augment the zoom functionality by having a 'slider' that permits the user to go directly to a desired zoom level. I can redefine the set of controls by simply changing the global array. However, using the long if construct mandates that I must amend the code of every page that uses the mapping, which makes for a lot of extra work and is just plain silly IMO. IOW, using an array can help avoid coding inconsistencies. -- Geoff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's faster using if else or arrays?
On 11-04-28 06:37 PM, dholmes1...@gmail.com wrote: Thanks switch and case seems to be more faster for the job and a lot cleaner --Original Message-- From: Andre Polykanine To: dholmes1...@gmail.com Cc: php-general@lists.php.net Subject: Re: [PHP] What's faster using if else or arrays? Sent: Apr 28, 2011 6:17 PM Hello Dholmes1031, I would write it like this: switch($foo) { case 5: $dothis; break; case 3: $dothat; break; default: $donothing; break; } This sounds like a job for *dun dun dun* GOTO! Kidding, of course ;) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Flattery will get you nowhere
On 11-04-28 05:23 PM, Nathan Rixham wrote: tedd wrote: At 4:58 PM -0400 4/27/11, Robert Cummings wrote: Tedd who? ;) Cheers, Rob. Rob what? ;-) Cheers, tedd flirting? Flirting will get you everywhere *bats eyelids* -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: What's faster using if else or arrays?
Arrays - using a silly construct that probably still takes as much time to evaluate machine-wise as anything else. And as far as readability goes, it is even sillier. IMO. (remainder deleted for readers' sakes :) ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's faster using if else or arrays?
Thanks switch and case seems to be more faster for the job and a lot cleaner --Original Message-- From: Andre Polykanine To: dholmes1...@gmail.com Cc: php-general@lists.php.net Subject: Re: [PHP] What's faster using if else or arrays? Sent: Apr 28, 2011 6:17 PM Hello Dholmes1031, I would write it like this: switch($foo) { case 5: $dothis; break; case 3: $dothat; break; default: $donothing; break; } -- With best regards from Ukraine, Andre Skype: Francophile My blog: http://oire.org/menelion (mostly in Russian) Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion Original message From: dholmes1...@gmail.com To: php-general@lists.php.net Date created: , 12:30:31 AM Subject: [PHP] What's faster using if else or arrays? I'm working on a project and I was wondering if I should use if else's or arrays ?? Example If($foo= 5) { $dothis } ElseIf($foo= 3) { $dothis } Else{ $donothing } Or put it in some short of arrays and pregmatch what would be the best to use and easiest to read Sent via BlackBerry from T-Mobile -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Sent via BlackBerry from T-Mobile
Re: [PHP] Re: What's faster using if else or arrays?
Hello Jim, I heard of arrays in the following context: if (($foo==5) || ($foo=="orange") || ($foo==88) .. So *that* would be done much better and cleaner with arrays. $FoosArray=array(5, "orange", 88); if (in_array($foo, $FoosArray)) { ... } -- With best regards from Ukraine, Andre Skype: Francophile My blog: http://oire.org/menelion (mostly in Russian) Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion Original message From: Jim Giner To: php-general@lists.php.net Date created: , 12:36:26 AM Subject: [PHP] Re: What's faster using if else or arrays? how many entries are you talking about, ie., how many conditions? Obviously if you have more than 4-5 it's going to be easier to code up as a case statement (?) rather than an if/else. Never in all my days have I ever heard of using an array for such a determination though. (remainder deleted for all reader's sakes :) ) -- 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] What's faster using if else or arrays?
Hello Dholmes1031, I would write it like this: switch($foo) { case 5: $dothis; break; case 3: $dothat; break; default: $donothing; break; } -- With best regards from Ukraine, Andre Skype: Francophile My blog: http://oire.org/menelion (mostly in Russian) Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion Original message From: dholmes1...@gmail.com To: php-general@lists.php.net Date created: , 12:30:31 AM Subject: [PHP] What's faster using if else or arrays? I'm working on a project and I was wondering if I should use if else's or arrays ?? Example If($foo= 5) { $dothis } ElseIf($foo= 3) { $dothis } Else{ $donothing } Or put it in some short of arrays and pregmatch what would be the best to use and easiest to read Sent via BlackBerry from T-Mobile -- 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] Javascript detection
On Thursday, April 28, 2011, Ashley Sheridan wrote: > I'm not sure if my earlier reply got through, but here it is again (or > at least the general gist of it) Many thanks. I got your info the first time around but didn't respond directly to you as Tedd made similar comments and I'd responded to his post. > Like everyone has mentioned thus far, it's better to use progressive > enhancement or try to avoid relying on Javascript at all. Even a website > as complex as Facebook allows users to go on it without needing a > browser that runs Javascript. Something as complex as Google Docs has a > very clear need for Javascript though, so you wouldn't expect that to > work without it. In my case, one of the controls I'm considering is a tiled map with up to 16 tiles. This is on a page with four tabbed sections that takes several seconds to load at broadband speeds. Also, the nature of the site means that people may need to access it and use this form while connected via mobile broadband or even GSM; connection media that are usually both slow and paid for per unit of data transfer. I need to record in hidden input fields the location of where a user clicks on the map and also echo that click back in the form of a marker overlaid on the clicked tile. Using AJAX, I can update just the two fields plus one image. Without Javascript, the extra bandwidth needed to unnecessarily download the entire page multiple times will cost my users both time and money. So while I must ensure the site works without Javascript, I really need the optimisation that JS brings. > Lastly, if you're creating the website for a government or business, you > really need to make it work without Javascript, as a lot of countries > make it illegal to discriminate against a disability, which you would be > doing if you made a site that was unusable without Javascript. After > all, there are many speech and Braille browsers out there that can't > take advantage of Javascript, and a lot of Javascript apps which require > mouse interaction to run (mouseover/hover events, etc) AIUI, a lot of countries (mine included) make it unlawful to knowingly discriminate against the disabled. However, The Disability Discrimination Act requires only that reasonable steps be taken to avoid discrimination ... and making stuff accessible to the disabled at considerable inconvenience and/or expense to everyone else is not considered reasonable. Now where I can, I'll produce stuff that is enhanced by images, colour, JS etc. but will still be usable in Lynx. However, some stuff (e.g. mapping) won't work without graphics and so is inherently unavailable to the visually impaired. It makes no sense whatever to try to make such content work in speech and Braille browsers. Thus making a site that's unusable without Javascript doesn't necessarily constitute unlawful discrimination! -- Geoff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: What's faster using if else or arrays?
how many entries are you talking about, ie., how many conditions? Obviously if you have more than 4-5 it's going to be easier to code up as a case statement (?) rather than an if/else. Never in all my days have I ever heard of using an array for such a determination though. (remainder deleted for all reader's sakes :) ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What's faster using if else or arrays?
I'm working on a project and I was wondering if I should use if else's or arrays ?? Example If($foo= 5) { $dothis } ElseIf($foo= 3) { $dothis } Else{ $donothing } Or put it in some short of arrays and pregmatch what would be the best to use and easiest to read Sent via BlackBerry from T-Mobile -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Flattery will get you nowhere
tedd wrote: At 4:58 PM -0400 4/27/11, Robert Cummings wrote: Tedd who? ;) Cheers, Rob. Rob what? ;-) Cheers, tedd flirting? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Javascript detection
On Thu, 2011-04-28 at 10:17 -0400, tedd wrote: > At 9:02 AM +0100 4/28/11, Geoff Lane wrote: > > > >FWIW, it's possible to detect whether or not Javascript is available, > >but not AFAICT at 'first contact' because you need the 'first contact' > >page to do something to prove that JS is available, from which you can > >assume that JS is not should that something not be done. For example, > >you can make the link to a page into a form submission - e.g: > > > > > > > > > >>onClick="document.forms['jstest'].submit();return(false);"> > > Click Here > > > >The form is submitted if the browser has JS and so the hidden input > >field is posted. However, if the browser doesn't have JS the default > >behaviour occurs when the link is clicked and so the field is not > >posted. Hence we can use isset($_POST['wehavejs']) to determine > >whether or not the browser has JS capability. > > > >Thanks again, > > > >-- > >Geoff > > Geoff: > > You are correct about "first contact" -- you need to launch the > browser to check to see if the browser has javascript enabled. > There's currently no way for the server to see what the user has > selected for their browser before the browser launches. > > It is true that the $_SERVER global provides all sorts of information > about the requester and I suppose it could also contain the browser's > javascript configuration, but it doesn't. > > However, JavaScript detection doesn't require a user's response, as > you have proposed via a form. > > Instead, you can simply add an "onload()" operation to the page and > detect javascript, such as: > > http://www.webbytedd.com/b1/ajax-js-dection/ > > Or do it unobtrusively as I have shown before. > > Cheers, > > tedd > > > -- > --- > http://sperling.com/ > I'm not sure if my earlier reply got through, but here it is again (or at least the general gist of it) There are ways you can detect if a browser is *capable* of running Javascript using $_SERVER['HTTP_USER_AGENT'] and an up-to-date browscap.ini file. This will allow you to check if the browser indicated by the user agent. However, there are caveats to this approach: * A browser might be sending the wrong user agent string, there are plenty of plugins which do this * A browser might be capable of running Javascript but might have it turned off or otherwise blocked * Filtering may be going on by a proxy server or firewall that strips out Javascript (sounds stupid but happens in paranoid businesses) Like everyone has mentioned thus far, it's better to use progressive enhancement or try to avoid relying on Javascript at all. Even a website as complex as Facebook allows users to go on it without needing a browser that runs Javascript. Something as complex as Google Docs has a very clear need for Javascript though, so you wouldn't expect that to work without it. Lastly, if you're creating the website for a government or business, you really need to make it work without Javascript, as a lot of countries make it illegal to discriminate against a disability, which you would be doing if you made a site that was unusable without Javascript. After all, there are many speech and Braille browsers out there that can't take advantage of Javascript, and a lot of Javascript apps which require mouse interaction to run (mouseover/hover events, etc) -- Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] Re: How to write a PHP coding to list out all files and directories aslinks to them?
On 4/14/2011 6:16 PM, Mikhail S wrote: How to write a PHP coding to list out all files and directories as links to them? This is somewhat similar to some index pages. When new file or folder is added to the directory, HTML page should display the newly created file/folder together with previous ones after it is being refreshed. (prefer in alphabatical order) How to achieve this sort of functionality in PHP? Please provide sample coding as well. (and any references) Thanks. -- Mike http://jp.shopsloop.com/ OK, maybe not the most elegant ... but it works for my purposes ... and it was my first attempt at these directory functions. You can navigate up and down the directory hierarchy. It flags files older than 1 year for potential cleanup. Hope it gives you some ideas and a place to start... Mitch #! /usr/bin/php4 Diskspace Analyzer $value){ $$key = $value; } ?> Enter Directory Name Here \n"); print("$dName Directory Information \n"); print("Highlighted files are older than 1 year and candidates for cleanup \n"); print("\n"); print("File NameFile SizeFile Date\n"); $d = @dir(trim($dName)); while ($entry = @$d->read()){ $total++; $fileExt = explode(".", $entry); if(is_dir($d->path . "/" . $entry)){ if($fileExt[0] ==""){ $fileExt[1] = "SysDirectories"; } else { $fileExt[1] = "Directories"; } $dirSize = filesize($d->path . "/" . $entry); $totaldirSize += $dirSize; $dirList[$entry] = $dirSize; } else { $fileExt[1] = "Files"; $fileStats = @stat($d->path . "/" . $entry); $fileSize = $fileStats[7]; $totalSize += $fileSize; $currDate = getdate(); $fdDay = date("z", $fileStats[10]); $fdYear = date("Y", $fileStats[10]); $ckDay = $currDate["yday"]; $ckYear = ($currDate["year"] - 1); if (($fdYear < $ckYear) || (($fdYear == $ckYear) && ($fdDay <= $ckDay))){ $highlight = "yellow"; $totalSavings += $fileStats[7]; } else { $highlight = "white"; } print("\t\n"); print("\t\t$entry$fileSize"); printf("%s", date("m/d/Y", $fileStats[10])); print("\n"); print("\t\n"); } $fileTypes[$fileExt[1]]++; } print("\t\n"); print("\t\tTotal Bytes in Files$totalSize"); if ($totalSavings > 0){ print("Potential Savings: $totalSavings"); } print("\n"); print("\t\n"); print(" \n"); if(count($dirList) > 1){ ksort($dirList); print("\n"); print("Directories\n"); foreach ($dirList as $key=>$value){ print("\t\n"); if ($key == "."){ print("\t\t$key (Current)\n"); } elseif ($key == ".."){ $truncPoint = strrpos($dName, "/"); $parentDir = substr($dName, 0, $truncPoint); if ($parentDir == ""){ $parentDir = "/"; } print("\t\t$key (Parent)\n"); } else { print("\t\t$key\n"); } print("\t\n"); } print("\t\n"); print("\t\tTotal Bytes ($totaldirSize)\n"); print("\t\n"); print(" \n"); } ksort($fileTypes); arsort($fileTypes); print("\n"); foreach ($fileTypes as $key=>$value){ print("$key ($value)\n"); }; print("\n"); print("Total Objects in $filespec branch: $total\n"); print("Total Bytes in $filespec branch: " . ($totalSize + $totaldirSize) . " \n"); } else { Print ("Requested Directory ( $dName ) was not found\n"); } // end if (isset(... print ("\n"); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Javascript detection
At 9:02 AM +0100 4/28/11, Geoff Lane wrote: FWIW, it's possible to detect whether or not Javascript is available, but not AFAICT at 'first contact' because you need the 'first contact' page to do something to prove that JS is available, from which you can assume that JS is not should that something not be done. For example, you can make the link to a page into a form submission - e.g: onClick="document.forms['jstest'].submit();return(false);"> Click Here The form is submitted if the browser has JS and so the hidden input field is posted. However, if the browser doesn't have JS the default behaviour occurs when the link is clicked and so the field is not posted. Hence we can use isset($_POST['wehavejs']) to determine whether or not the browser has JS capability. Thanks again, -- Geoff Geoff: You are correct about "first contact" -- you need to launch the browser to check to see if the browser has javascript enabled. There's currently no way for the server to see what the user has selected for their browser before the browser launches. It is true that the $_SERVER global provides all sorts of information about the requester and I suppose it could also contain the browser's javascript configuration, but it doesn't. However, JavaScript detection doesn't require a user's response, as you have proposed via a form. Instead, you can simply add an "onload()" operation to the page and detect javascript, such as: http://www.webbytedd.com/b1/ajax-js-dection/ Or do it unobtrusively as I have shown before. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] refreshing pages in the cache
Your welcome, I am glad that it works and is doing what your after. > To: php-general@lists.php.net > From: jim.gi...@albanyhandball.com > Date: Thu, 28 Apr 2011 09:19:58 -0400 > Subject: Re: [PHP] refreshing pages in the cache > > Yes - that seems to be the trick! Thank you very much for your tip AND > your patience. :) > > You've made an old programmer's day! > > > > -- > 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] Flattery will get you nowhere
At 9:11 AM -0400 4/28/11, Marc Guay wrote: > What are you are looking for? I'm working on a new form and after reading a few threads on this list since I've subscribed I realized that validating input is a weakness of mine. I figured you would have an example online somewhere covered some of the main security concerns. Marc Marc: It's a larger concern than an on-line example somewhere would show. I did a presentation on PHP security for my students, which much of it I took from "Essential PHP Security" by Chris Shiflett -- see: http://phpsecurity.org/ The book is inexpensive enough -- I suggest that IF you are interested (as you should be if you're a developer), then buy it, read it, and practice it. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] refreshing pages in the cache
Yes - that seems to be the trick! Thank you very much for your tip AND your patience. :) You've made an old programmer's day! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Flattery will get you nowhere
> What are you are looking for? I'm working on a new form and after reading a few threads on this list since I've subscribed I realized that validating input is a weakness of mine. I figured you would have an example online somewhere covered some of the main security concerns. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Detecting Javascript (was Re: Newsgroup status)
[snip] this isn't possible [/snip] Welcome to the world of progressive enhancement! http://www.alistapart.com/articles/understandingprogressiveenhancement/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Nested XInclude in XML
I need to insert a content of an XML node into text of another XML element in the same document. I use XInclude for this purpose. For example: http://www.w3.org/2001/XInclude";> Lorem ipsum sed do eiusmod tempor dolor sit amet, consectetur adipisicing elit It works well when a node what content is inserted from contains only text (e.g., first sql node in the "foo" query in example above). So I have "Lorem ipsum dolor sit amet," in the first sql node in the "bar" query after parsing. That's what I want. But I have a problem when I try to insert a content of a node containing xi:include. For example I have " dolor sit amet, consectetur adipisicing elit" instead of "Lorem ipsum dolor sit amet, consectetur adipisicing elit" in the second sql node within the "bar" query. When I use xpointer without text( ) at end I have the following as content of the second sql node within the "bar" query: http://www.w3.org/2001/XInclude"; db="oracle">Lorem ipsum dolor sit amet, consectetur adipisicing elit It's almost correct, but here are undesirable sql tags. I've tried to use range-inside() function of xpointer in this way: .. consectetur adipisicing elit .. Content of the second sql node in the "bar" query has been changed to this: consectetur adipisicing elit As you can see content of included sql node entirely gone. What's wrong? Am I using XInclude or XPointer in the wrong way? Or may be PHP XML parser (I use DOMDocument for working with this XML document) isn't entirely conformed with XInclude or XPointer standard? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Javascript detection
tedd wrote: > As Yogi Berra once said; "It's always hard to predict things > especially when it deals with the future." > He was quoting Niels Bohr: http://www.quotationspage.com/quote/26159.html -- Per Jessen, Zürich (10.2°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Destroying cookies... not working
On Thursday, April 28, 2011, Sean Greenslade wrote: > On Wed, Apr 27, 2011 at 8:52 PM, Rick Dwyer > wrote: >> The following did the trick... is there any reason I should not use it? >> >> $name="mysession"; >> setcookie($name); >> >> --Rick > Only if you're OCD, since the cookie is still technically there, just empty. > Without setting the expire arg, the browser will keep it until closed. What happens if you then use isset($_COOKIE['mysession'])? TBH, I don't know and don't have the time to experiment just now. However, this should return false if the cookie has been destroyed but if just set to null or an empty string via Rick's code I suspect it'd return true. -- Geoff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Javascript detection
On Thursday, April 28, 2011, tedd wrote: > To answer your question in a new thread. > No, the $_SERVER super-global isn't going to give you anything nor is > anything else like it. > You see, PHP has a difficult time detecting IF Javascript is turned > ON in the client's browser because PHP is history by the time the > browser does anything, including running Javascript. Thanks, Tedd. That's how I suspected things to be. However, the list was very quiet, I might have missed something, and so I felt it couldn't hurt to ask. TBH I'd already done: echo ""; print_r ($_SERVER); echo ""; and didn't spot anything there that I thought would give me the info I sought - but then I don't know the purpose of every element of that array and $_SERVER is not the only superglobal! > As Yogi Berra once said; "It's always hard to predict things > especially when it deals with the future." However, once the browser has requested a transfer via HTTP that request is in the past and that request is where stuff that lets you know some of the browser's capabilities (e.g. HTTP_ACCEPT) comes from. So it would be possible by a similar mechanism for a browser to tell your script whether or not Javascript (or any other language for that) is available. > However, there are two ways to "kind-of" doing it: > Way 1 -- I place an element in html that is hidden from the user's > view via css (display:none) and if Javascript is ON then Javascript > changes the css so that the element is shown to the user > (display:block). Here's an example: This is the reverse of part of what I've done for the page in question. I had a tabbed interface similar to: [stuff] [stuff] ... However, the second div must be visible if JS isn't available otherwise the user can't access that section. So I've changed the style of the second and subsequent divs to display:block and then used an onLoad routine to change the .style.display and .style.visibility attributes of the second and subsequent divs to none and hidden respectively so that those who have JS get the full DHTML. Now I also using AJAX on that page. However, I can use the fact that the trigger events aren't handled if JS isn't available to just retrieve what's actually needed at the time via AJAX if JS is available or submit the full form if it's not. Of course, that complicates things in the PHP on the server as the script then has to handle both interim and final form submission. FWIW, it's possible to detect whether or not Javascript is available, but not AFAICT at 'first contact' because you need the 'first contact' page to do something to prove that JS is available, from which you can assume that JS is not should that something not be done. For example, you can make the link to a page into a form submission - e.g: Click Here The form is submitted if the browser has JS and so the hidden input field is posted. However, if the browser doesn't have JS the default behaviour occurs when the link is clicked and so the field is not posted. Hence we can use isset($_POST['wehavejs']) to determine whether or not the browser has JS capability. Thanks again, -- Geoff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php