Jump to content

Using Get To Update Handler Information


Xtremer360

Recommended Posts

What I have is a list of handlers (users) in a html table with the word edit by their name and when clicked on it takes them to the following function where their user info can be edited and updated to the DB table.

 

What I would like help doing is making this function into where it'll call the info from the DB for the selected user and updated to the DB table. I have also included a pae called TheAjaxHandler.php which have been used to post the values for making a user to the DB and know I'll probably have to do something in that file to repost it.

 

 

backstagefunctions.php

function edithandler() {
print '<h1 class=backstage>Handler Management</h1><br />';
print '<h2 class=backstage>Edit Handler Details</h2><br />';
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 value=""></td>';
print '</tr>';
print '<tr>';
print '<td class=rowheading>Password:</td><td class=row3><input type=password name=password class=fieldtext490 onfocus="this.select()" value=""></td>';
print '</tr>';
print '<tr>';
print '<td class=rowheading>Surname:</td><td class=row3>';
print '<input type=text name=surname class=fieldtext490 value=""></td>';
print '</tr>';
print '<tr>';
print '<td class=rowheading>Firstname:</td>';
print '<td class=row3><input type=text name=firstname class=fieldtext490 value=""></td>';
print '</tr>';
print '<tr>';
print '<td class=rowheading>Email:</td>';
print '<td class=row3><input type=text name=email class=fieldtext490 value=""></td>';
print '</tr>';
print '<tr>';
print '<td class=rowheading>AIM:</td>';
print '<td class=row3><input type=text name=aim class=fieldtext490 value=""></td>';
print '</tr>';
print '<tr>';
print '<td class=rowheading>MSN:</td>';
print '<td class=row3><input type=text name=msn class=fieldtext490 value=""></td>';
print '</tr>';
print '<tr>';
print '<td class=rowheading>Forum ID:</td>';
print '<td class=row3><input type=text name=forumid class=fieldtext490 value=""></td>';
print '</tr>';
print '<tr>';
print '<td class=rowheading>Account:</td>';
print '<td class=row3><select name=enabled class=selection>';
print '<option value=1>Enabled<option value=0>Disabled</option>';
print '</select></td>';
print '</tr>';
print '<tr>';
print '<td class=rowheading>Administrator:</td>';
print '<td class=row3><select name=isadministrator class=selection>';
print '<option value=1>Yes<option value=0>No';
print '</select></td>';
print '</tr>';
print '<tr>';
print '<td class=rowheading>Default Character:</td>';
print '<td class=row3></td>';
print '</tr>';
print '</table><br />';
print '<input type=checkbox name=deletehandler> <span class=table1heading>Delete Handler?</span><br /><br />';
print '<input type=submit value="Save Handler" class=button></form><br />';
print '<form method=POST><input type=hidden name=action value=handler><input type=submit value="Return to Handler List" class=button200></form><br />';
print '<h2 class=backstage>Characters<br /><br /><form method=post><input type=hidden name=action value=handler><input type=hidden name=routine value=addcharacter><input type=hidden name=option value=0><input type=hidden name=id value="130"><select name=characterid class=dropdown>';
print '<option value=0>- Select -</select>  <input type=submit value="Add" class=button></form></h2><br />';
print '<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>';
}

 

TheAjaxHandler.php

