Editing Members Login Info

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
CoolAsCarlito
Forum Contributor
Posts: 192
Joined: Sat May 31, 2008 3:27 pm
Contact:

Editing Members Login Info

Post by CoolAsCarlito »

This script is a script that when an admin chooses a member username from the dropdown menu the username is put into the text box so that it can be entered. My question I want to know is how do I have it put the correct type of what's in the database and put in the passwords that are in database as well for editing.

Code: Select all

 
<html>
<head>
<script type="text/javascript">
function showusername(str)
{
  document.forms['change'].username.value = str;
}
 
</script>
</head>
<body>
 
<?php
// Connects to your Database
$link = mysql_connect("?", "?", "?") or die(mysql_error());
mysql_select_db("?",$link) or die(mysql_error());
 
if (!mysql_select_db("?", $link))
{
  echo 'Could not select database';
  exit;
}
?>
 
 
<center><table><tr><td>Member Username:</td><td>
 
 
<?php
echo "<select onchange=\"showusername(this.value)\">";
$data = mysql_query("SELECT username FROM members");
while($row = mysql_fetch_assoc($data))
  echo '<option value="'.$row['username'].'">'.$row['username'].'</option>';
 
echo '</select>';
mysql_close();
?>
 
</td></tr></table></center>
 
<center> 
<table border=1 cellpadding=5 cellspacing=0 width=350>
 
<center><h2><span style="color: #CC0000">Edit a User</span></h2></center>
<form name="change" action="editmember.php" method="post">
<tr><td>User Name:</td><td>
<input type="text" name="username" maxlength="60" value="" />
</td></tr>
<tr><td>Type:</td><td>
<select name="type">
<option>Singles</option><option>Tag Team</option><option>Stable</option><option>Manager/Valet</option><option>Staff</option><option>Referee</option></select>
</td></tr>
<tr><td>Password:</td><td>
<input type="password" name="pass" maxlength="10">
</td></tr>
<tr><td>Confirm Password:</td><td>
<input type="password" name="pass2" maxlength="10">
</td></tr>
<tr><th colspan=2><input type="submit" name="editmember" value="Edit Member"></th></tr> </table>
</form>
</td>
</tr>
</table>
</center> 
 
</body>
</html>
 
Gevie
Forum Newbie
Posts: 5
Joined: Sun Aug 31, 2008 2:43 pm

Re: Editing Members Login Info

Post by Gevie »

I would do it this way

In your table have a field called

`member_type` then use a tinyint(1) as the field type.
1 = Singles
2 = Tag Team (and so on)

I'd setup your select in a loop if possible (List each possible type in a table of its own)
Then use an AJAX script to present the form.

So when a username is selected, the ajax form appears in a div.
Each time the drop down is edited, it sends a request to the ajax script and that then
returns a new version of the form.

In the AJAX form I would do something like this

Code: Select all

 
 
if(isset($_GET['userid'])) {
// Escape the $_GET always, but this is just a brief example
$get_types = mysql_query("select member_type from members where userid = '{$_GET['userid']}'");
$type = mysql_fetch_array($get_types);
 
echo "<select>";
 
$select_types = mysql_query("select id, distinct(type) as game_type from types order by type asc");
while($row = mysql_fetch_array($select_types)) {
$selected = ($type['member_type'] == $row['id']) ? "selected='selected'" : NULL;
echo "<option value='{$row['id']}' {$selected}>{$row['game_type']}</option>";
}
 
echo "</select>";
}
 
 
 
That's just brief code to outline the basic concept.
You'd probably need to present your whole form through the ajax script.
CoolAsCarlito
Forum Contributor
Posts: 192
Joined: Sat May 31, 2008 3:27 pm
Contact:

Re: Editing Members Login Info

Post by CoolAsCarlito »

Here's the structure of my database. Well all the information comes from the table called members. The first field is called "id" which is int11 and is auto incremented then there is the other following fields which are all text fields: type, username, password.

Can I still do what you are saying I should do with this database table format.
Post Reply