Home arrow PHP arrow Page 4 - Creating a Mailing List Manager with PHP

Editing the names - PHP

This tutorial will guide you through building a complete mail list administration solution in PHP, capable of handling multiple lists.

TABLE OF CONTENTS:
  1. Creating a Mailing List Manager with PHP
  2. Creating the front page
  3. Adding names to the list
  4. Editing the names
  5. Autoresponders
  6. Conclusion
By: Duncan Lamb
Rating: starstarstarstarstar / 52
December 16, 1999

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

To edit the names, we’ll use a crude but effective method: direct editing! Incorporating the editing into a form will make it less daunting, however. Observe the following code:

First, the user should pick the list to edit:

picklist.php3

<html><head><title>Pick the list</title></head><body> <center> <br><br> Please pick the list you would like to edit: <br> <form method=post action="editnames.php3"> <select name="List" size=4> <? $fileloc = "lists.txt"; $groups = file("data/lists.txt"); for ($index=0; $index < count($groups); $index++) { $grouplist = split("\|", chop($groups[$index])); ?> <option value="<? echo $grouplist[1] ?>" <? if ($index==0) {echo "selected";} ?>> <? echo $grouplist[0] ?><br> <? } ?> </select> <br><br> <input type="submit" value="Edit list"></form></center> </body></html>
Then, a form is created to allow editing and deleting of the names:

editnames.php3

<html><head><title>Edit Maillist addresses</title></head><body> <form method=post action="writenamefile.php3"> <br> Editing <? echo $List ?>. <br><br> Fix an address by editing in place, or delete an address by deleting the WHOLE line. <b>No blank lines or spaces allowed! </b> <br><br><textarea cols=50 rows=20 name="Body"> <? if (file_exists("data/$List")) {readfile("data/$List");} ?> </textarea> <br><br> <input type="hidden" name="List" value="<? echo $List ?>"> <input type="submit" name="submit" value="Save This List"></FORM> <br><br><a href="addnames.php3">Add names to the list</a>. <br><br><a href="data/log.txt">View Send Log</a>. <br> </body></html>
The readfile function (line 8) reads in a file and directly sends in to the browser. This places all the addresses for the specified list into a textbox, where they can be deleted or fixed directly. Also, note the warnings about one address to a line, something to remind the administrator about what’s right and wrong. The next script saves all the changes:

writenamefile.php3

<html><head><title>Updating file....</title></head><body> <br><br> Changes saved to <? echo $List ?>.<br> <? $myfile = fopen("data/$List","w"); fputs($myfile,$Body); fclose($myfile); ?> <br> <a href="index.php3">Home.</a> </body></html>
This was just as easy as reading the file in! Since the whole list was in the textbox, it is all included in the variable $Body, newlines and all. Writing $Body to the file saves the entire thing exactly as it looked in the previous form.

 
 
>>> More PHP Articles          >>> More By Duncan Lamb
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: