in reply to delete user from database
Your html form in which you select the user to delete is going to have a drop down:username|password|fname|lname|user_info
Then your Perl script is going to look like:<form action="myscript.pl"> <select name="user"> <OPTION VALUE="uname_1">user name 1 <OPTION VALUE="uname_2">user name 2 </select> </form>
This is very basic. You should add code for file locking, for example. And this could could be more elegant with the use of "unless" instead of the if-else.# use the CGI module, this automates processing of form input and take +s care of a lot of security issues too use CGI; my $query = new CGI; $user_to_delete = $query->param('user'); #load the user file into an array open(FILE, '<user_data_file.txt'); @user_data = <FILE>; close(FILE); #to find the row with your user, cycle through the rows, parsing each +one and looking for the user name, and write all lines back to the us +er database except the one for the user in question open(FILE, '>user_data_file.txt'); for $i (0 .. $#user_data) { @this_user_info = split(/\|/, $user_data[$i]); if ($this_user_info[0] eq $user_to_delete) { #do nothing } else { print FILE "$user_data[$i]\n"; } } close(FILE);
|
|---|