Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Feb 27th, 2006, 9:45 AM   #1
TecBrain
Hobbyist Programmer
 
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 5 TecBrain is on a distinguished road
Form Validation

Am trying to check whether the input is text or not, so what i did is creating a function and return the value false or true, is this legal, if no then how can i go around this problem.

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) 
{
	$countryname= $_POST['countryname'];
	$currency = $_POST['currency'];
	$image = $fileName = $_FILES['uploaded']['name'];
	
	function isLetters($countryname) 
	{
  	return !preg_match ('/[^A-z]/', $countryname);
	}
	
	isLetters($countryname);
	
	if ((is_float($currency)) || (!$countryname))
	{
		echo "error";
		exit();
	}
	else if (empty($countryname) || empty($currency))
	{
		echo "error2";
		exit();
	}
	
	else
	{
	$query = "INSERT INTO countries (countryname, currency, imgpath) VALUES ('$countryname', '$currency', '$image')";
	mysql_select_db($database, $dbcnx);
	mysql_query($query) or die('Error, insert query failed');
	}
}
__________________
Personal Portfolio
TecBrain Support Forum
Linux VS Windows ... Dont Even Think of it ..
Distribution: Slackware
if (OS==Linux) return success
There are 10 kinds of people, those who can read binary numbers and those who can't.
TecBrain is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:14 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC