Subscribe/Unsubscribe form help

  • ecu33
  • Novice
  • Novice
  • No Avatar
  • Joined: Jun 24, 2004
  • Posts: 28
  • Loc: Eastern US
  • Status: Offline

Post July 12th, 2004, 5:42 am

I am trying to add a text box for the user to enter their email address so that when my webpage (in design now) is updated I can send them an email. Can anyone steer me to where I can find info on how to set this up. Thanks to everyone here! Your awesome!
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 12th, 2004, 5:42 am

  • quantumcloud
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 11, 2004
  • Posts: 456
  • Loc: Dhaka, Bangladesh
  • Status: Offline

Post July 12th, 2004, 10:06 am

In the simplest form what you can do is write a php/cgi scripts that would take the email addresses input by the surfers and keep appending to a text file. Later when you are done with the site you just send them an email and notify using the cc or bcc feature for bulk mail from your regular email account. You will have to do it manually. This will work if you are expecting a small number of visitors and don't mind doing little manual work. Actually this would be quite easy. Since the text file can be written in the appropiate form so that you can just copy and paste all the email addresses at once. You just have check it once for accuracy. Lots of address validity checks can be built in already.

Or you can go with a full fledged newsletter or mailing list program. Many are available for free on the net. Do a search in the scriptsearch.com for newletter or mailing list. Here is one written with php.

http://www.scriptsearch.com/details/4203.html

Quote:
Description: PHP Mailing List has been designed to make the life of webmasters easier. This script collects the mail addresses of all who want to recieve your newsletter. It also provides automation of the unsubscribe process. PHP Mailing List works using MySQL database which provides a high performance of your web-server. PHP Mailing List is a cross-platform solution and will work under Linux, FreeBSD, Solaris, or Windows9x/NT/2000.


If you want to go with the first solution, I can write you a small script for that in php.
Web development company : quantumcloud

Web design company : web.com.bd
  • ecu33
  • Novice
  • Novice
  • No Avatar
  • Joined: Jun 24, 2004
  • Posts: 28
  • Loc: Eastern US
  • Status: Offline

Post July 12th, 2004, 10:11 am

the first solution would work great. I'm not expecting alot of addresses. I appreciate the help and the script.
  • quantumcloud
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 11, 2004
  • Posts: 456
  • Loc: Dhaka, Bangladesh
  • Status: Offline

Post July 12th, 2004, 10:28 am

Kool then. The few basic things you must have are: a php enabled server, the page that will have the script must have .php extension, and your ability to change file permission. Let me know if you have them.
Web development company : quantumcloud

Web design company : web.com.bd
  • ecu33
  • Novice
  • Novice
  • No Avatar
  • Joined: Jun 24, 2004
  • Posts: 28
  • Loc: Eastern US
  • Status: Offline

Post July 12th, 2004, 12:21 pm

Yes, I have all of those.
  • quantumcloud
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 11, 2004
  • Posts: 456
  • Loc: Dhaka, Bangladesh
  • Status: Offline

Post July 12th, 2004, 2:01 pm

Very nice. Give me some time then to get around to writing it.
Web development company : quantumcloud

Web design company : web.com.bd
  • ecu33
  • Novice
  • Novice
  • No Avatar
  • Joined: Jun 24, 2004
  • Posts: 28
  • Loc: Eastern US
  • Status: Offline

Post July 13th, 2004, 5:53 am

Thanx quantumcloud!
  • quantumcloud
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 11, 2004
  • Posts: 456
  • Loc: Dhaka, Bangladesh
  • Status: Offline

Post July 13th, 2004, 7:24 am

Sorry about the delay.

Anyway, here it is. It takes two fields. Name and email.

a. The form inside a table below goes in the page where you want people to submit the info. You can change the look anyway you choose, just make sure the form and the field names inside the form are unchanged.

Code: [ Download ] [ Select ]
<form name="form" method="post" action="./mailsubmitted.php">
 <table width="300" border="0" align="center" cellpadding="0" cellspacing="3" bordercolor="#CCCCCC">
  <tr>
   <td align="right" valign="middle" bgcolor="#CCCCCC"><p>Name:</p></td>
   <td align="left" valign="middle" bgcolor="dddddd">
    <p>
     <input name="name" type="text" class="input" id="contactname2" size="10" maxlength="25">
   </p>    </td>
  </tr>
  <tr>
   <td align="right" valign="middle" bgcolor="#CCCCCC">
    <p>Email:</p></td>
   <td align="left" valign="middle" bgcolor="dddddd">
    <p>
     <input name="email" type="text" class="input" id="email" size="10" maxlength="25">
