Noob can't get eregi to work
Posted: Sun Aug 24, 2008 5:17 pm
Why does the !eregi not work?
Code: Select all
<?php
$conn = mysql_connect($dbhost, $dbuser, $dbpass)
or die('Error connecting to MySQL.');
mysql_select_db($dbname)
or die('Error selecting database.');
if (isset($_POST["submit"]))
{
$error = array();
$message = "";
$validName = "[a-z]*";
$validDescription = "[a-z\,\.\']*";
if (!is_numeric($_POST[MenuCategory]))
{
$error[] = 'Whoa nelly';
}
if (!eregi($validName, $_POST[name]))
{
$error[] = 'Name field is not text only';
}
if (!eregi($validDescription, $_POST[description]))
{
$error[] = 'Description field has unathorized characters';
}
if (!is_numeric($_POST[price]))
{
$error[] = 'Price field is not numeric';
}
if (count($error) > 0)
{
foreach ($error as $fail)
{
echo $fail .'<br>'. "\n";
}
}
if (count($error) == 0)
{
$sql="INSERT INTO universitymenu (MenuCategoryID, ItemName, ItemCost, ItemDescription)
VALUES
('$_POST[MenuCategory]','$_POST[name]','$_POST[price]','$_POST[description]')";
if (!mysql_query($sql,$conn))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($conn);
}
}
?>