Jump to content

how do i check wheter a text box is empty or not ?


jd2007

Recommended Posts

The Best way is:

 

<?php
if (isset($_REQUEST["textbox"]))
{
echo "Thank You!";
}
else
{
echo "Textbox was not filled in.";
}
?>

 

How is that a best way? Generally, when you have a form that modifies anything you want to send it via post. According to Chris Shiflet:

 

http://shiflett.org/articles/ideology

I want to add a quick note about $_REQUEST before closing.

 

Don't use it.

 

$_REQUEST hides the source of data, much like register_globals. While it is slightly better in the sense that it is clearly input (whereas register_globals can make it difficult to distinguish between remote and local data), the difference between GET and POST data is significant. Consider the following excerpt from RFC 2616, the HTTP specification:

 

In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. These methods ought to be considered "safe". This allows user agents to represent other methods, such as POST, PUT and DELETE, in a special way, so that the user is made aware of the fact that a possibly unsafe action is being requested.

 

If you can't distinguish between GET and POST, you cannot adhere to the specification. While this may seem like a harmless violation, there are also security concerns - particularly cross-site request forgeries. This is an attack that I've written about in php|architect before but never specifically in Security Corner. It is a likely topic for a future edition.

 

 

edit: Sorry, way off topic and it's late :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.