<?php
if(isset($_POST))
{
    //Form was submitted - determine the form
    if ( isset ( $_POST['addhandler'] ) ) {
        // Define the query.
        $password = md5($p); // Currently $p does not have a value
        $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 ('".addslashes($login)."', '".addslashes($p)."', '".addslashes($surname)."','".addslashes($firstname)."', '".addslashes($email)."', '".addslashes($aim)."', '".addslashes($msn)."', '".addslashes($forumid)."', '".addslashes($account)."', '".addslashes($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 ();
    
    }
    
    if ( isset ( $_POST['addcharacter'] ) ) {
        // Define the query.
	$charactername = $_POST ['charactername'];
	$username = $_POST ['username'];
	$posername = $_POST ['posername'];
	$style = $_POST ['style'];
	$gender = $_POST ['gender'];
	$status = $_POST ['status'];
	$division = $_POST ['division'];
	$alignment = $_POST ['alignment'];
	$sort = $_POST ['sort'];
	$query = "INSERT INTO `characters` (`charactername`, `username`, `posername`, `style`, `gender`, `status`, `division`, `alignment`, `sort`) VALUES ('".addslashes($charactername)."', '".addslashes($username)."', '".addslashes($posername)."','".addslashes($style)."', '".addslashes($gender)."', '".addslashes($status)."', '".addslashes($division)."', '".addslashes($alignment)."', '".addslashes($sort)."')";

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

	//mysql_close ();

    }

//Form was submitted - determine the form
    if ( isset ( $_POST['addmatchtype'] ) ) {
        // Define the query.
        $typename = $_POST['typename'];
        
        $query = "INSERT INTO `matchtypes` (`matchtype`) VALUES ('".addslashes($typename)."')";
        
        // Execute the query.
        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>';
        }
        
        //mysql_close ();
    
    }
    //Form was submitted - determine the form
    if ( isset ( $_POST['adddivision'] ) ) {
        // Define the query.
        $divisionname = $_POST['divisionname'];
        
        $query = "INSERT INTO `divisions` (`name`) VALUES ('".addslashes($divisionname)."')";
        
        // Execute the query.
        if (@mysql_query ( $query )) {
            print '<p>The division has been added.</p>';
        } else {
            print '<p>Could not add the entry because: <b>"' . mysql_error() . '"</b>. The query was '.$query.'.</p>';
        }
        
        //mysql_close ();
    
    }
    //Form was submitted - determine the form
    if ( isset ( $_POST['addeventnameweekly'] ) ) {
        // Define the query.
        $eventname = $_POST['eventname'];
        $shortname = $_POST['shortname'];
        
        $query = "INSERT INTO `events` (`type`,`eventname`,`shortname`) VALUES ('Weekly Event','".addslashes($eventname)."','".addslashes($shortname)."')";
        
        // Execute the query.
        if (@mysql_query ( $query )) {
            print '<p>The event name has been added.</p>';
        } else {
            print '<p>Could not add the entry because: <b>"' . mysql_error() . '"</b>. The query was '.$query.'.</p>';
        }
        
        //mysql_close ();
    
    }
    //Form was submitted - determine the form
    if ( isset ( $_POST['addeventnameppv'] ) ) {
        // Define the query.
        $eventname = $_POST['eventname'];
        $shortname = $_POST['shortname'];
        
        $query = "INSERT INTO `events` (`type`,`eventname`,`shortname`,) VALUES ('Pay Per View','".addslashes($eventname)."','".addslashes($shortname)."')";
        
        // Execute the query.
        if (@mysql_query ( $query )) {
            print '<p>The event name has been added.</p>';
        } else {
            print '<p>Could not add the entry because: <b>"' . mysql_error() . '"</b>. The query was '.$query.'.</p>';
        }
        
        //mysql_close ();
    
    }
    
}    
?> 

Link to comment
Share on other sites

I c&p the addhandler post submit in TheAjaxHandler.php file  and changed just the submit part to edithandler like this:

 

//Form was submitted - determine the form
    if ( isset ( $_POST['edithandler'] ) ) {
        // Define the query.
        $password = md5($p); // Currently $p does not have a value
        $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 = "UPDATE INTO `users` (`username`, `password`, `surname`, `firstname`, `email`, `aim`, `msn`, `forumid`, `status`, `admin`) VALUES ('".addslashes($login)."', '".addslashes($p)."', '".addslashes($surname)."','".addslashes($firstname)."', '".addslashes($email)."', '".addslashes($aim)."', '".addslashes($msn)."', '".addslashes($forumid)."', '".addslashes($account)."', '".addslashes($admin)."')";
        
        // Execute the query.
        if (@mysql_query ( $query )) {
            print '<p>The handler has been edited.</p>';
        } else {
            print '<p>Could not add the entry because: <b>"' . mysql_error() . '"</b>. The query was '.$query.'.</p>';
        }
        
        //mysql_close ();
    
    }

 

Hopefully that's right, however, I still don't know what I need to do to do the call for the data in the actual form.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.