Thread: Form Validation
View Single Post
Old Feb 27th, 2006, 1:06 PM   #4
TecBrain
Hobbyist Programmer
 
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 5 TecBrain is on a distinguished road
This is what I have done, I did create a function to validate my countryName, not sure where i have done my mistake though...

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) 
{
	$countryname= $_POST['countryname'];
	$currency = $_POST['currency'];
	$image = $fileName = $_FILES['uploaded']['name'];
	
	function isLetters($countryname) 
	{
	  	if (preg_match('|^[a-z]+$|i', $countryname))
	    	
	    	return true;
	  	else
	   		return false;
	}
	
		if ((isLetters($countryname)) && (is_float($currency)))
		{
		$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');
		}
		else
		{
			echo "error";
			exit();
		}
}
__________________
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