...

View Full Version : Form Submit Passing Value From Dropdown To UL



CoolAsCarlito
12-31-2008, 08:22 PM
Nothing happens when I click submit to add character names to the UL. Also it needs to be able to check to make sure there are no matches in the UL meaning a selection can't be made more than once.



function newhandler() {
if (isset ($_POST['submit'])) { // Handle the form.

// Define the query.
$salt = "rweweroiu23i4u89wu89fu9sadhfiuhaw89eriuahdfuiwher";
$password = md5(md5(md5(encrypt(md5(md5($password.$salt))))));
$login = $_POST['login'];
$p = $_POST['password'];
$surname = $_POST['surname'];
$firstname = $_POST['firstname'];
$email = $_POST['email'];
$aim = $_POST['aim'];
$msn = $_POST['msn'];
$forumid = $_POST['forumid'];
$account = $_POST['account'];
$admin = $_POST['admin'];
$query = "INSERT INTO users (username, password, surname, firstname, email, aim, msn, forumid, status, admin) VALUES ('$login', '$p','$surname','$firstname', '$email', '$aim', '$msn', '$forumid', '$account', '$admin')";

// Execute the query.
if (@mysql_query ($query)) {
print '<p>The handler has been added.</p>';
} else {
print '<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>';
}

mysql_close();

}
print'<h1 class="backstage">Handler Management</h1><br />';
print'<h2 class="backstage">Add New Handler Account</h2><br />';
print'<form name="newhandler" action="backstage.php" method="post" >';
print'<table width="100%" class="table2">';
print'<tr>';
print'<td width="120" class="rowheading">Username:</td><td class="row3"><input type="text" name="login" class="fieldtext490"></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Password:</td><td class="row3"><input type="password" name="password" class="fieldtext490"></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Surname:</td><td class="row3">';
print'<input type="text" name="surname" class="fieldtext490"></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Firstname:</td>';
print'<td class="row3"><input type="text" name="firstname" class="fieldtext490"></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Email:</td>';
print'<td class="row3"><input type="text" name="email" class="fieldtext490"></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">AIM:</td>';
print'<td class="row3"><input type="text" name="aim" class="fieldtext490"></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">MSN:</td>';
print'<td class="row3"><input type="text" name="msn" class="fieldtext490"></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Forum ID:</td>';
print'<td class="row3"><input type="text" name="forumid" class="fieldtext490"></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Account:</td>';
print'<td class="row3"><select name="account" class="selection">';
print'<option value="1">Enabled</option><option value="2">Disabled</option>';
print'</select></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Administrator:</td>';
print'<td class="row3"><select name="admin" class="selection">';
print'<option value="2">No</option><option value="1">Yes</option>';
print'</select></td>';
print'</tr>';
print'</table><br />';
print'<input type="submit" value="Save Handler" class="button" name="submit"></form><br />';
print'<input type="hidden" name="action" value="handlers"><input type="submit" value="Return to Handler List" class="button200"><br />
<script type="text/javascript">
function WrestlerList(addWrestler)
{
if (addWrestler)
document.getElementById("characterlist").innerHTML += "<li>" + addWrestler + "</li>";
return WrestlerList;
}
</script>';
print'<h2 class="backstage">Characters<br /><br />';
print'<form method=post id="form1" name="addwrestler" onsubmit="return WrestlerList(this);"><select name="characterid" class="dropdown" onchange="WrestlerList(this.value)">';
print'<option value="">- Select -</option>';
$query = 'SELECT charactername FROM characters';
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
print "<option value=\"{$row['charactername']}\">{$row['charactername']}</option>\r";
}
print'</select>&nbsp;&nbsp;<input name="submit" type="submit" value="Add" class="button"></form></h2><br />';
print'<ul id="characterlist"></ul>';
print'This handler does not have any characters assigned.<br /><br />';
print'<h2 class="backstage"><form method="POST"><input type="hidden" name="action" value="mainmenu"><input type="submit" value="Return to Main Menu" class="button200"></form></h2>';
}

A1ien51
01-03-2009, 01:41 AM
Why are you doing md5 a billion times?

Have you debugged and see why?

Eric

CoolAsCarlito
01-03-2009, 05:24 AM
This is my code that works however I want it on default to say "This handler does not have any characters assigned." until a character name is submitted then the character is replaced with that string. I also want it to do a check to make sure that the same character name isn't placed in the ul twice.


print'<script type="text/javascript" src="ajax.js"></script>';
print'<h2 class="backstage">Characters<br /><br />';
print'<form method=post name="addwrestler" onsubmit="return WrestlerList(this);"><select name="characterid" class="dropdown">';
print'<option value="">- Select -</option>';
$query = 'SELECT charactername FROM characters';
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
print "<option value=\"{$row['charactername']}\">{$row['charactername']}</option>\r";
}
print'</select>&nbsp;&nbsp;<input name="submit" type="submit" value="Add" class="button"></form></h2><br />';
print'<ul id="characterlist"></ul>';
print'This handler does not have any characters assigned.<br /><br />';

A1ien51
01-03-2009, 01:29 PM
If you do not want the name to appear twice in the list, why are you letting them select it a second time? Remove it from the list after the user adds it to the ul.

Eric

CoolAsCarlito
01-03-2009, 09:43 PM
Well they can have multiple characters. Just obviously do a check in the UL to make sure that there aren't any matches.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum