Titus Cheung wrote:
Can I have it such that "removerow.php" don't need to be called and the PHP
script can call instead a local function to execute the job?
No. PHP is an interpretor that executes as the web server (usually
Apache) is being asked for the page. Once the page has been given to the
user, PHP has done its job. To run more script, another page has to be
called for, and so on. That is server-side scripting.
You're thinking of client-side scripting (such as - spit, curse -
JavaScript). That is executed by the web browser (which is why it will
work for some users, and throw object errors for most others).
However, you're obviously new to server-side scripting, and you haven't
learned the tricks of the trade. Here are the basics.
A form calls another PHP page using the action='php-page.php' attribute
in the form tag. If you are going to do something 'unique' with the data
that you pass to php-page.php, such as update a database, which you will
only want to happen once for that data, then you should set method to
POST. So this gives you something like this:
<form action='php-page.php' method='post'>
If the data is just used to do something common, such as call a list of
results that people are going to want to be able to see over and over
again, then use method='get'. The GET method puts the data into the URL
itself, so the URL can be cached. POST does not allow caching, and the
data is passed as part of the HTTP request.
You also state that only one variable can be sent to a PHP page in a
form. This is not true at all. You can send as much as you like (in a
POST method; GET has limits on how much can fit because it goes into the
URL).
An example form with multiple variables would be:
<form action='php-page.php' method='post'>
<input type='text' name='userInput' maxlength='20' />
<input type='checkbox' name='checkboxArray[]' value='box1' />
<input type='checkbox' name='checkboxArray[]' value='box2' />
<input type='checkbox' name='checkboxArray[]' value='box3' />
<input type='hidden' name='globalVar' value='".$globalVariable."' />
<input type='submit' value='Click Here to Submit' />
</form>
The text type allows a user to put text into a text field; the checkbox
type allows multiple items to be selected and stored in the
checkBoxArray[] variable (notice that each checkbox element of the same
group must have the same name, and must end with [] square brackets);
the hidden type allows you to add unseen variables to a form so that
they don't interfere with the user, but they will be passed to the page
mentioned in action.
Hopefully this answers the questions you have raised in your posting.
However, there is much more to forms if you need more. Try
www.w3c.org,
the home of WWW standards, for more form elements.
www.htmlgoodies.com
is also very good. And, of course, the PHP manual.
--
Bob
London, UK
echo Mail fefsensmrrjyaheeoceoq\! | tr "jefroq\!" "@obe.uk"