Checking if 'button' set with isset() (beginner)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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:


   <form name='noname' action='test.php' method=post>
   <input type="button" name='button' value='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?

Re: Checking if 'button' set with isset() (beginner)

sathyashrayan wrote:

Quoted text here. Click to load it


<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".
$_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.

Erwin Moller

Re: Checking if 'button' set with isset() (beginner)

On Mar 23, 9:28 pm, Erwin Moller
Quoted text here. Click to load it

Yes helped a lot. Thanks..

Site Timeline