Re: [PHP] Directing form to different handlers?

2009-06-01 Thread Matthew McKay
It would be much simpler and cleaner to use Javascript to modify the form's
action attribute onClick.

On Mon, Jun 1, 2009 at 2:28 PM, Shawn McKenzie  wrote:

> Jason Pruim wrote:
> >
> > On May 31, 2009, at 10:53 PM, Angus Mann wrote:
> >
> >> Hi all. I realize this is more an HTML question than PHP but I'm sure
> >> someone here can help.
> >>
> >> I have several forms with lots (dozens) of text inputs. If the user
> >> presses the "Update" button I want the form handled by "update.php"
> >> but if they press "Delete" it needs to be handled by "delete.php" or
> >> "add.php" and so-on depending on the button they press.
> >>
> >> But when establishing the form I can only have  >> action="delete.php"> or "add.php" or whatever.
> >>
> >> Is there a way to direct the content of the form do a different
> >> handler depending on the button?
> >>
> >> I know I can use javascript to direct to a constructed URL and append
> >> ?name=smith&address=hishouse&telephone=28376.and so on but this is
> >> not practical when there are dozens of entriesthe URL becomes
> >> massive. I prefer to use "POST" and then use PHP to extract the POST
> >> array.
> >>
> >
> > Couldn't you use a switch statement in a process.php file?
> >
> >  >
> > $var = $_GET['switchvar'];
> >
> > switch($var) {
> >
> > case "add";
> > include("add.php");
> > break;
> >
> > case "delete";
> > include("delete.php");
> > break;
> >
> > default;
> > echo "Nothing selected";
> > break;
> >
> > }
>
> Yes, something like this except it would be $_POST.  Your form/buttons
> would be something like:
>
> 
> ..
> 
> 
> 
> 
>
>
> And then process.php with a switch or something using the value of
> $_POST['submit'].
>
>
> --
> 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] Directing form to different handlers?

2009-06-01 Thread Matthew McKay
On Mon, Jun 1, 2009 at 2:43 PM, James Ausmus
wrote:

> On Mon, Jun 1, 2009 at 12:32 PM, Matthew McKay  wrote:
> > It would be much simpler and cleaner to use Javascript to modify the
> form's
> > action attribute onClick.
> >
>
> Not really. What about clients who don't have Javascript installed?
> What about users who want to either do something nefarious or just to
> see what happens,  - exposing your "Delete my record"-specific PHP
> code could potentially cause security holes. The less of your internal
> interface/structure you expose to the end user, the less easy it is
> for the casual script kiddies to find the security holes that you have
> (and yes, everyone has them... ;)  )
>
> -James
>

How is passing parameters to a 'delete' action different than passing
'delete' as a parameter to a general purpose action?
You do have a point with not all clients having Javascript. It would be a
business decision on the part of Shawn if he wants to support the fraction
of users running browsers without support for the most basic of extensions.


Re: [PHP] Need unrounded precision

2009-11-04 Thread Matthew McKay

Kim Madsen wrote:

Hello

Andre Dubuc wrote on 2010-01-02 02:20:

Hi,

I need to extract the first digit after the decimal point from a 
number such as 28.56018, which should be '5'.


Since no one came up with the simple solution:

$num = "28.56018";
ereg("^[0-9]+\.([0-9]){1}", trim($num), $regs);
if($regs[1])
  $digit = $regs[1];
else
  print "no digit found";


My submission for a "simple" solution. I wish I had xslt2 =(

   
   select="number(substring(substring-after(number(translate(normalize-space($number),translate(normalize-space($number),'.0123456789',''),'')),'.'),1,1))"/>




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