mattthac
Fri 12 September 2008, 02:08 am GMT +0200
here's what i'm trying to complete
An interface should be written that displays a list of all users that have
been imported. When displaying the list of users, the password field should
be represented with a blank input box, allowing the user's password to be
changed. Underneath the table there will be a "Save" button, which when
pressed will change all the passwords for those users who have a password
filled in and reload the page.
When someone has input several passwords, each password needs to be
validated in javascript prior to submit to ensure that it is of a minimum
length of 4 characters. If it is not, the Save button should not work and a
popup should explain what the problem is.
here's what i have so far....I'm pretty new to php and javascript so don't know what i'm missing...when i click save i can't get the javascript to pull the values from the password fields in the php while loop....just says that they're ok and save....which is another issue, i can't figure out how to update the entire row accordingly if needed.... any help is greatly appreciated
<html>
<head>
<title>Matt's Password Changing Page</title>
<script type="text/javascript">
function validate(f){
var passwords = f.password;
var theID = f.userID;
for (i=0;i<passwords.length;i++){
if (passwords[i].length < 4) {
alert("Password Length is Less than 4 characters!");
passwords[i].focus();
return false;
}
else if(passwords[i].value=='') {
}
else{
alert("Everything passed just save!");
}
}
return true;
}
</script>
</head>
<body>
<form name="UserUpdate" enctype="multipart/form-data" action="employeeupdate.php" method="POST" onsubmit="return validate(this);">
<h1>User Display Page</h1>
<br>
<table>
<tr bgcolor="gray">
<td align="center">User Name</td>
<td align="center">First Name</td>
<td align="center">Last Name</td>
<td align="center">New Password</td>
</tr>
<?php
while($row = mysql_fetch_array($result))
{
?>
<tr bgcolor="white">
<td align="center"><input type="text" name="username" value="<?php echo $row['user_name']; ?>"></td>
<td align="center"><input type="text" name="firstname" value="<?php echo $row['first_name']; ?>"></td>
<td align="center"><input type="text" name="lastname" value="<?php echo $row['last_name']; ?>"></td>
<td align="center"><input type="text" name="password">
<input type="hidden" name="userID" value="<?php echo $row['uid']; ?>"></td>
</tr>
<?php
}//end while
?>
<tr>
<td><input type="submit" name="Submit" value="Save">
<input type="hidden" name="numRecords" value="<?php echo $num_rows; ?>"</td>
</tr>
</table>
</form>
</body>
</html>
An interface should be written that displays a list of all users that have
been imported. When displaying the list of users, the password field should
be represented with a blank input box, allowing the user's password to be
changed. Underneath the table there will be a "Save" button, which when
pressed will change all the passwords for those users who have a password
filled in and reload the page.
When someone has input several passwords, each password needs to be
validated in javascript prior to submit to ensure that it is of a minimum
length of 4 characters. If it is not, the Save button should not work and a
popup should explain what the problem is.
here's what i have so far....I'm pretty new to php and javascript so don't know what i'm missing...when i click save i can't get the javascript to pull the values from the password fields in the php while loop....just says that they're ok and save....which is another issue, i can't figure out how to update the entire row accordingly if needed.... any help is greatly appreciated
<html>
<head>
<title>Matt's Password Changing Page</title>
<script type="text/javascript">
function validate(f){
var passwords = f.password;
var theID = f.userID;
for (i=0;i<passwords.length;i++){
if (passwords[i].length < 4) {
alert("Password Length is Less than 4 characters!");
passwords[i].focus();
return false;
}
else if(passwords[i].value=='') {
}
else{
alert("Everything passed just save!");
}
}
return true;
}
</script>
</head>
<body>
<form name="UserUpdate" enctype="multipart/form-data" action="employeeupdate.php" method="POST" onsubmit="return validate(this);">
<h1>User Display Page</h1>
<br>
<table>
<tr bgcolor="gray">
<td align="center">User Name</td>
<td align="center">First Name</td>
<td align="center">Last Name</td>
<td align="center">New Password</td>
</tr>
<?php
while($row = mysql_fetch_array($result))
{
?>
<tr bgcolor="white">
<td align="center"><input type="text" name="username" value="<?php echo $row['user_name']; ?>"></td>
<td align="center"><input type="text" name="firstname" value="<?php echo $row['first_name']; ?>"></td>
<td align="center"><input type="text" name="lastname" value="<?php echo $row['last_name']; ?>"></td>
<td align="center"><input type="text" name="password">
<input type="hidden" name="userID" value="<?php echo $row['uid']; ?>"></td>
</tr>
<?php
}//end while
?>
<tr>
<td><input type="submit" name="Submit" value="Save">
<input type="hidden" name="numRecords" value="<?php echo $num_rows; ?>"</td>
</tr>
</table>
</form>
</body>
</html>