Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts

    Form Submit Passing Value From Dropdown To UL

    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.

    PHP Code:
    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>';

    Last edited by CoolAsCarlito; 12-31-2008 at 09:32 PM.

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Why are you doing md5 a billion times?

    Have you debugged and see why?

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    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.

    PHP Code:
    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 />'

  • #4
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    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
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #5
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    Well they can have multiple characters. Just obviously do a check in the UL to make sure that there aren't any matches.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •