Angus Mann | 1 Jun 2009 04:53
Picon
Favicon

Directing form to different handlers?

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 <form method="POST" 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 entries....the URL becomes massive. I prefer to use "POST" and then use PHP to extract the POST array.

Any ideas?

Much appreciated.
Angus
Robert Cummings | 1 Jun 2009 05:08
Favicon
Gravatar

Re: Directing form to different handlers?

On Mon, 2009-06-01 at 12:53 +1000, 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 <form method="POST" 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 entries....the URL becomes massive. I prefer to use "POST" and then use PHP to extract the POST array.
> 
> Any ideas?

Yes, have the form submit to the URL that presented the form. Have THAT
PHP script determine which button was clicked. Then delegate to the
appropriate handler function.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP

--

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

Robert Cummings | 1 Jun 2009 05:15
Favicon
Gravatar

Re: spawning a process that uses pipes - doesn't terminate when webpage download is canceled

On Sun, 2009-05-31 at 08:52 -0500, flint wrote:
> sent this before, don't know if it went through... someone please reply if 
> it went, even if they don't know answer?...
> 
> so here's the scenario..
> 
> I have a site that uses php with a database to offer sound files to
> users using streaming methods.
> 
> the request page has options, allowing the user to modify the sound
> file in various ways, before having it sent to them
> 
> Here's the problem:
> 
> The method i'm using to feed the data to the user is to run the source
> file through various piped commands, with the resulting audio being
> dumped to stdout, and then using passthru in php to get that data to
> the enduser.
> 
> here's an example, for serving an MP3 with its pitch/speed changed by sox:
> 
> passthru("lame --quiet --decode \"" . $in_file . "\" - | " .
>              "sox -V -S -t wav - -t wav - speed " . $speed_factor . " | " .
>              "lame --quiet " . $lame_params . " - -");
> 
> This works just fine, except the problem is if the end user aborts the
> transfer (e.g. stops playback in the media player, cancels download of
> the mp3, whatever) then it leaves behind both the sox process and the
> decoder LAMe process along with the sh that's running them. the only
> process that exits is the final encoding lame process. If the sound
(Continue reading)

bruce | 1 Jun 2009 06:23
Picon
Favicon

RE: spawning a process that uses pipes - doesn't terminatewhen webpage download is canceled

hi robert.,,

now you've got me curious..

you state...

-Use something else to pass the data back to the user... popen() comes to
-mind or proc_open(). Then disable auto abort on user disconnect via
-ignore_user_abort(). Then after sending periodic data chunks, check the
-user connection status via connection_aborted(). If your script finds
-that the user has aborted, then kill all the processes in the pipeline
-from the PHP script before finally aborting the PHP script itself.

but if the user is using a browser session... which has a web server
connection... are you siggesting that the server app spawns off a child
process via the popen, and that the child somehow connects to the existing
browser session??

walk through the psuedo logic/flow of this if you don't mind.. i must be
missing something..

thanks

-----Original Message-----
From: Robert Cummings [mailto:robert <at> interjinn.com]
Sent: Sunday, May 31, 2009 8:16 PM
To: flint
Cc: PHP-General List
Subject: Re: [PHP] spawning a process that uses pipes - doesn't
terminatewhen webpage download is canceled
(Continue reading)

Manuel Lemos | 1 Jun 2009 06:30
Picon
Favicon

Re: PHP vs ASP.NET

Hello,

on 05/28/2009 10:20 AM Olexandr Heneralov said the following:
> Hi!
> Guys, you of course, know that  ASP.NET becomes more and more popular in the
> world.
> I have a question for everyone:
> Can it happen so that PHP will be replaced with ASP.NET?

ASP.NET is not a language. It is more like a framework that can run
multiple languages. It can run VB.NET, C# and even PHP (although it is
not usual).

I am not sure what are the current numbers, but the latest statistics
that I have seen Apache was running on 72% of the Internet Web servers
against only 17% of Microsoft IIS. Although you can run ASP.NET on
Apache via mono, that is unusual.

