Code2Design.com

User login

The Layout

Programming

Graphic Design

Resources

Navigation

C2D Projects

Unsystematic Affiliates

Fresh Tuts Project 62 Proof That God Exists Tutorials Expert 

Change Language

Who's online

There are currently 0 users and 7 guests online.

Using Regex and other things

You could try your hand at using regex to solve your problem or you can take a look over at http://php.net for all the variable functions like is_numeric().

I also recommend you test the input like this:

<?php
$longitude 
trim(htmlentities(strip_tags($_POST["Longitude"], ENT_QUOTES'UTF-8')));

//Make sure it isn't some long string of XSS or just a huge number...
if (strlen($longitude) > 15) {
    print 
'Your Longitude is too long...';
} else {

    if(!
is_numeric($longitude)) {
        print 
'This is not a valid number.';
    } else {
        print 
'You entered the right number';
    }

}
?>

Of course this is just the simplest mock-up I could do without any effort or knowledge of how you process your code.

Also look at this


Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br> <br /> <h3>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use BBCode tags in the text, URLs will be automatically converted to links
More information about formatting options



Like what you see?

Why not add more? C2D is looking for other Christian Web Masters who would like to help write articles for this site. If you have expericance in FLASH, CSS/HTML, PHP/MySQL, PhotoShop/GIMP, Blender, Javascript, or just General Design - our users would love to hear what you have to say. Contact Us

delicious   digg   reddit   magnoliacom   newsvine   furl   google   yahoo   technorati