473,699 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ph p' method=post>
<input type="button" name='button' value='button'>
</form>

</body>
</html>

<?php

if(isset($_REQU EST['button']))
{
echo "clicked";
}

?>

If I change the <input type='submit'th en it works, like get
submitted and perform the action. But why not with button?

Mar 23 '07 #1
2 37167
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.ph p' method=post>
<input type="button" name='button' value='button'>
</form>

</body>
</html>

<?php

if(isset($_REQU EST['button']))
{
echo "clicked";
}

?>

If I change the <input type='submit'th en 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="familynam e">
and that is posted to PHP (actiontag in the form), then PHP can retrieve
that value via:
$passedFamilyNa me = $_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_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
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.ph p' method=post>
<input type="button" name='button' value='button'>
</form>
</body>
</html>
<?php
if(isset($_REQU EST['button']))
{
echo "clicked";
}
?>
If I change the <input type='submit'th en 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="familynam e">
and that is posted to PHP (actiontag in the form), then PHP can retrieve
that value via:
$passedFamilyNa me = $_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
11493
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 type="image" src="modify.gif" border="0" alt="modify" title="modify" name="btn_modify" value="modify"> In mozilla everything works great, but in Konqueror and MSIE the if statement I'm using to detect which button was press does not work.
7
2231
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 $round2heats $round3heats etc...
8
1760
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 do. The code is the following: <?php require('config.php'); $conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS) or die ('Could not connect to MySQL database.' .mysql_error()); mysql_select_db (SQL_DB, $conn);
9
2661
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 prompt user again.
5
5899
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 button to open the "file browse" dialog and the Submit button to submit the form data.
13
1797
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 execute some PHP code, but I don't want the navigator to show another web. So imagine the file is product_list.php and the link is: <a href="add_product.php?code=...> Buy </a>. I want the code in add_product.php to be executed but I want the...
3
1680
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 have a button which upon clicking should enter the value "null" to the feild. one of the text feild code i m displaying here <input name="departFrom" type="text" id="departFrom" <?php if ($_POST=='Void') { echo "NULL"; exit(); }...
9
4488
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: $SetNonNull = 0; $SetNull = null; var_dump(isset($SetNonNull)); // bool(true) $Junk = $SetNonNull; // No error, as predicted by isset(). var_dump(isset($NotSet)); // bool(false)
0
1683
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 database i have a table named employee <a href="logout_file.php">Sign Out</a> if (username and passwords are matched) { session_start(); $_SESSION = $row; $_SESSION =$row;
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9172
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8908
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7745
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.