Not Inserting into DB


Posted on 16th Feb 2014 07:03 pm by admin

I can't get my Add new Division form to submit to the database. Anyone see my issue?

Code: <?php
$e = <<<here
<script src="./jscripts/scriptaculous/prototype.js" type="text/javascript"></script>
<script src="./jscripts/scriptaculous/scriptaculous.js" type="text/javascript"></script>
<script type="text/javascript" src="./jscripts/ajax.js"></script>
here;
switch ($_REQUEST['option']) {
case 0:
echo $e;
?>
<h1 class="backstage">Division Management</h1><br />
<h2 class=backstage>Divisions :: <a href="#" onclick="ajaxpage('backstage_libs/division.php?option=1', 'content'); return false;">Add New</a></h2><br />
<table width="100%" class="table1">
<tr class="rowheading">
<td>&nbsp;</td>
<td>Name</td>
</tr>
<?php
$query = "SELECT * FROM efed_list_divisions";
$result = mysql_query ( $query );
$rows = mysql_num_rows($result);

if ($result) {
$i = 0;
while ( $row = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) {
$sClass = 'row2';
if ($i++ % 2) $sClass = 'row1';
printf ( "<tr class="%s">", $sClass );
print "<td valign="top" align=center width=35><a href="#" onclick="ajaxpage('backstage_libs/division.php?option=2', 'content'); return false;">Edit</a></td>";
printf ( "<td valign="top">%s</td>", $row [name] );
echo '</tr>';
}
echo '</table>';
} else {
echo '<span>There are no divisions.</span><br />';
}
returnmain();
break;
case 1:
echo $e;
require_once('../backstagefunctions.php');
?>
<h1 class="backstage">Division Management</h1><br />
<h2 class="backstage">Add New Division</h2><br />
<form name="divisions" method="post">
<input type="hidden" name="action" value="division" />
<table width="100%" class="table2">
<tr>
<td width="120" class="rowheading" valign="center">Division Name:</td><td class="row3"><input type="text" name="name" class="fieldtext490"></td>
</tr>
</table><br />
<input type="hidden" name="newadded" value="true">
<input type="submit" value="Save Division" class="button"></form><br />
<form method="post"><input type="submit" value="Return to Division List" class="button200" name="return">
</form><br />
<?php
returnmain();
break;
case 2:
echo $e;
require_once('../backstagefunctions.php');
?>
<h1 class="backstage">Division Management</h1><br />
<h2 class="backstage">Edit Division</h2><br />
<form name="editdivision" method="post">
<table width="100%" class="table2">
<tr>
<td width="120" class="rowheading" valign="center">Division:</td><td class="row3"><input type="text" name="division" class="fieldtext490" value=""></td>
</tr>
</table><br />
<center>
<input type="checkbox" name="deletedivision"><span class="table1heading">Delete Division?</span><br /><br />
<input type="submit" value="Edit Division" class=button name="editdivision"><br /><br />
<input type="button" value="Return to Divisions List" class="button200"><br /><br />
</form>
<?php
returnmain();
break;
}
function division() {
if ((!empty($_POST['newadded'])) && (!empty($_POST['divisions']))) {
$name = mysql_real_escape_string($_POST['name']);
$query = "INSERT INTO `efed_list_divisions` (name) VALUES ('".$name."')";
if (mysql_query($query)) {
//success
} else {
//fail
}
}
}
?>

No comments posted yet

Your Answer:

Login to answer
156 Like 24 Dislike
Previous forums Next forums
Other forums

DateObject and Nulls
Hi all,

I have an array mapped to a value object. One of the items in the array is a PHP Date

Uploading Filetypes and placing them in seperate folders.
Hello,

first post , and asking for help im afraid. Very new to PHP, was making good progress

Typedef struct vs just struct
Anyone know the rationale for using typedef for structs when a struct is itself a typedef? I have s

Find occurences of unicode characters in string
I need to prohibit filenames with everything but English characters and numbers but regexp and strin

Curl & sessions PLS HELP
Hello,

I have a problem with curl and sessions and i will try to explain the best i could.

shift numbers with paging
Hi

How would i be able to display 10 numbers 1 2 3 4 5 6 7 8 9 10
and when I click next

help with image upload code
Hello,

right now this code I have resizes images and then places them into the uploads folder

WELCOME SCREEN
first of all let me tell you what does my script do,

it´s a very simple query to show a e

Include ("Absolute Path") of a file?
I'm not sure what I'm doing wrong. I am writing my php code in the same directory of the file that

JSON SORT WITH PHP
I have two products that I want to sort by say "Id:17, value: xxx" using php
The page w

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash