Jump to content

Archived

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

christiansees

New Box for PHPlist Sign Up

Recommended Posts

Hello All,

I am working on creating a new box to sign up for phplist. Eventually I would like to post it as a contribution, but for now I am hoping for some other eyes to review my code. As I am posting to a live store and would like to get it right the first time. Ha Ha The assumtions are a Milestone2.2 OsCommerce and PHPList 2.8.12 Please let me know what your suggestions are.

Here is the code for a new page sign_up.php

<?php
/*
 $Id: sign_up.php,v 1.01 2005/08/24 10:34:05 jch Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- sign_up //-->
         <tr>
           <td>
<!-- newsletter subscribe below here -->
 <script language="Javascript" type="text/javascript">
var fieldstocheck = new Array();
   fieldnames = new Array();
function checkform() {
 for (i=0;i<fieldstocheck.length;i++) {
   if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].value") == "") {
     alert("Please enter your "+fieldnames[i]);
     eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
     return false;
   }
 }
 if(! compareEmail())
 {
   alert("Email addresses you entered do not match");
   return false;
 }
 return true;
}
function addFieldToCheck(value,name) {
 fieldstocheck[fieldstocheck.length] = value;
 fieldnames[fieldnames.length] = name;
}
function compareEmail()
{
 return (document.subscribeform.elements["email"].value == document.subscribeform.elements["emailconfirm"].value);
}

</script>
<form method=post action="http://YOURSITEHERE/YOURNEWSLETTER/?p=subscribe" name="subscribeform" target = "subscribe">
 <p><b>Please choose</b>: <br/><input type=radio name="makeconfirmed" value="1"> Confirmed immediately<br/><input type=radio name="makeconfirmed" value="0"> Send confirmation email </p>
 <table border=0>
 <tr><td><div class="required">Email</div></td></tr>
 <tr><td class="attributeinput"><input type=text name=email value="" size="25">
 <script language="Javascript" type="text/javascript">addFieldToCheck("email","Email");</script></td></tr>
 <tr><td><div class="required">Confirm email</div></td></tr>
 <tr><td class="attributeinput"><input type=text name=emailconfirm value="" size="25">
 <script language="Javascript" type="text/javascript">addFieldToCheck("emailconfirm","Confirm email");</script></td></tr>
 <tr><td colspan=2>
       <span class="attributename">Preferred format for emails:</span><br/>
       <span class="attributeinput"><input type=radio name="htmlemail" value="0" ></span>
       <span class="attributename">Text</span>
       <span class="attributeinput"><input type=radio name="htmlemail" value="1" checked></span>
       <span class="attributename">HTML</span></td></tr>
 </table>
 <input type="hidden" name="list[2]" value="signup"><input type="hidden" name="listname[2]" value="YOUR MAILING LIST"/>
 <p><input type=submit name="subscribe" value="Subscribe" onClick="return checkform();"></p>
</form>
   <p><a href="http://YOURSITEHERE/YOURNEWSLETTER/?p=unsubscribe">Unsubscribe</a></p>
           </td>
         </tr>
<!-- sign_up_eof //-->

 

Are the bits of php code necessary? They seemed to me to just be the OsCommerce consistant way of creating links with in the box. As I wasn't linking to another part of the store they seemed unneeded. The code I am asking about is below.

<?php
   $info_box_contents = array();
   $info_box_contents[] = array('text' => BOX_HEADING_SPECIALS);

   new infoBoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_SPECIALS));

   $info_box_contents = array();
   $info_box_contents[] = array();

   new infoBox($info_box_contents);
?>

 

Just to confirm the only other changes I would need would be for english.php

 

// Newsletter sign up box text in includes/boxes/sign_up.php
// This the new one added by christian for phplist sign up only
define('BOX_HEADING_SIGN_UP', 'Get Our Newsletter');
define('BOX_SIGN_UP_TEXT', 'Sign Up For Our Newsletter')

 

and for comlum_left.php

  require(DIR_WS_BOXES . 'sign_up.php');

 

There doesn't need to be an addition to filenames.php?

Thanks for looking

Christian


On your last day only you will have to approve or disaprove of how your life has been.

Share this post


Link to post
Share on other sites
Are the bits of php code necessary? They seemed to me to just be the OsCommerce consistant way of creating links with in the box. As I wasn't linking to another part of the store they seemed unneeded. The code I am asking about is below.

 

hello christian, the tep_href_link will maintain the sessions.

 

also this line of code

<p><a href="http://YOURSITEHERE/YOURNEWSLETTER/?p=unsubscribe">Unsubscribe</a></p>

You could use php with tep_redirect(tep_href_link....etc again to maintain sessions

 

Are you going to have admin control module to switch on/off the feature?

Share this post


Link to post
Share on other sites

Hi, thanks for the reply

Yes I understand that the tep_href_link method will preserve the session ID, but as I said the links all point to pages off the OsCommerce store, also as new windows, because if they were to surf over to the PHPlist and back PHPlist would not be handing them back to OsCommerce with the session ID intact any way. It has no way of preserving it. I think that the following code would be much better. Please let me know if you think it will work.

Thanks

Christian

<?php
$info_box_contents = array();
$info_box_contents[] = array('align' => 'left',
                             'text' => '<form method=post action="http://YOURSITEHERE/YOURNEWSLETTER/?p=subscribe" name="subscribeform" target = "subscribe">
                                       <p><b>Please choose</b>: <br/>
                                       <input type=radio name="makeconfirmed" value="1"> Confirmed immediately<br/><input type=radio name="makeconfirmed" value="0"> Send confirmation email </p>
                                       <table border=0>
                                       <tr><td><div class="required">Email</div></td></tr>
                                       <tr><td class="attributeinput"><input type=text name=email value="" size="25">
                                       <script language="Javascript" type="text/javascript">addFieldToCheck("email","Email");</script></td></tr>
                                       <tr><td><div class="required">Confirm email</div></td></tr>
                                       <tr><td class="attributeinput"><input type=text name=emailconfirm value="" size="25">
                                       <script language="Javascript" type="text/javascript">addFieldToCheck("emailconfirm","Confirm email");</script></td></tr>
                                       <tr><td colspan=2>
                                         <span class="attributename">Preferred format for emails:</span><br/>
                                         <span class="attributeinput"><input type=radio name="htmlemail" value="0" ></span>
                                         <span class="attributename">Text</span>
                                         <span class="attributeinput"><input type=radio name="htmlemail" value="1" checked></span>
                                         <span class="attributename">HTML</span></td></tr>
                                       </table>
                                       <input type="hidden" name="list[2]" value="signup"><input type="hidden" name="listname[2]" value="K mailing list"/>
                                       <p><input type=submit name="subscribe" value="Subscribe" onClick="return checkform();"></p>
                                       </form>
                                       <p><a href="http://YOURSITEHERE/YOURNEWSLETTER/?p=unsubscribe" target="blank">Unsubscribe</a></p>');

new infoBox($info_box_contents);
?>


On your last day only you will have to approve or disaprove of how your life has been.

Share this post


Link to post
Share on other sites

Sorry not meaning to double post but here is the full code for the sign_up.php

<?php
/*
 $Id: sign_up.php,v 1.01 2005/08/24 10:34:05 jch Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- sign_up //-->
         <tr>
           <td>
<!-- newsletter subscribe below here -->
 <script language="Javascript" type="text/javascript">
var fieldstocheck = new Array();
   fieldnames = new Array();
function checkform() {
 for (i=0;i<fieldstocheck.length;i++) {
   if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].value") == "") {
     alert("Please enter your "+fieldnames[i]);
     eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
     return false;
   }
 }
 if(! compareEmail())
 {
   alert("Email addresses you entered do not match");
   return false;
 }
 return true;
}
function addFieldToCheck(value,name) {
 fieldstocheck[fieldstocheck.length] = value;
 fieldnames[fieldnames.length] = name;
}
function compareEmail()
{
 return (document.subscribeform.elements["email"].value == document.subscribeform.elements["emailconfirm"].value);
}

</script>
<?php
$info_box_contents = array();
$info_box_contents[] = array('align' => 'left',
                             'text' => '<form method=post action="http://YOURSITEHERE/YOURNEWSLETTER/?p=subscribe" name="subscribeform" target = "subscribe">
                                       <p><b>Please choose</b>: <br/>
                                       <input type=radio name="makeconfirmed" value="1"> Confirmed immediately<br/><input type=radio name="makeconfirmed" value="0"> Send confirmation email </p>
                                       <table border=0>
                                       <tr><td><div class="required">Email</div></td></tr>
                                       <tr><td class="attributeinput"><input type=text name=email value="" size="25">
                                       <script language="Javascript" type="text/javascript">addFieldToCheck("email","Email");</script></td></tr>
                                       <tr><td><div class="required">Confirm email</div></td></tr>
                                       <tr><td class="attributeinput"><input type=text name=emailconfirm value="" size="25">
                                       <script language="Javascript" type="text/javascript">addFieldToCheck("emailconfirm","Confirm email");</script></td></tr>
                                       <tr><td colspan=2>
                                         <span class="attributename">Preferred format for emails:</span><br/>
                                         <span class="attributeinput"><input type=radio name="htmlemail" value="0" ></span>
                                         <span class="attributename">Text</span>
                                         <span class="attributeinput"><input type=radio name="htmlemail" value="1" checked></span>
                                         <span class="attributename">HTML</span></td></tr>
                                       </table>
                                       <input type="hidden" name="list[2]" value="signup"><input type="hidden" name="listname[2]" value="K mailing list"/>
                                       <p><input type=submit name="subscribe" value="Subscribe" onClick="return checkform();"></p>
                                       </form>
                                       <p><a href="http://YOURSITEHERE/YOURNEWSLETTER/?p=unsubscribe" target="_blank">Unsubscribe</a></p>');

new infoBox($info_box_contents);
?>
           </td>
         </tr>
<!-- sign_up_eof //-->


On your last day only you will have to approve or disaprove of how your life has been.

Share this post


Link to post
Share on other sites

Ok yes there is should be the css associated classes and the filenames.php you asked earlier for the new file you may need to add a definition. The same for the BOX_HEADINGS.... you could add them in the equivalent language files.

 

For the html of the signup.php you can run a check with the w3c validator (use a test page) to make sure there are no errors.

Share this post


Link to post
Share on other sites

Ok it's quick and dirty I know. I didn't really want to go editing OsCommerce to create new variables so I just used the java. As far as the css the exit css definitions for boxes is fine bos headings is defined in the english.php as shown above. So here is the final edit, till I get time to whip it into true OsC code and submit as a contribution. Best thing is that it is tested and it works :D

<?php
/*
 $Id: sign_up.php,v 1.01 2005/08/24 10:34:05 jch Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- sign_up //-->
         <tr>
           <td>
<!-- newsletter subscribe below here -->
 <script language="Javascript" type="text/javascript">
var fieldstocheck = new Array();
   fieldnames = new Array();
function checkform() {
 for (i=0;i<fieldstocheck.length;i++) {
   if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].value") == "") {
     alert("Please enter your "+fieldnames[i]);
     eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
     return false;
   }
 }
 if(! compareEmail())
 {
   alert("Email addresses you entered do not match");
   return false;
 }
 return true;
}
function addFieldToCheck(value,name) {
 fieldstocheck[fieldstocheck.length] = value;
 fieldnames[fieldnames.length] = name;
}
function compareEmail()
{
 return (document.subscribeform.elements["email"].value == document.subscribeform.elements["emailconfirm"].value);
}

</script>
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => BOX_HEADING_SIGN_UP);

 new infoBoxHeading($info_box_contents, false, false);

$info_box_contents = array();
$info_box_contents[] = array('align' => 'left',
                             'text' => '<form method=post action="http://YOURSITEHERE/YOURNEWSLETTER/?p=subscribe" name="subscribeform" target = "subscribe">
                                       <p><b>Choose confirmation</b>: <br/>
                                       <input type=radio name="makeconfirmed" value="1"> Confirmed now <br/>
                                       <input type=radio name="makeconfirmed" value="0">Send email <br/>
                                       <b>Email</b><br/>
                                       <input type=text name=email value="">
                                       <script language="Javascript" type="text/javascript">addFieldToCheck("email","Email");</script><br/>
                                       <b>Confirm email</b><br/>
                                       <input type=text name=emailconfirm value="">
                                       <script language="Javascript" type="text/javascript">addFieldToCheck("emailconfirm","Confirm email");</script><br/>
                                       <b>Email format:</b><br/>
                                       Text <input type=radio name="htmlemail" value="0"><br/>
                                       HTML <input type=radio name="htmlemail" value="1" checked><br/>
                                       <input type="hidden" name="list[2]" value="signup"><input type="hidden" name="listname[2]" value="K mailing list"/>
                                       <input type=submit name="subscribe" value="Subscribe" onClick="return checkform();"></p>
                                       </form>
                                       <p><a href="http://YOURSITEHERE/YOURNEWSLETTER/?p=unsubscribe" target="_blank">Unsubscribe</a></p>');

new infoBox($info_box_contents);
?>
           </td>
         </tr>
<!-- sign_up_eof //-->


On your last day only you will have to approve or disaprove of how your life has been.

Share this post


Link to post
Share on other sites

Also if you use this you will want to comment out the OsCommerce Newsletter box on the create_account.php and the account.php pages. The best guide is hereNew Box Page If you read it you will also see that no new filenames.php entry is needed.


On your last day only you will have to approve or disaprove of how your life has been.

Share this post


Link to post
Share on other sites

yes that info could be included with the readme in the contribution. As of the code I looked at it a bit seems ok you have tested it so since it works its cool for first version :D

Share this post


Link to post
Share on other sites
Ok it's quick and dirty I know.

 

Hi,

Did you ever manage to get this added as a contribution. It would be a valuable addition to the community as I am struggling with the same issue of how to integrate osCommerce and phpList right now, without any success ( :(

 

Please let me know if you ever found time to share what you learned (I could not find anything in the contribution page).

 

Thanks guys!

:D

Share this post


Link to post
Share on other sites

×