473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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

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?

Mar 23 '07 #1
2 37099
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
Mar 23 '07 #2
On Mar 23, 9:28 pm, Erwin Moller
<since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
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.
Yes helped a lot. Thanks..

Mar 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Ryan | last post by:
I currently have two image submit buttons. The code generated looks like so: <input type="image" src="button_in_cart.gif" border="0" alt="Add" title="Add" name="btn_cart" value="buy"> <input...
7
by: PhilM | last post by:
perhaps I am just a little tired, but I am having trouble with my form buttons. Firstly I name them like this name=\"round".$counter."heats\" which results in variables $round1heats...
8
by: Igor Slivka | last post by:
I have done simple php script and I have corrected every little error I got but now I stucked. I keep getting "You have an error in your SQL syntax near '' at line 9 ", and I don't know what to...
9
by: Bart Nessux | last post by:
Are these equivelent? Is one approach prefered over the other #check to see if var contains something... if so proceed. if var is not None: continue #check to see if var is empty... if so...
5
by: Codeman II | last post by:
Hi there, I am building a form where the user must upload a picture and fill in his details. Now I have a problem as all of this is on the same form. How will I be able to have the Browse...
13
by: pepito3 | last post by:
Hi. I have a question about PHP programming philosophy: Imagine a web of a shop with a table displaying the name of some products. There is a link "Buy" next to each product. I want that link to...
3
by: nehaquick | last post by:
I have a form where the user has to enter values. to make it easy for the user there are some values already present in the feilds but if the user wants he can change it. the problem is i want to...
9
by: arundelo | last post by:
Is there a way to tell whether accessing a variable will result in an "Undefined variable" E_NOTICE? isset() almost does this, but it also returns false if a variable is set to null: ...
0
by: itsmenarwal | last post by:
HI everyone 1. As user enter username and password in sign-in-form.php then values are collected in sign-in-action-form.php page and the i am storing username into session variable like this In...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.