|
Posted by Erwin Moller on 03/23/07 16:28
sathyashrayan wrote:
> Dear group,
> My question may be novice. I have seen codes where the isset() is
> used to test weather a user's session ($_SESSION[]) is set before
> entering a page. A kind of direct access to a page is not possible.
> But I tested with the "input type="button" and the clicking of the
> event is not happened. Can any one tell me why. The code:
>
> <html>
> <body>
>
> <form name='noname' action='test.php' method=post>
> <input type="button" name='button' value='button'>
> </form>
>
> </body>
> </html>
>
> <?php
>
> if(isset($_REQUEST['button']))
> {
> echo "clicked";
> }
>
> ?>
>
> If I change the <input type='submit'> then it works, like get
> submitted and perform the action. But why not with button?
Hi,
<Input type="button"> is just a HTML element.
PHP is NOT involved what the receiving browser does with the HTML received.
However, if you press a submit-button, you are posting a form to some
script, in this case PHP.
Keep a sharp eye on what client-server actually is if you want to learn PHP.
WHAT happens at the server?
WHAT happens at the client (browser)?
In short: PHP produces output. That output goes to the browser. Browser
displays it.
If the HTML send to the browser happens to contain a form, then nothing
special happens: it just displays the form.
However, if you submit the form, your browser sends the information
contained in the form to the receiving script.
PHP can see what is posted by examining:
$_POST[] superglobal for forms with method="POST".
and
$_GET[] retrieves all name/value pairs from the URL.
eg, if you make a page with a form that contains:
<input type="text" name="familyname">
and that is posted to PHP (actiontag in the form), then PHP can retrieve
that value via:
$passedFamilyName = $_GET["familyname"];
About the isset(): If you are not sure the form send to PHP contains an
element with the name familyname, you can use isset to test this.
if (isset($_GET["familyname"])){
// code for existence of familyname
} else {
// no familyname
}
Hope that helps.
Regards,
Erwin Moller
[Back to original message]
|