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

License Issue - service type user
Hi,

I would like to understand the following issue regarding sap license.
I wish to

Schedule editor
Hi,

I have a question related to Schedule editor.
If we schedule a BLS for every 30

iterating through an array and escape each value independently.
I have a set up where the variable being escaped is an array and it needs to be iterated and escaped

2 decima places & How to reload my page
Hello There,

How do i put full-stop (.) after second figure from behind? ie if i have 123456

need a script for 3 pages
I have a customer who wants me to set up a site with a number of pages with the following requiremen

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

tag inside php...
hi


Code: <?php
echo "<td width="$columnWidth%" align=&

NOOB needs help with upload file
The intent of this form is to create a folder for a client and upload an image into another folder '

Preg_match unknown modifyer
Hello,

Im trying to write a little script for my forums i need to get the reply from my forum

Drawing Images in classes
I'm quite new to Object Oriented PHP. What I'm trying to do is draw some images but also have other

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