*    </p>    </td>
  </tr>
  <tr>
   <td width="65%" align="left" valign="middle">Please enter your name and email address
   to get notified when the site is updated. </td>
   <td align="center" valign="middle"><div align="center">
     <input type="submit" name="Submit" value="Submit" class="button">
   </div></td>
  </tr>
 </table>
 <p>&nbsp;</p>
</form>
  1. <form name="form" method="post" action="./mailsubmitted.php">
  2.  <table width="300" border="0" align="center" cellpadding="0" cellspacing="3" bordercolor="#CCCCCC">
  3.   <tr>
  4.    <td align="right" valign="middle" bgcolor="#CCCCCC"><p>Name:</p></td>
  5.    <td align="left" valign="middle" bgcolor="dddddd">
  6.     <p>
  7.      <input name="name" type="text" class="input" id="contactname2" size="10" maxlength="25">
  8.    </p>    </td>
  9.   </tr>
  10.   <tr>
  11.    <td align="right" valign="middle" bgcolor="#CCCCCC">
  12.     <p>Email:</p></td>
  13.    <td align="left" valign="middle" bgcolor="dddddd">
  14.     <p>
  15.      <input name="email" type="text" class="input" id="email" size="10" maxlength="25">
  16. *    </p>    </td>
  17.   </tr>
  18.   <tr>
  19.    <td width="65%" align="left" valign="middle">Please enter your name and email address
  20.    to get notified when the site is updated. </td>
  21.    <td align="center" valign="middle"><div align="center">
  22.      <input type="submit" name="Submit" value="Submit" class="button">
  23.    </div></td>
  24.   </tr>
  25.  </table>
  26.  <p>&nbsp;</p>
  27. </form>


b. The php code below goes to a page named mailsubmitted.php . This is where the user is redirected after submission. Create the layout anyway you choose according to your site theme. The php code below goes where you want to show the user the message about a successful submission or invalid email address. The name field is optional. The php code only checks for a valid email address in the form someone@somehost.com . If invalid the user can go back and enter the address again.

PHP Code: [ Download ] [ Select ]
<?php
 
   $what = true;
 
   $chkemail = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $email);
 
   if (!$chkemail) {
 
            echo "Please enter a valid email address in the form someone@somehost.com<br>
 
            Hit the browser's back button to go back and enter a valid email address.<br>";
 
            $what = false;
 
            }
 
   $formatted = $name." : ".$email;
 
   if ($what == true)
 
   {
 
   $fp = fopen("./maildata.txt", "a");//change the file name maildata.txt to somethingelse.txt for lil security.
 
   if (!$fp) die ("Sorry, Cannot open file to write Try Later.");
 
   fwrite($fp, "$formatted \r\n");
 
   fclose($fp);
 
                echo "Thank you for entering your email address. We will get back to you as soon as we launch our new site.";
 
                }
 
?>
  1. <?php
  2.  
  3.    $what = true;
  4.  
  5.    $chkemail = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $email);
  6.  
  7.    if (!$chkemail) {
  8.  
  9.             echo "Please enter a valid email address in the form someone@somehost.com<br>
  10.  
  11.             Hit the browser's back button to go back and enter a valid email address.<br>";
  12.  
  13.             $what = false;
  14.  
  15.             }
  16.  
  17.    $formatted = $name." : ".$email;
  18.  
  19.    if ($what == true)
  20.  
  21.    {
  22.  
  23.    $fp = fopen("./maildata.txt", "a");//change the file name maildata.txt to somethingelse.txt for lil security.
  24.  
  25.    if (!$fp) die ("Sorry, Cannot open file to write Try Later.");
  26.  
  27.    fwrite($fp, "$formatted \r\n");
  28.  
  29.    fclose($fp);
  30.  
  31.                 echo "Thank you for entering your email address. We will get back to you as soon as we launch our new site.";
  32.  
  33.                 }
  34.  
  35. ?>


c. Before you test it, make a txt file named maildata.txt or somethingelse.txt that you specify above in the code. As it is all files must be in the same directory. CHMOD the file permission to world writable. 766 or 777 whatever works in your server.

d. Now try and submit. To view the data download and open the text file. It should output something like this:

Quote:


Let me know if there is a problem. Also if you want the information to be formatted in any other way you find convenient, we can change it.
Web development company : quantumcloud

Web design company : web.com.bd
  • ecu33
  • Novice
  • Novice
  • No Avatar
  • Joined: Jun 24, 2004
  • Posts: 28
  • Loc: Eastern US
  • Status: Offline

Post July 14th, 2004, 9:56 am

