473,698 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ISSET() question

The following code processes a blank field as though it has some value
and proceeds as though it was set to some value.

Apparently isset() is not working, because it thinks that a blank text
field is set to something.

Please let me know how to use isset() correctly.

Thanks ahead.

<?php
if(!isset($_POS T['varA'])||!isset($_POS T['varB'])){
?>
<form action="isset.p hp" method="POST">
<table><tr>
<td>Value 1:</td><td><input type="text" name="varA" value=""></td></
tr>
<tr><td>Value 2:</td><td><input type="text" name="varB" value=""></
td></tr>
<tr><td colspan="2"><in put type="submit" value="submit"> </td></tr>
</table>
</form>
<?php
}

else {
$x=$_POST['varA'];
$y=$_POST['varB'];

if($x>$y){
echo "Value 1:".$x." is larger";
}else

echo "Value 2:".$y." is larger";
}

?>
Feb 28 '08
10 2369
In article <13************ *@corp.supernew s.com>, no****@example. com
says...

Otherwise - just how "efficient" do you need a $_POST test to be?
Stop worrying - do it and move on. That what script languages like PHP
are for.

If regex is troubling you or you want to do more validation I'd take a
look at www.streamforensics.com to automate your forms validations.
Their system makes life a whole lot easier in so many ways.

You probably have more pressing problems than the one you are worrying
about?

Jeez, people - I was just asking. I don't know everything about PHP, and
was simply admitting there might be a better way than mine.

Is the moon full or something? People seem to be awfully touchy lately.
Tony - I wasn't having a go I was just trying to explain why I didn't
think it worth worrying about instead of just saying so.

Sorry if it read bad to you.

Mar 3 '08 #11

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

Similar topics

7
11875
by: Dan | last post by:
I was trying to troubleshoot a login page that doesn't work - it keeps saying the login/password is missing - when my tracing discovered this peculiar behavior. register_globals is off, so at the top of my script I assign a few variables to incoming GET and POST values. $login = clean($_POST, 30); $passwd = clean($_POST, 30);
4
1793
by: Brian Olivier | last post by:
Hello, What I try to do is create a string variabel with some intelligence. I want this variabel to read the information sent by another page and interpret the result. The idea is that is a variabel is set, a line break is printed. First question is if this is possible? Second if so, what should be the
25
2488
by: wd | last post by:
I want my server to send a 404 header if a URL with a query string is requested. So if a browser or spider requests something like www. my_site .com?p=chair they would get a 404... But if they request www. my_site .com/chair.htm everything would be normal.
9
9717
by: wouter | last post by:
hey hi..... I wanna make a switch wich does this: if pagid is set do A, if catid is set do B, if projectid is set do C, else do D. So i was thinking something like this:
3
4355
by: oggy | last post by:
Hello I try to answer this question for the Zend Certification PHP 5 : "What is the difference between isset() and other is_*() functions (is_alpha(), is_number(), etc.)?" Do you have a solution ? Thanks
2
37167
by: sathyashrayan | last post by:
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>
2
2577
by: yawnmoth | last post by:
<?php $var = 'test'; echo isset($var) ? 'true' : 'false'; echo '<br>'; echo isset($var) ? 'true' : 'false'; ?> Why does that result in this output?:
8
2456
by: Giovanni R. | last post by:
Take a look at this code (you can execute it): error_reporting(E_ALL); function byVal( $v) {} function byRef(&$v) {} print '<pre>'; byVal ($first); // gives a notice
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
8683
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
9170
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
9031
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
8904
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
8876
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7741
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...
0
5867
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();...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
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.