Welcome to WebmasterWorld Guest from 54.85.162.213

Forum Moderators: open

Message Too Old, No Replies

Form not submitting

     
12:29 am on Dec 7, 2009 (gmt 0)

New User

5+ Year Member

joined:Dec 3, 2009
posts: 16
votes: 0


Issue I'm having is located at option 1 where the Add New Match Type form is shown. Upon filling out the form and attempting to insert the form results into the database but it doesn't, however the form is loaded via ajax and I don't know what I have to do to get it to insert into the database still.


<?php
{
print "<script src=\"/jscripts/scriptaculous/prototype.js\" type=\"text/javascript\"></script>\n";
print "<script src=\"/jscripts/scriptaculous/scriptaculous.js\" type=\"text/javascript\"></script>\n";
print "<script type=\"text/javascript\" src=\"./jscripts/ajax.js\"></script>\n";
}
?>

<?php

$option = $_GET['option'];

if ($option == 0 )

{
print '<h1 class="backstage">Match Type Management</h1><br />';
print "<h2 class=backstage>Match Types :: <a href=\"#\" onclick=\"ajaxpage('backstage_libs/matchtypes.php?option=1', 'content'); return false;\">Add New</a></h2><br />";
print '<table width="100%" class="table1">';
print '<tr class="rowheading">';
print '<td>&nbsp;</td>';
print '<td>Name</td>';
print '</tr>';
$query = "SELECT * FROM efed_list_matchtypes";
$result = mysql_query ( $query );
if ($result)
{
$i = 0;
while ( $row = mysql_fetch_array ( $result, MYSQL_ASSOC ) )
{
$sClass = 'row2';
if ($i ++ & 1)
{
$sClass = 'row1';
}
printf ( "<tr class=\"%s\">", $sClass );
print "<td valign=\"top\" align=center width=35><a href=\"#\" onclick=\"ajaxpage('backstage_libs/matchtypes.php?option=2', 'content'); return false;\">Edit</a></td>";
printf ( "<td valign=\"top\">%s</td>", $row [matchtype] );
print '</tr>';
}
print '</table>';
}else
{
print '<span>There are no match types.</span><br />';
}
print '<br />';
returnmain();

} elseif ( $option == 1)
{
include('../backstageconfig.php');
include('../backstagefunctions.php');
print '<h1 class="backstage">Match Type Management</h1><br />';
print '<h2 class="backstage">Add New Match Type</h2><br />';
print '<form name="addmatchtype" method="post" action="backstage.php">';
print '<table width="100%" class="table2">';
print '<tr>';
print '<td width="120" class="rowheading" valign="center">Match Type:</td><td class="row3"><input type="text" name="matchtype" class="fieldtext490"></td>';
print '</tr>';
print '</table><br />';
print '<input type="submit" value="Save Match Type" class="button" name="submit"></form><br />';
print '<form method="POST"><input type="submit" value="Return to Match Type List" class="button200"></form><br />';
returnmain();

} elseif ( $option == 2)
{
include('../backstageconfig.php');
include('../backstagefunctions.php');
print '<h1 class="backstage">Match Type Management</h1><br />';
print '<h2 class="backstage">Edit Match Type</h2><br />';
print '<form name="editmatchtype" method="post" action="backstage.php">';
print '<table width="100%" class="table2">';
print '<tr>';
print "<td width=\"120\" class=\"rowheading\" valign=\"center\">Match Type:</td><td class=\"row3\"><input type=\"text\" name=\"matchtype\" class=\"fieldtext490\" value=\"".$row['matchtype']."\"></td>";
print '</tr>';
print '</table><br />';
print '<input type="checkbox" name="deletematchtype"><span class="table1heading">Delete Match Type?</span><br /><br />';
print '<input type="submit" value="Edit Match Type" class=button name="editmatchtype"><br /><br />';
print '<input type="button" value="Return to Match Type List" class="button200"><br /><br />';
returnmain();
}
?>

<?php

if (isset ($_POST['submit']))
{

$matchtype = $_POST['matchtype'];

$query = "INSERT INTO efed_list_matchtypes (matchtypes) VALUES ('$matchtype')";

if (@mysql_query ($query))
{
print '<p>The match type has been added.</p>';
} else

{
print '<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>';
}

}
?>

6:25 am on Dec 7, 2009 (gmt 0)

Full Member

10+ Year Member

joined:Apr 21, 2004
posts:306
votes: 0


1) Not sure about your context or how the ajaxpage(...) method works, but if this script is calling itself and ajaxpage takes a relative path, you probably want to remove the 'backstage_libs/' part because it would likely be looking in the backstage_libs/backstage_libs folder.

2) What output are you getting, assuming 1) was not the problem?

"The match type has been added."
or
"Could not add the entry because: ... The query was ..."?

If there is a SQL exception being thrown it appears that your code should display the error -- if so, what is that error message.

3) This probably won't fix your problem, but you should format your <input ...> tags like <input ... />

7:25 am on Dec 7, 2009 (gmt 0)

New User

5+ Year Member

joined:Dec 3, 2009
posts: 16
votes: 0


1. The ajaxpage uses ajax to call links into a certain div. And after click on Add New it loads the form into the same div. I can't remove backstage_libs folder because then it wouldn't call the form.

2. I'm not getting any error message all it does is loads the same backstage.php file that is in the form action tag.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members