I'm still working on getting the mailsubmitted.php file to load after hitting the submit button. Is there a way to make this form work?

Code: [ Download ] [ Select ]
<form>
<tr align=left><td><b>Enter Your E-mail</b><br><input name="email" type=text id="email" style="width:120px;" size=10 maxlength="25"></td></tr>
<tr align=left><td><input type=radio>&nbsp;<b>Subscribe</b><br></td></tr>
<tr align=left><td><input type=radio>&nbsp;<b>Un Subscribe</b><br></td></tr>
<tr align=center><td><input type="submit" name="Submit" value="Submit" class="button">
          <br></td></tr>
</form>
  1. <form>
  2. <tr align=left><td><b>Enter Your E-mail</b><br><input name="email" type=text id="email" style="width:120px;" size=10 maxlength="25"></td></tr>
  3. <tr align=left><td><input type=radio>&nbsp;<b>Subscribe</b><br></td></tr>
  4. <tr align=left><td><input type=radio>&nbsp;<b>Un Subscribe</b><br></td></tr>
  5. <tr align=center><td><input type="submit" name="Submit" value="Submit" class="button">
  6.           <br></td></tr>
  7. </form>
  • ecu33
  • Novice
  • Novice
  • No Avatar
  • Joined: Jun 24, 2004
  • Posts: 28
  • Loc: Eastern US
  • Status: Offline

Post July 14th, 2004, 10:15 am

Sorry, I am trying to post the code for the form but my newbie status is telling on me.
[/code][/quote]
  • quantumcloud
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 11, 2004
  • Posts: 456
  • Loc: Dhaka, Bangladesh
  • Status: Offline

Post July 15th, 2004, 6:39 am

Alright, I sorta got your idea. Here is the modified codes. This will save the inputs like this:

Quote:
Subscribe : test@yahoo.com
Unsubscribe : test1@yahoo.com
Unsubscribe : test2@yahoo.com
Subscribe : test3@yahoo.com
Subscribe : test4@yahoo.com
Unsubscribe : test5@yahoo.com



Form code:

Code: [ Download ] [ Select ]
<form method="post" action="mailsubmitted.php">
<table>
<tr align=left><td><b>Enter Your E-mail</b><br><input name="email" type=text id="email" style="width:120px;" size=10 maxlength="25"></td></tr>
<tr align=left><td><input name="chk" type=radio value="sub" checked>
&nbsp;<b>Subscribe</b><br></td></tr>
<tr align=left><td><input name="chk" type=radio value="unsub">
&nbsp;<b>Un Subscribe</b><br></td></tr>
<tr align=center><td><input type="submit" name="Submit" value="Submit" class="button">
          <br></td></tr>
</table>
</form>
  1. <form method="post" action="mailsubmitted.php">
  2. <table>
  3. <tr align=left><td><b>Enter Your E-mail</b><br><input name="email" type=text id="email" style="width:120px;" size=10 maxlength="25"></td></tr>
  4. <tr align=left><td><input name="chk" type=radio value="sub" checked>
  5. &nbsp;<b>Subscribe</b><br></td></tr>
  6. <tr align=left><td><input name="chk" type=radio value="unsub">
  7. &nbsp;<b>Un Subscribe</b><br></td></tr>
  8. <tr align=center><td><input type="submit" name="Submit" value="Submit" class="button">
  9.           <br></td></tr>
  10. </table>
  11. </form>



Php code:

PHP Code: [ Download ] [ Select ]
<?php
 
   $what = true;
 
   $chkemail = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $email);
 
   if (!$chkemail) {
 
            echo "Please enter a valid email address in the form someone@somehost.com<br>
 
            Hit the browser's back button to go back and enter a valid email address.<br>";
 
            $what = false;
 
            }
 
   if ($chk == "sub") {
 
   $formatted = "Subscribe"." : ".$email;
 
   }
 
   else $formatted = "Unsubscribe"." : ".$email;
 
 
 
   if ($what == true)
 
   {
 
   $fp = fopen("./maildata.txt", "a");//change the file name maildata.txt to somethingelse.txt for lil security.
 
   if (!$fp) die ("Sorry, Cannot open file to write Try Later.");
 
   fwrite($fp, "$formatted \r\n");
 
   fclose($fp);
 
   echo "Thank you for entering your email address. We will get back to you as soon as we launch our new site.";
 
   }
 