Also PHP is the most popular Apache extension present in between 40% and
50% of Apache installations. This means that PHP is present in 1/3 of
the Internet Web servers, which represents about half of the PHP market
share.

This article provides more details about PHP market share.

http://www.phpclasses.org/blog/post/95-How-large-is-the-PHP-market.html

As of ASP.NET becoming more popular than PHP, I don't think that even
Microsoft believes that is possible. Actually Microsoft is very
concerned that PHP runs well on Windows and is sponsoring a lot of PHP
(Continue reading)

Jacob Kutty | 1 Jun 2009 06:55
Picon
Favicon

Jacob's Calendar

Hi

I am creating a birthday calendar of all my friends and family.  Can you please click on the link below to enter
your birthday for me?

http://www.birthdayalarm.com/bd2/85206071a420999425b1469532889c603775600d905

Thanks,
Jacob

--

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

Grega Leskovsek | 1 Jun 2009 12:10
Picon

mysql connections

how do I make a permanent connection to mysql database and what is
difference between mysql_connect() and permanent one?

If I make connections in one file and  redirect it to another file do
I keep connection (permanent / standard)?

Do I lose connection only when I type mysql_close (permanent/ standard)?

if I select different database between the php program do I need to do
something extra along mysql_select_db("dbname",$link)?

If I opened db in another php file, where do I get the $link variable
from = mysql_connect (when selecting another database)?

Thanks in advance,

-- 
When the sun rises I receive and when it sets I forgive ->
http://users.skavt.net/~gleskovs/
All the Love, Grega Leskov'sek

--

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

flint | 1 Jun 2009 12:15
Picon

Re: spawning a process that uses pipes - doesn't terminatewhen webpage download is canceled


----- Original Message ----- 
From: "Robert Cummings" <robert <at> interjinn.com>
To: "flint" <fmillion <at> gmail.com>
Cc: "PHP-General List" <php-general <at> lists.php.net>
Sent: Sunday, May 31, 2009 10:15 PM
Subject: Re: [PHP] spawning a process that uses pipes - doesn't 
terminatewhen webpage download is canceled

I'm already doing something like that... here's what I have basically

$o = popen($cmd);
while (!feof($o)) {
  $buffer = fread($o,4096);
  echo $p;
}
exit();

Ok so I can add in the statements to stop auto aborting, use connection 
aborted... but how do i kill the process chain itself? If I simply pclose 
the process it has the same effect - the other spawned processes keep 
running. I figured out what's happening is the lame process keeps going 
utnil it finishes, and apparently is sending its data to the proverbial bit 
bucket... and in a process tree it moves from being under the http process 
to being under init itself...

fm

> Use something else to pass the data back to the user... popen() comes to
> mind or proc_open(). Then disable auto abort on user disconnect via
(Continue reading)

Muhammad Hassan Samee | 1 Jun 2009 12:43
Picon

Anyone know whats the best way to learn PHP

Hi

Anyone know whats the best way to learn PHP? Every time I open an php book
or look the codes online, my mind goes "oh man, So many stuffs to learn and
gets frustrated before i even start" but on the other hand, I don't know why
some how the brain keep on nagging me to learn PHP. I guess what's the fun
way to learn php? Any good books?
Patrick | 1 Jun 2009 13:01
Favicon

Re: Anyone know whats the best way to learn PHP

I don't think there are any substitutes for good books but
www.phpvideotutorials.com has screencasts. I have really enjoyed them.
There are free ones and paid ones. If funds permit I would recommend the
paid ones, there are hours and hours of them. It does not work out to be
much at all per hour. The free ones are of course the place to start
however.

-Patrick

Muhammad Hassan Samee wrote:
> Hi
>
> Anyone know whats the best way to learn PHP? Every time I open an php book
> or look the codes online, my mind goes "oh man, So many stuffs to learn and
> gets frustrated before i even start" but on the other hand, I don't know why
> some how the brain keep on nagging me to learn PHP. I guess what's the fun
> way to learn php? Any good books?
>
>   

--

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


Gmane