Jump to content


A few how two questions


1 reply to this topic

#1 Steve Marcano

    Young Padawan

  • Members
  • Pip
  • 31 posts
  • Gender:Male
  • Location:Tucson, Arizona

Posted 05 February 2009 - 01:56 PM

What I want to do with this edithandler function is for

1. When it calls for the password out of the database decode it and put the decoded version in the text box that way a new one can possibly be made unless no change is made to the password then it obviously keeps it the way it is when the form is submitted.
2. I have the two drop down lists what I'd like for it to do is match what's in the database with the option in the drop down list and have that one preselected.
3. I'd like to ask why is it that the values have double quotes around each string in the characters field. They should just be listed is all and like they are now separated by a comma.
4. I need to figure out how to put and if statment on this function just in case the admin checks the checkbox called deletehandler.
5. And for the bottom with the Add button I want the values in the UL to just add those values to the DB to the characters list and not replace the old values.

function edithandler() 
{ 
	$username = $_GET['username']; 
	$query = "SELECT * FROM `users` WHERE `username` = '" . $username . "'";
	 $result = mysql_query ( $query ); // Run The Query 
	 $row = mysql_fetch_array ( $result, MYSQL_ASSOC );
	print '<h1 class="backstage">Handler Management</h1><br />';
	print '<h2 class="backstage">Edit Handler Details</h2><br />';
	print '<form name="edithandler" method="post" action="backstage.php" id="edithandler">';
	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=\"". getFormData($username, "users","username") ."\"></td>";
	print '</tr>';
	print '<tr>';
	print "<td class=\"rowheading\">Password:</td><td class=\"row3\"><input type=\"password\" name=\"password\" class=\"fieldtext490\" value=\"". getFormData($username, "users","password") ."\"></td>";
	print '</tr>';
	print '<tr>';
	print '<td class="rowheading">Surname:</td><td class="row3">';
	print "<input type=\"text\" name=\"surname\" class=\"fieldtext490\" value=\"". getFormData($username, "users","surname") ."\"></td>";
	print '</tr>';
	print '<tr>';
	print '<td class="rowheading">Firstname:</td>';
	print "<td class=\"row3\"><input type=\"text\" name=\"firstname\" class=\"fieldtext490\" value=\"". getFormData($username, "users","username") ."\"></td>";
	print '</tr>';
	print '<tr>';
	print '<td class="rowheading">Email:</td>';
	print "<td class=\"row3\"><input type=\"text\" name=\"email\" class=\"fieldtext490\" value=\"". getFormData($username, "users","email") ."\"></td>";
	print '</tr>';
	print '<tr>';
	print '<td class="rowheading">AIM:</td>';
	print "<td class=\"row3\"><input type=\"text\" name=\"aim\" class=\"fieldtext490\" value=\"". getFormData($username, "users","aim") ."\"></td>";
	print '</tr>';
	print '<tr>';
	print '<td class="rowheading">MSN:</td>';
	print "<td class=\"row3\"><input type=\"text\" name=\"msn\" class=\"fieldtext490\" value=\"". getFormData($username, "users","msn") ."\"></td>";
	print '</tr>';
	print '<tr>';
	print '<td class="rowheading">Forum ID:</td>';
	print "<td class=\"row3\"><input type=\"text\" name=\"forumid\" class=\"fieldtext490\" value=\"". getFormData($username, "users","forumid") ."\"></td>";
	print '</tr>';
	print '<tr>';
	print '<td class="rowheading">Account:</td>';
	print '<td class="row3"><select name="enabled" class="selection">';
	print '<option value="0">- Select -</option><option value="1">Enabled</option><option value=0>Disabled</option>';
	print '</select></td>';
	print '</tr>';
	print '<tr>';
	print '<td class="rowheading">Administrator:</td>';
	print '<td class="row3"><select name="admin" class="selection"><option value="0">- Select -</option>';
	print '<option value="2">No</option><option value="1">Yes</option>';
	print '</select></td>';
	print '</tr>';
	print '<tr>';
	print '<td class="rowheading">Default Character:</td>';
	print "<td class=\"row3\">\"". getFormData($username, "users","characters") ."\"</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="Edit Handler" class="button" name="edithandler"><br /><br />';
	print '<input type="button" value="Return to Handler List" class="button200"><br /><br />';
	print '<script type="text/javascript" src="ajax.js"></script>';
	print '<h2 class="backstage">Characters<br /><br /><select name="characterid" class="dropdown" id="character_selection">';
	print '<option value="0">- 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 type="hidden" id="chars" name="chars" value=""><input type="button" value="Add" onclick="WrestlerList()" class="button"></h2><br />';
	print '<ul id="characterlist"></ul><br />'; 
	print '<h2 class="backstage"><input type="button" value="Return to Main Menu" class=button200></form></h2>';
}


//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 ();
	
	}


#2 023-jimmy

    Young Padawan

  • Members
  • Pip
  • 44 posts

Posted 05 February 2009 - 05:01 PM

1. Not possible. You can't decode MD5.
2. I helped you with this already. I gave you the code and you said that it worked?
3. Not understanding this question.

4. Do it like this:
if(isset($_POST['deletehandler'])){
	 /* Delete code */
} else {
	 /* Updating code */
}

5. Not possible to get the data from the <ul>, BUT you can use a hidden input form and put the values inside that:
<input type="hidden" name="" value="">






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users