?>
  1. <?php
  2.  
  3.    $what = true;
  4.  
  5.    $chkemail = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $email);
  6.  
  7.    if (!$chkemail) {
  8.  
  9.             echo "Please enter a valid email address in the form someone@somehost.com<br>
  10.  
  11.             Hit the browser's back button to go back and enter a valid email address.<br>";
  12.  
  13.             $what = false;
  14.  
  15.             }
  16.  
  17.    if ($chk == "sub") {
  18.  
  19.    $formatted = "Subscribe"." : ".$email;
  20.  
  21.    }
  22.  
  23.    else $formatted = "Unsubscribe"." : ".$email;
  24.  
  25.  
  26.  
  27.    if ($what == true)
  28.  
  29.    {
  30.  
  31.    $fp = fopen("./maildata.txt", "a");//change the file name maildata.txt to somethingelse.txt for lil security.
  32.  
  33.    if (!$fp) die ("Sorry, Cannot open file to write Try Later.");
  34.  
  35.    fwrite($fp, "$formatted \r\n");
  36.  
  37.    fclose($fp);
  38.  
  39.    echo "Thank you for entering your email address. We will get back to you as soon as we launch our new site.";
  40.  
  41.    }
  42.  
  43. ?>


What kind of problem with the mailsubmitted.php you are facing? Remember to CHMOD the text file, or it won't write to the file.
Web development company : quantumcloud

Web design company : web.com.bd
  • GhettoPuNKkiD
  • Novice
  • Novice
  • No Avatar
  • Joined: Aug 04, 2004
  • Posts: 20
  • Status: Offline

Post August 4th, 2004, 1:03 am

i tried that script..im running windows 2000 and apache 1.3

here is the url:

http://168.103.115.178/moontime.html

any help would be appreciated to get the script working :-( ..

-erik


Notice: Undefined variable: email in c:\program files\apache group\Apache\htdocs\mailsubmitted.php on line 3
Please enter a valid email address in the form someone@somehost.com
Hit the browser's back button to go back and enter a valid email address.

Notice: Undefined variable: chk in c:\program files\apache group\Apache\htdocs\mailsubmitted.php on line 9

Notice: Undefined variable: email in c:\program files\apache group\Apache\htdocs\mailsubmitted.php on line 12
  • quantumcloud
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 11, 2004
  • Posts: 456
  • Loc: Dhaka, Bangladesh
  • Status: Offline

Post August 4th, 2004, 6:03 am

Hi GhettoPuNKkiD,

The error you are getting means that the email variable is ot being passed to the mailsubmitted.php . Most probably you changed the form's email field name.

Quote:
<input name="email" type=text id="email" style="width:120px;" size=10 maxlength="25">


Make sure the id="email" is intact. Along with other id names of the html form.

If that does not solve your problem, post the code you are using as it is with any kind of change you might have made. I will have a look.
Web development company : quantumcloud

Web design company : web.com.bd
  • GhettoPuNKkiD
  • Novice
  • Novice
  • No Avatar
  • Joined: Aug 04, 2004
  • Posts: 20
  • Status: Offline

Post August 4th, 2004, 11:38 am

well i am using the exact code as you posted to the other user (The latest one) ..and im still getting the error...

here is a new url:

http://168.103.115.178/moonlist.htm

thanks,
-GPk
  • quantumcloud
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 11, 2004
  • Posts: 456
  • Loc: Dhaka, Bangladesh
  • Status: Offline

Post August 4th, 2004, 12:35 pm

Well, I am as sure as humanly possible that the code is alright. In fact, it is so simple that there is nothing to be messed up here. It works fine in my machine.

On the other hand, if you are using the exact code, it means it has something to do with the difference in server configuration. I see that you are probably using your home cmputer as server. And I also assume that you installed apache on a windows machine. If that is so, the problem could be a bug in the php.

Quote:
FORM variables are not passed when php.ini-optimized is used for C:\WINNT\php.ini.

The workaround is to use php.ini-dist instead.

http://aspn.activestate.com/ASPN/Mail/M ... Dev/830341

Another reason can be that you are using a php version that is above 4.20 and it has register global off by default. If that is causing the problem, this code has to be rewritten. Can you check out the above solution, and if the register global is off? You can get this info by saving a php file as phpinfo.php in the root directory with the following code.
PHP Code: [ Download ] [ Select ]
<?php
 
 
 
phpinfo();
 
 
 
?>
  1. <?php
  2.  
  3.  
  4.  
  5. phpinfo();
  6.  
  7.  
  8.  
  9. ?>
Web development company : quantumcloud

Web design company : web.com.bd
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post August 4th, 2004, 12:35 pm

Post Information

  • Total Posts in this topic: 31 posts
  • Users browsing this forum: tirkey and 62 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2009. Driven by phpBB © 2001-2009 phpBB Group.