From 1bad4fc00814e2c03ecadaa7faf93c6372f5bd30 Mon Sep 17 00:00:00 2001 From: Kyle Kaminski Date: Sun, 16 Jun 2013 03:25:26 -0500 Subject: initial commit --- insert.php | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 insert.php (limited to 'insert.php') diff --git a/insert.php b/insert.php new file mode 100644 index 0000000..f3c9652 --- /dev/null +++ b/insert.php @@ -0,0 +1,75 @@ + + + + + +Hacker's Corner + + + +

Fire fire fire!

+ 30); + if (empty($menu_name) || !validation($requirements, $_POST) || !isset($_POST['visible'])) /* visible is a boolean AFAIK */ + { + header("Location: forms.php"); + exit; + } + + /* string needs single quotes */ + $query = "insert into subjects ( + menu_name, position, visible + ) VALUES ( + '{$menu_name}', {$position}, {$visible} + )"; + + $result = mysql_query($query, $connection); + if ($result) + { + header("Location: fetch.php"); + exit; + } + else + { + echo "

Subject creation failed.

\n"; + echo "

" . mysql_error() . "

\n"; + } + + /* kinda went freestyle, check to make sure not overflow the sql */ + function validation($rules, $source) + { + foreach ($rules as $rule => $max_length) + { + if (strlen($source[$rule]) > $max_length) + { + echo "{$rule} is over {$max_length} characters long!
\n"; + return false; + } + } + + return true; + } + + mysql_close($connection); +?> + + + -- cgit v1.2.3