Jump to content

changing email in mailing list..


justinchrono

Recommended Posts

hello. at my page's footer, there is a form to sign up for a mailing list.

how do i change the email address that this is sending information to?

this is the coding for my footer:

 

</td>

</tr>

</table>

<table cellpadding="0" cellspacing="0" border="0" width="630">

<tr>

<td height="60">

 

<!-- BEGIN: Constant Contact Basic Opt-in Email List Form -->

<div align="center" style="padding-top: 10px;">

<table border="0" cellspacing="0" cellpadding="3">

<tr>

<td align="center">Join Our Mailing List</td>

 

<td align="center">

<form name="ccoptin" action="http://visitor.constantcontact.com/d.jsp" target="_blank" method="post" >

<input type="hidden" name="m" value="1101612644692">

<input type="hidden" name="p" value="oi">

<input type="text" name="ea" size="25" value="enter email address">

<input type="submit" name="go" value="GO" class="submit" style="font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:10px;" >  <a href="http://www.constantcontact.com/safesubscribe.jsp" target="_blank" style="font-size: 9px; font-style: italic;">Privacy provided by SafeSubscribe(SM)</a>

</form>

</td>

</tr>

</table>

</div>

 

 

<div style="text-align: center; padding-top: 10px;"><div style="font-size: 9px; padding-bottom: 0px;">. . . . . . . . . .  . . . . . . . . . . . . . . . . . . . . .  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . </div>

Decaneas Archive, 295 Endicott Avenue, Revere, MA 02151   <a href="mailto:[email protected]" class="link">[email protected]</a>    617-834-1684<br />

All contents of this site are the exclusive rights of Decaneas Archive.</div><br />

<br />

</td>

</tr>

</table>

</div>

</div>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/201420-changing-email-in-mailing-list/
Share on other sites

sql

 

mysql> CREATE TABLE subscribers (

    -> id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,

    -> email VARCHAR (150) UNIQUE NOT NULL

    -> );

 

 

and php

 

<?php
2:   //set up a couple of functions
3:   function doDB() {
4:       global $mysqli;
5:
6:       //connect to server and select database; you may need it
7:       $mysqli = mysqli_connect("localhost", "joeuser",
8:           "somepass", "testDB");
9:
10:       //if connection fails, stop script execution
11:       if (mysqli_connect_errno()) {
12:       printf("Connect failed: %s\n", mysqli_connect_error());
13:       exit();
14:    }
15: }
16:
17: function emailChecker($email) {
18:     global $mysqli, $check_res;
19:
20:     //check that email is not already in list
21:     $check_sql = "SELECT id FROM SUBSCRIBERS
22:        WHERE email = '".$email."'";
23:     $check_res = mysqli_query($mysqli, $check_sql)
24:        or die(mysqli_error($mysqli));
25: }
26:
27: //determine if they need to see the form or not
28: if (!$_POST) {
29:     //they need to see the form, so create form block
30:     $display_block = "
31:     <form method=\"POST\" action=\"".$_SERVER["PHP_SELF"]."\">
32:
33:     <p><strong>Your E-Mail Address:</strong><br/>
34:     <input type=\"text\" name=\"email\" size=\"40\">
35:
36:     <p><strong>Action:</strong><br/>
37:     <input type=\"radio\" name=\"action\"
38:         value=\"sub\" checked> subscribe
39:     <input type=\"radio\" name=\"action\"
40:         value=\"unsub\"> unsubscribe
41:
42:     <p><input type=\"submit\" name=\"submit\"
43:        value=\"Submit Form\"></p>
44:     </form>";
45:
46: } else if (($_POST) && ($_POST["action"] == "sub")) {
47:     //trying to subscribe; validate email address
48:     if ($_POST["email"] == "") {
49:         header("Location: manage.php");
50:         exit;
51:     } else {
52:         //connect to database
53:         doDB();
54:
55:         //check that email is in list
56:         emailChecker($_POST["email"]);
57:
58:         //get number of results and do action
59:         if (mysqli_num_rows($check_res) < 1) {
60:             //free result
61:             mysqli_free_result($check_res);
62:
63:             //add record
64:                $add_sql = "INSERT INTO subscribers (email)
65:                        VALUES('".$_POST["email"]."')";
66:                $add_res = mysqli_query($mysqli, $add_sql)
67:                       or die(mysqli_error($mysqli));
68:                  $display_block = "<p>Thanks for signing up!</p>";
69:
70:              //close connection to MySQL
71:              mysqli_close($mysqli);
72:          } else {
73:              //print failure message
74:                    $display_block = "<p>You're already subscribed!</p>";
75:          }
76:      }
77:  } else if (($_POST) && ($_POST["action"] == "unsub")) {
78:      //trying to unsubscribe; validate email address
79:      if ($_POST["email"] == "") {
80:          header("Location: manage.php");
81:          exit;
82:      } else {
83:          //connect to database
84:          doDB();
85:
86:          //check that email is in list
87:          emailChecker($_POST["email"]);
88:
89:          //get number of results and do action
90:          if (mysqli_num_rows($check_res) < 1) {
91:              //free result
92:              mysqli_free_result($check_res);
93:
94:              //print failure message
95:                 $display_block = "<p>Couldn't find your address!</p>
96:              <p>No action was taken.</p>";
97:          } else {
98:              //get value of ID from result
99:              while ($row = mysqli_fetch_array($check_res)) {
100:                  $id = $row["id"];
101:              }
102:
103:              //unsubscribe the address
104:              $del_sql = "DELETE FROM subscribers
105:                         WHERE id = '".$id."'";
106:              $del_res = mysqli_query($mysqli, $del_sql)
107:                         or die(mysqli_error($mysqli));
108:              $display_block = "<P>You're unsubscribed!</p>";
109:          }
110:          mysqli_close($mysqli);
111:      }
112:  }
113:  ?>
114: <html>
115: <head>
116: <title>Subscribe/Unsubscribe to a Mailing List</title>
117: </head>
118: <body>
119: <h1>Subscribe/Unsubscribe to a Mailing List</h1>
120: <?php echo "$display_block"; ?>
121: </body>
122: </html>

 

from sams book

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.