This following modification will change the look of your Registration page, and add the ability to display the Terms and Conditions section before Registration form itself in websites that generated with PHPMaker 9.0.1. The Terms and Conditions section can be displayed or not by simply setting a constant value in the configuration file that generated by PHPMaker.
If the Terms and Conditions is displayed, then that page will appear precede the page where the user register his/her account. Conversely, if not displayed, then the page Terms and Conditions does not appear, but user will directly see the Registration form page. In addition, you can now decide whether to display the Captcha on Registration page or not, simply by setting up the related constant in your configuration file.
All we have to do is customizing PHPMaker template files. In other words, we will not modify the generated script files at all.
Important: In order to display the Captcha in the User Registration Page, then make sure to do the following:
- Enable the CAPTCHA extension from: Tools -> Extensions -> CAPTCHA.
- Enable the related setting from: Security -> Advanced -> User Login Options -> User Registration Page -> CAPTCHA (require extension).
Updated on May 30, 2012: This customization has been implemented in PHPMaker version 9.0.2, it matches to each other, and as a result, it works properly.
Updated on July 21, 2012: This customization has been implemented in PHPMaker version 9.0.3, it matches to each other, and as a result, it works properly.
Updated on September 4, 2012: This customization has been implemented in PHPMaker version 9.0.4, it matches to each other, and as a result, it works properly.
Updated on November 28, 2012: This customization has been implemented in PHPMaker version 9.1.0, it matches to each other, and as a result, it works properly.
Updated on February 9, 2013: This customization has been implemented in PHPMaker version 9.2.0, it matches to each other, and as a result, it works properly.
Updated on June 17, 2013: The customization for CAPTCHA part has been handled by using MasinoCAPTCHA extension The customization for the look and view of Register page has been handled by MasinoRegister extension. You don’t need to implement the customization below if you use my extensions together with the original PHPMaker Template and Extensions.
[hidepost]
Before we get started, please note that the step number 1 and 2 is identically with the step number 1 and 2 in the customization for Login Page in PHPMaker version 9.0.1 (previous article). So, if you have done it before, you may skip the step number 1 and 2 below, and start from the step number 3.
- Download images-box.zip. Extract the .zip file that contains of 9 image files in it, to your \Script\images sub-directory. Make sure you do not skip this step, as those images are also being used for the other customization that related to Registration, Forgot Password, and Change Password pages.
-
Open your \extensions\CAPTCHA\captcha-script.php file, and then replace all of the content of that file with the following code below (Warning: Please backup your original file first before doing this step!):
<!--##session phpcaptcha_config##--> <!--## // Check if Use Captcha var bUseCaptcha = false; var bConfirmCaptcha = false; var EXT = EXTS("CAPTCHA"); if (EXT.Enabled) { if (CTRL.CtrlID == "register") { if (PROJ.SecRegisterCaptcha) { bUseCaptcha = true; bConfirmCaptcha = PROJ.SecRegisterConfirm; } } else if (CTRL.CtrlID == "login") { if (PROJ.SecLoginCaptcha) { bUseCaptcha = true; bConfirmCaptcha = false; } } else if (CTRL.CtrlID == "forgotpwd") { if (PROJ.SecForgotPwdCaptcha) { bUseCaptcha = true; bConfirmCaptcha = false; } } else if (CTRL.CtrlID == "changepwd") { if (PROJ.SecChangePwdCaptcha) { bUseCaptcha = true; bConfirmCaptcha = false; } } else if (CTRL.CtrlID == "add") { if (TABLE.TblAddCaptcha) { bUseCaptcha = true; bConfirmCaptcha = TABLE.TblAddConfirm; } } else if (CTRL.CtrlID == "edit") { if (TABLE.TblEditCaptcha) { bUseCaptcha = true; bConfirmCaptcha = TABLE.TblEditConfirm; } } } // Get table variable sTblVar = gsTblVar; ##--> <!--##/session##--> <!--##session phpcaptcha_var##--> <!--## if (bUseCaptcha) { ##--> // CAPTCHA var $captcha; <!--## } ##--> <!--##/session##--> <!--##session phpcaptcha_php##--> <!--## if (bUseCaptcha) { if (CTRL.CtrlID == "add" || CTRL.CtrlID == "register") { ##--> // CAPTCHA checking if ($this->CurrentAction <> "I" && $this->CurrentAction <> "C") { if ( (($this->CurrentAction == "F") || ($this->CurrentAction == "I") || ($this->CurrentAction == "A") || ($this->CurrentAction == "X")) && (MS_SHOW_CAPTCHA_ON_REGISTRATION_PAGE == TRUE) ) { $objForm->Index = -1; $this->captcha = $objForm->GetValue("captcha"); if ($this->captcha <> @$_SESSION["EW_CAPTCHA_CODE"]) { // CAPTCHA unmatched $this->setFailureMessage($Language->Phrase("EnterValidateCode")); $this->CurrentAction = "I"; // Reset action, do not insert $this->EventCancelled = TRUE; // Event cancelled $this->RestoreFormValues(); // Restore form values } else { if ($this->CurrentAction == "A") $_SESSION["EW_CAPTCHA_CODE"] = ew_Random(); } } } <!--## } else if (CTRL.CtrlID == "edit") { ##--> // CAPTCHA checking if ($this->CurrentAction <> "I") { $objForm->Index = -1; $this->captcha = $objForm->GetValue("captcha"); if ($this->captcha <> @$_SESSION["EW_CAPTCHA_CODE"]) { // CAPTCHA unmatched $this->setFailureMessage($Language->Phrase("EnterValidateCode")); // Set message $this->CurrentAction = ""; // Reset action, do not update $this->EventCancelled = TRUE; // Event cancelled $this->RestoreFormValues(); // Restore form values } else { if ($this->CurrentAction == "U") $_SESSION["EW_CAPTCHA_CODE"] = ew_Random(); } } <!--## } else if (CTRL.CtrlID == "login") { ##--> // CAPTCHA checking if (ew_IsHttpPost()) { $this->captcha = @$_POST["captcha"]; if ($this->captcha <> @$_SESSION["EW_CAPTCHA_CODE"]) { // CAPTCHA unmatched $this->setFailureMessage($Language->Phrase("EnterValidateCode")); // Set message $bValidate = FALSE; } } if (!$bValidate) { $_SESSION["EW_CAPTCHA_CODE"] = ew_Random(); } <!--## } else if (CTRL.CtrlID == "forgotpwd") { ##--> // CAPTCHA checking if (ew_IsHttpPost()) { $this->captcha = @$_POST["captcha"]; if ($this->captcha <> @$_SESSION["EW_CAPTCHA_CODE"]) { // CAPTCHA unmatched $this->setFailureMessage($Language->Phrase("EnterValidateCode")); // Set message $bValidEmail = FALSE; } } if (!$bValidEmail) { $_SESSION["EW_CAPTCHA_CODE"] = ew_Random(); } <!--## } else if (CTRL.CtrlID == "changepwd") { ##--> // CAPTCHA checking if (ew_IsHttpPost()) { $this->captcha = @$_POST["captcha"]; if ($this->captcha <> @$_SESSION["EW_CAPTCHA_CODE"]) { // CAPTCHA unmatched $this->setFailureMessage($Language->Phrase("EnterValidateCode")); // Set message $bValidate = FALSE; } } if (!$bValidate) { $_SESSION["EW_CAPTCHA_CODE"] = ew_Random(); } <!--## } } ##--> <!--##/session##--> <!--##session phpcaptcha_htm##--> <!--## if (bUseCaptcha) { ##--> <!--## if (bConfirmCaptcha) { ##--> <?php if ($<!--##=gsTblVar##-->->CurrentAction <> "F") { ?> <!--## } ##--> <!-- captcha html (begin) --> <tr> <td > </td> <td > </td> <tr/> <tr> <td colspan="3" align="center"> <?php if (phpversion() < "4.3.2") { echo "<p class=\"ewmsg\">Warning: CAPTCHA extension is enabled but PHP version on this server is " . phpversion() . " only. The extension requires PHP >= 4.3.2.</p>"; } ?> <div><img src="ewcaptcha.php" alt="Security Image" width="200" height="50" /></div><br> <span class="phpmaker"><!--##@EnterValidateCode##--><!--##@FieldRequiredIndicator##--></span><br> <input type="text" name="captcha" id="captcha" size="30" /> </td> </tr> <!--## if (bConfirmCaptcha) { ##--> <?php } else { ?> <input type="hidden" name="captcha" id="captcha" value="<?php echo $<!--##=sPageObj##-->->captcha ?>" /> <?php } ?> <!--## } ##--> <br> <!-- captcha html (end) --> <!--## } ##--> <!--##/session##--> <!--##session phpcaptcha_js##--> <!--## if (bUseCaptcha) { ##--> if (fobj.captcha && !ew_HasValue(fobj.captcha)) return ew_OnError(this, fobj.captcha, ewLanguage.Phrase("EnterValidateCode")); <!--## } ##--> <!--##/session##--> -
Open your \Script\ewcfg.php file, and find this code:
// General
before that line, please insert the following code:
// Begin of modification Customizing Registration Page, by Masino Sinaga, May 3, 2012 <!--## if (PROJ.SecRegisterPage) { ##--> define("MS_SHOW_CAPTCHA_ON_REGISTRATION_PAGE", TRUE, TRUE); define("MS_SHOW_TOC_ON_REGISTRATION_PAGE", TRUE, TRUE); <!--## } ##--> // End of modification Customizing Registration Page, by Masino Sinaga, May 3, 2012 -
Replace all of the content in \Script\register.php file with the following code (Warning: Please Backup your existing register.php page before doing this step!):
<!--##session currenttable##--> <!--## // Set security table current if (ew_IsNotEmpty(PROJ.SecTbl)) { TABLE = DB.Tables(PROJ.SecTbl); goFlds = goTblFlds.Fields; gsTblVar = TABLE.TblVar; } if (GetFldObj(PROJ.SecLoginIDFld)) { LOGINIDFIELD = FIELD; sLoginIDFld = gsFld; sLoginIDFldName = gsFldName; sLoginIDFldVar = gsFldVar; sLoginIDFldParm = gsFldParm; sLoginIDFldObj = "this->" + gsFldParm; } if (GetFldObj(PROJ.SecPasswdFld)) { PASSWORDFIELD = FIELD; sPasswordFld = gsFld; sPasswordFldName = gsFldName; sPasswordFldVar = gsFldVar; sPasswordFldParm = gsFldParm; sPasswordFldObj = "this->" + gsFldParm; } if (PROJ.SecRegisterEmail && ew_IsNotEmpty(PROJ.SecEmailFld)) { if (GetFldObj(PROJ.SecEmailFld)) { EMAILFIELD = FIELD; sEmailFld = gsFld; sEmailFldName = gsFldName; sEmailFldVar = gsFldVar; sEmailFldParm = gsFldParm; sEmailFldObj = "this->" + gsFldParm; } } var sActivateFldName = ""; if (PROJ.SecRegisterActivate && ew_IsNotEmpty(PROJ.SecRegisterActivateFld)) { if (GetFldObj(PROJ.SecRegisterActivateFld)) { sActivateFldName = gsFldName; } } ##--> <!--##/session##--> <?php <!--##session phpmain##--> <!--##include captcha-script.php/phpcaptcha_var##--> // // Page main // function Page_Main() { global $conn, $Security, $Language, $gsFormError, $objForm; $bUserExists = FALSE; if (@$_POST["a_register"] <> "") { // Get action $this->CurrentAction = $_POST["a_register"]; $this->LoadFormValues(); // Get form values // Validate form if (!$this->ValidateForm()) { $this->CurrentAction = "I"; // Form error, reset action $this->setFailureMessage($gsFormError); } } else { // $this->CurrentAction = "I"; // Display blank record $this->LoadDefaultValues(); // Load default values } <!--##include captcha-script.php/phpcaptcha_php##--> <!--## if (PROJ.SecRegisterActivate && ew_IsNotEmpty(PROJ.SecRegisterActivateFld)) { ##--> // Handle email activation if (@$_GET["action"] <> "") { $sAction = $_GET["action"]; $sEmail = @$_GET["email"]; $sApprovalCode = @$_GET["code"]; if ($sEmail == TEAdecrypt($sApprovalCode, EW_RANDOM_KEY)) { if (strtolower($sAction) == "confirm") { // Email activation if ($this->ActivateEmail($sEmail)) { // Activate this email if ($this->getSuccessMessage() == "") $this->setSuccessMessage($Language->Phrase("ActivateAccount")); // Set up message acount activated <!--## if (PROJ.SecRegisterAutoLogin && ew_IsNotEmpty(sLoginIDFldObj) && ew_IsNotEmpty(sPasswordFldObj)) { ##--> // Auto login user from cookie values $sUsr = TEAdecrypt(@$_COOKIE[EW_PROJECT_NAME]['Username'], EW_RANDOM_KEY); $sPwd = TEAdecrypt(@$_COOKIE[EW_PROJECT_NAME]['Password'], EW_RANDOM_KEY); if ($Security->ValidateUser($sUsr, $sPwd, TRUE)) $this->Page_Terminate(<!--##=sRegisterReturnPage##-->); // Go to return page <!--## } else { ##--> $this->Page_Terminate("<!--##=sFnLogin##-->"); // Go to login page <!--## } ##--> } } } if ($this->getFailureMessage() == "") $this->setFailureMessage($Language->Phrase("ActivateFailed")); // Set activate failed message $this->Page_Terminate("<!--##=sFnLogin##-->"); // Go to login page } <!--## } ##--> switch ($this->CurrentAction) { case "I": // Blank record, no action required break; case "A": // Add <!--## if (!LOGINIDFIELD.FldAutoIncrement) { ##--> // Check for duplicate User ID $sFilter = str_replace("%u", ew_AdjustSql($<!--##=sLoginIDFldObj##-->->CurrentValue), EW_USER_NAME_FILTER); // Set up filter (SQL WHERE clause) and get return SQL // SQL constructor in <!--##=gsTblVar##--> class, <!--##=gsTblVar##-->info.php $this->CurrentFilter = $sFilter; $sUserSql = $this->SQL(); if ($rs = $conn->Execute($sUserSql)) { if (!$rs->EOF) { $bUserExists = TRUE; $this->RestoreFormValues(); // Restore form values $this->setFailureMessage($Language->Phrase("UserExists")); // Set user exist message } $rs->Close(); } <!--## } else { ##--> $bUserExists = FALSE; <!--## } ##--> if (!$bUserExists) { $this->SendEmail = TRUE; // Send email on add success if ($this->AddRow()) { // Add record <!--## if (PROJ.SecRegisterEmail && ew_IsNotEmpty(PROJ.SecEmailFld)) { ##--> // Load user email $sReceiverEmail = $<!--##=sEmailFldObj##-->->CurrentValue; if ($sReceiverEmail == "") { // Send to recipient directly $sReceiverEmail = EW_RECIPIENT_EMAIL; $sBccEmail = ""; } else { // Bcc recipient $sBccEmail = EW_RECIPIENT_EMAIL; } // Set up email content if ($sReceiverEmail <> "") { $Email = new cEmail; $Email->Load("<!--##=sFnRegisterTxt##-->"); $Email->ReplaceSender(EW_SENDER_EMAIL); // Replace Sender $Email->ReplaceRecipient($sReceiverEmail); // Replace Recipient if ($sBccEmail <> "") $Email->AddBcc($sBccEmail); // Add Bcc <!--## for (var i = 0; i < nFldCount; i++) { if (GetFldObj(arFlds[i])) { ##--> $Email->ReplaceContent('<!--FieldCaption_<!--##=SQuote(gsFldName)##-->-->', $this-><!--##=gsFldParm##-->->FldCaption()); $Email->ReplaceContent('<!--<!--##=SQuote(gsFldName)##-->-->', strval($this-><!--##=gsFldParm##-->->FormValue)); <!--## } } // Field ##--> <!--## if (PROJ.SecRegisterActivate) { ##--> $sActivateLink = ew_FullUrl() . "?action=confirm"; $sActivateLink .= "&email=" . $<!--##=sEmailFldObj##-->->CurrentValue; $sActivateLink .= "&code=" . TEAencrypt($<!--##=sEmailFldObj##-->->CurrentValue, EW_RANDOM_KEY); $Email->ReplaceContent("<!--ActivateLink-->", $sActivateLink); <!--## if (PROJ.SecRegisterAutoLogin && ew_IsNotEmpty(sLoginIDFldObj) && ew_IsNotEmpty(sPasswordFldObj)) { ##--> setcookie(EW_PROJECT_NAME . '[Username]', TEAencrypt($<!--##=sLoginIDFldObj##-->->CurrentValue, EW_RANDOM_KEY), EW_COOKIE_EXPIRY_TIME); // Set up user name cookies setcookie(EW_PROJECT_NAME . '[Password]', TEAencrypt($<!--##=sPasswordFldObj##-->->FormValue, EW_RANDOM_KEY), EW_COOKIE_EXPIRY_TIME); // Set up password cookies <!--## } ##--> <!--## } ##--> $Email->Charset = EW_EMAIL_CHARSET; // Get new recordset $this->CurrentFilter = $this->KeyFilter(); $sSql = $this->SQL(); $rsnew = $conn->Execute($sSql); <!--## if (SYSTEMFUNCTIONS.ServerScriptExist("Other","Email_Sending")) { ##--> $Args = array(); $Args["rs"] = &$rsnew; $bEmailSent = FALSE; if ($this->Email_Sending($Email, $Args)) $bEmailSent = $Email->Send(); <!--## } else { ##--> $bEmailSent =$Email->Send(); <!--## } ##--> // Send email failed if (!$bEmailSent) $this->setFailureMessage($Email->SendErrDescription); } <!--## } ##--> <!--## if (PROJ.SecRegisterActivate) { ##--> if ($this->getSuccessMessage() == "") $this->setSuccessMessage($Language->Phrase("RegisterSuccessActivate")); // Activate success <!--## } else { ##--> if ($this->getSuccessMessage() == "") $this->setSuccessMessage($Language->Phrase("RegisterSuccess")); // Register success <!--## if (PROJ.SecRegisterAutoLogin && ew_IsNotEmpty(sLoginIDFldObj) && ew_IsNotEmpty(sPasswordFldObj)) { ##--> // Auto login user if ($Security->ValidateUser($<!--##=sLoginIDFldObj##-->->CurrentValue, $<!--##=sPasswordFldObj##-->->FormValue, TRUE)) { // Nothing to do } <!--## } ##--> <!--## } ##--> $this->Page_Terminate(<!--##=sRegisterReturnPage##-->); // Return } else { $this->RestoreFormValues(); // Restore form values } } } // Render row <!--## if (bRegisterConfirm) { ##--> if ($this->CurrentAction == "F") { // Confirm page $this->RowType = EW_ROWTYPE_VIEW; // Render view } else { $this->RowType = EW_ROWTYPE_ADD; // Render add } <!--## } else { ##--> $this->RowType = EW_ROWTYPE_ADD; // Render add <!--## } ##--> $this->ResetAttrs(); $this->RenderRow(); } <!--##/session##--> ?> <!--##session htmtable##--> <!--##include phpcommon.php/header-message##--> <!--##include phpcommon.php/phpcommon-message##--> <br /><br /> <body> <form name="<!--##=sFormName##-->" id="<!--##=sFormName##-->" class="ewForm" action="<?php echo ew_CurrentPage() ?>" method="post"<!--##=sEncType##--><!--##=sFormSubmit##-->> <table border="0" cellpadding="0" cellspacing="0" width="400" align="center"> <tr> <td> <table border="0" cellpadding="0" cellspacing="0" width="420" align="center"> <tr> <td align="left" valign="top" width="4" height="30"><img src="phpimages/sidebox-title-left.gif"></td> <td align="left" valign="middle" background="phpimages/sidebox-title-bg.gif" width="390" height="30"> <font class="option"> <strong><!--##@RegisterPage##--></strong></font> </td> <td align="left" valign="top" width="4" height="30"><img src="phpimages/sidebox-title-right.gif"></td> </tr> </table> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" align="center" class="ewGrid"> <tr valign="top"> <td width="4" align="left" valign="top" background="phpimages/sidebox-bar-left.gif"><img src="phpimages/sidebox-bar-px.gif"></td> <td bgcolor="#FFFFFF" width="" align="left" valign="top"> <table bgcolor="#F0F1F5" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td> <table width="412" border="0" align="center" cellpadding="2" cellspacing="0"> <?php if ( ($<!--##=gsTblVar##-->->CurrentAction == "F") || ($<!--##=gsTblVar##-->->CurrentAction == "I") || ($<!--##=gsTblVar##-->->CurrentAction == "A") || ($<!--##=gsTblVar##-->->CurrentAction == "X") || (MS_SHOW_TOC_ON_REGISTRATION_PAGE == FALSE) ) { ?> <tr> <td> </td> <td> <input type="hidden" name="t" value="<!--##=gsTblVar##-->" /> <input type="hidden" name="a_register" id="a_register" value="A" /> <!--## if (bRegisterConfirm) { ##--> <?php if ($<!--##=gsTblVar##-->->CurrentAction == "F") { // Confirm page ?> <input type="hidden" name="a_confirm" id="a_confirm" value="F" /> <?php } elseif ($<!--##=gsTblVar##-->->CurrentAction == "T") { ?> <input type="hidden" name="a_confirm" id="a_confirm" value="T" /> <?php } ?> <!--## } else { ##--> <?php if ($<!--##=gsTblVar##-->->CurrentAction == "T") { ?> <input type="hidden" name="a_confirm" id="a_confirm" value="T" /> <?php } ?> <!--## } ##--> </td> </tr> <!--## // Get number of pages nPage = 1; dPageLabels = {}; if (PROJ.RegisterMultiPage) { for (var i = 0; i < nFldCount; i++) { if (GetFldObj(arFlds[i])) { if (!goFld.FldAutoIncrement && ew_IsEmpty(goFld.FldAutoUpdateValue) && goFld.FldName != DB.SecUserLevelFld && goFld.FldName != sActivateFldName) { if (glFldPageIndex > nPage) nPage = glFldPageIndex; if (!(String(glFldPageIndex) in dPageLabels)) dPageLabels[String(glFldPageIndex)] = "Page " + glFldPageIndex; } } } // Field } // Multi page style if (nPage > 1) sMultiPageStyle = " style=\"width: 100%\""; else sMultiPageStyle = ""; var sMainTableStyle = ""; var sPageTableStyle = ""; if (bUseCustomTemplate) { if (!bUseCustomMultiPageTemplate) { sMainTableStyle = " style=\"display: none\""; sMultiPageStyle = " style=\"display: none\""; } else { sPageTableStyle = " style=\"display: none\""; } } // Multi page if (nPage > 1) { ##--> <table cellspacing="0" cellpadding="0"<!--##=sMainTableStyle##-->><tr><td> <div id="<!--##=sPageObj##-->" class="yui-navset"> <ul class="yui-nav"> <!--## for (var i = 1; i <= nPage; i++) { if (String(i) in dPageLabels) { if (i == 1) sItemClass = " class=\"selected\""; else sItemClass = ""; ##--> <li<!--##=sItemClass##-->><a href="#tab_<!--##=gsTblVar##--><!--##=i##-->"><em><span class="phpmaker"><?php echo $<!--##=gsTblVar##-->->PageCaption(<!--##=i##-->) ?></span></em></a></li> <!--## } else { ##--> <li style="display: none"><a href="#tab_<!--##=gsTblVar##--><!--##=i##-->"></a></li> <!--## } } // Page ##--> </ul> <div class="yui-content"> <!--## } ##--> <!--## for (var pageidx = 1; pageidx <= nPage; pageidx++) { var sTableId = ewTableId + ((nPage > 1) ? pageidx : ""); if (nPage > 1) { ##--> <div id="tab_<!--##=gsTblVar##--><!--##=pageidx##-->"> <!--## } if (!PROJ.RegisterMultiPage || (PROJ.RegisterMultiPage && String(pageidx) in dPageLabels)) { ##--> <!-- <table cellspacing="0" class="ewGrid"<!--##=sMultiPageStyle##-->><tr><td class="ewGridContent"> <div class="ewGridMiddlePanel"> <table cellspacing="0" id="<!--##=sTableId##-->"<!--##=ewCSSTableClass##--><!--##=sPageTableStyle##-->> --> <!--## rowcnt = 0; for (var i = 0; i < nFldCount; i++) { if (GetFldObj(arFlds[i])) { if (!PROJ.RegisterMultiPage || (PROJ.RegisterMultiPage && glFldPageIndex == pageidx)) { if (!goFld.FldAutoIncrement && ew_IsEmpty(goFld.FldAutoUpdateValue)) { // Skip User Level Field, Activate Field and Hidden Field if (goFld.FldName != DB.SecUserLevelFld && goFld.FldName != sActivateFldName && !(goFld.FldHtmlTag == "HIDDEN" && ew_IsNotEmpty(goFld.FldDefault))) { sHeaderSpanId = "elh_" + gsTblVar + "_" + gsFldParm; sSpanId = "el_" + gsTblVar + "_" + gsFldParm; if (IsRequiredField(FIELD)) sFldReqInd = "<?php echo $Language->Phrase(\"FieldRequiredIndicator\") ?>"; else sFldReqInd = ""; rowcnt += 1; ##--> <?php if ($<!--##=gsFldObj##-->->Visible) { // <!--##=gsFldName##--> ?> <tr id="r_<!--##=gsFldParm##-->"<?php echo $<!--##=gsTblVar##-->->RowAttributes() ?>> <td<!--##=ewCSSTableHeaderClass##--> width="40%"><span id="<!--##=sHeaderSpanId##-->"> <!--##=SYSTEMFUNCTIONS.FieldCaption()##--><!--##=sFldReqInd##--></span></td> <td> </td> <td<?php echo $<!--##=gsFldObj##-->->CellAttributes() ?> width="58%"><span id="<!--##=sSpanId##-->"><!--##=SYSTEMFUNCTIONS.FieldAdd()##--></span><?php echo $<!--##=gsFldObj##-->->CustomMsg ?></td> </tr> <?php } ?> <!--## if (goFld.FldName == PROJ.SecPasswdFld) { // Generate Confirm Password Field sTmpFldVar = goFld.FldVar; // Save Field Variable Name gsFldVar = "c_" + gsFldParm; // New Variable as c_FldVar goFld.FldVar = gsFldVar; sHeaderSpanId = "e2h_" + gsTblVar + "_" + gsFldParm; sSpanId = "e2_" + gsTblVar + "_" + gsFldParm; rowcnt += 1; ##--> <?php if ($<!--##=gsFldObj##-->->Visible) { // <!--##=gsFldName##--> ?> <tr id="rc_<!--##=gsFldParm##-->"<?php echo $<!--##=gsTblVar##-->->RowAttributes() ?>> <td<!--##=ewCSSTableHeaderClass##-->><span id="<!--##=sHeaderSpanId##-->"> <!--##=SYSTEMFUNCTIONS.FieldCaption()##--><!--##=sFldReqInd##--></span></td> <td> </td> <td<?php echo $<!--##=gsFldObj##-->->CellAttributes() ?>><span id="<!--##=sSpanId##-->"><!--##=SYSTEMFUNCTIONS.FieldAdd()##--></span></td> </tr> <?php } ?> <!--## goFld.FldVar = sTmpFldVar; // Restore Field Variable Name } // Hidden field } else if (goFld.FldHtmlTag == "HIDDEN" && ew_IsNotEmpty(goFld.FldDefault)) { ##--> <!--##=SYSTEMFUNCTIONS.FieldAdd()##--> <!--## } } } } } // Field ##--> <!--## if (nPage > 1 && bUseCustomMultiPageTemplate) { ##--> <!--##~SYSTEMFUNCTIONS.GetCustomTemplatePage(pageidx)##--> <!--## } ##--> <!--## } if (nPage > 1) { ##--> </div> <!--## } } // Page ##--> <!--## // Multi page if (nPage > 1) { ##--> </div> </div> </td></tr></table> <!--## } ##--> <?php if (MS_SHOW_CAPTCHA_ON_REGISTRATION_PAGE == TRUE) { ?> <!--##include captcha-script.php/phpcaptcha_htm##--> <?php } ?> <tr> <td > </td> <td > </td> <td > </td> </tr> <tr> <td> </td> <td> </td> <td><span class="phpmaker"> <!--## if (bRegisterConfirm) { ##--> <?php if ($<!--##=gsTblVar##-->->CurrentAction <> "F") { // Confirm page ?> <input type="<!--##=sButtonType##-->" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("RegisterBtn")) ?>"<!--##=sConfirmButtonSubmit##--> /> <?php } else { ?> <input type="<!--##=sButtonType##-->" name="btnCancel" id="btnCancel" value="<?php echo ew_BtnCaption($Language->Phrase("CancelBtn")) ?>"<!--##=sCancelButtonSubmit##--> /> <input type="<!--##=sButtonType##-->" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("ConfirmBtn")) ?>"<!--##=sButtonSubmit##--> /> <?php } ?> <!--## } else { ##--> <input type="<!--##=sButtonType##-->" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("RegisterBtn")) ?>"<!--##=sButtonSubmit##--> /> <!--## } ##--> </span></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <?php } else { ?> <tr> <td> <?php echo $Language->Phrase("TaCTitle"); ?></td> </tr> <tr> <td> <textarea cols="65" rows="14" readonly style="resize: none;";><?php echo $Language->Phrase("TaCContent"); ?></textarea></td> </tr> <tr> <td> </td> </tr> <tr> <td align="left"> <input type="hidden" name="a_register" id="a_register" value="I"> <input type="submit" name="btnAction" id="btnAction" value="<?php echo $Language->Phrase("IAgree"); ?>" onclick="this.form.a_register.value='I';"> </td> </tr> <tr> <td> </td> </tr> <?php } ?> </table> </td> </tr> </table> </td> <td width="4" align="left" valign="top" background="phpimages/sidebox-bar-right.gif"><img src="phpimages/sidebox-bar-px.gif"> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" width="420" align="center"> <tr> <td width="2" height="29" align="left" valign="top"><img src="phpimages/storybox-bottom-left.gif"></td> <td width="394" height="29" background="phpimages/storybox-bottom-bg.gif"> <a href="<!--##=sFnLogin##-->"><!--##@BackToLogin##--></a></td> <td width="8" height="29" align="left" valign="top"><img src="phpimages/storybox-bottom-right.gif"></td> </tr> </table> <br /><br /> </form> </body> <!--## if (bUseCustomTemplate) { ##--> <!--##~SYSTEMFUNCTIONS.GetCustomTemplate()##--> <!--## } ##--> <!--## if (bUseCustomTemplate) { ##--> <!--##~SYSTEMFUNCTIONS.RenderCustomTemplate()##--> <!--## } ##--> <script type="text/javascript"> <!--##=sFormName##-->.Init(); </script> <!--##include phpcommon.php/footer-message##--> <!--##/session##--> <?php <!--##session phpfunction##--> <!--## if (PROJ.SecRegisterActivate && ew_IsNotEmpty(PROJ.SecRegisterActivateFld)) { if (GetFldObj(PROJ.SecRegisterActivateFld)) { sActivateFld = gsFld; sActivateFldName = gsFldName; sActivateFldVar = gsFldVar; sActivateFldParm = gsFldParm; sActivateFldQuoteS = gsFldQuoteS; sActivateFldQuoteE = gsFldQuoteE; sActivateFldValue = ActivateFieldValue(FIELD); if (ew_IsNotEmpty(sActivateFldQuoteS)) { sActivateFldValue = ew_DoubleQuote(sActivateFldValue, 1); } } ##--> // Activate account based on email function ActivateEmail($email) { global $conn, $Language; $sFilter = str_replace("%e", ew_AdjustSql($email), EW_USER_EMAIL_FILTER); $sSql = $this->GetSQL($sFilter, ""); $conn->raiseErrorFn = 'ew_ErrorFn'; $rs = $conn->Execute($sSql); $conn->raiseErrorFn = ''; if (!$rs) return FALSE; if (!$rs->EOF) { $rsnew = $rs->fields; $this->LoadRowValues($rs); // Load row values $rs->Close(); $rsact = array('<!--##=SQuote(sActivateFldName)##-->' => <!--##=sActivateFldValue##-->); // Auto register $this->CurrentFilter = $sFilter; $res = $conn->Execute($this->UpdateSQL($rsact)); <!--## if (SYSTEMFUNCTIONS.ServerScriptExist("Other","User_Activated")) { ##--> if ($res) { // Call User Activated event $rsnew['<!--##=SQuote(sActivateFldName)##-->'] = <!--##=sActivateFldValue##-->; $this->User_Activated($rsnew); } <!--## } ##--> return $res; } else { $this->setFailureMessage($Language->Phrase("NoRecord")); $rs->Close(); return FALSE; } } <!--## } ##--> <!--##/session##--> ?> <?php <!--##session phpevents##--> <!--##~SYSTEMFUNCTIONS.GetServerScript("Other","Email_Sending")##--> <!--##~SYSTEMFUNCTIONS.GetServerScript("Other","Form_CustomValidate")##--> <!--##~SYSTEMFUNCTIONS.GetServerScript("Other","User_Registered")##--> <!--##~SYSTEMFUNCTIONS.GetServerScript("Other","User_Activated")##--> <!--##/session##--> ?> -
Open your C:\Program Files\PHPMaker 9\languages\english.xml, and find this code:
</global>
before that line, please insert the following code:
<phrase id="TaCTitle" value="Terms and Conditions"/> <phrase id="TaCContent" value="Here is the content of Terms and Condition. Each row must be separated by BR tag."/> <phrase id="IAgree" value="I Agree"/>Do the same way to your .xml language (for example, I am also using Indonesian, then I add the same code to my indonesian.xml file:
<phrase id="TaCTitle" value="Syarat dan Ketentuan"/> <phrase id="TaCContent" value="Di sini isi dari Syarat dan Ketentuan. Setiap baris harus dipisahkan dengan tag BR."/> <phrase id="IAgree" value="Saya Setuju"/>
-
Open your \Script\ew_addon.js script file, and find this code:
// Validate form
before that line, please insert the following code:
<!--## if (CTRL.CtrlID == "register" && TABLE.TblName == PROJ.SecTbl) { ##--> <?php // Begin of modification removing error in registration page after clicking on "I Agree" button, by Masino Sinaga, January 30, 2013 if ( ($<!--##=SECTABLE.TblName##-->->CurrentAction == "F") || ($<!--##=SECTABLE.TblName##-->->CurrentAction == "I") || ($<!--##=SECTABLE.TblName##-->->CurrentAction == "A") || ($<!--##=SECTABLE.TblName##-->->CurrentAction == "X") || (MS_SHOW_TOC_ON_REGISTRATION_PAGE == FALSE) ) { // End of modification removing error in registration page after clicking on "I Agree" button, by Masino Sinaga, January 30, 2013 ?> <!--## } ##--> -
Still in \Script\ew_addon.js file, find again this code:
// Process detail page if (fobj.detailpage && fobj.detailpage.value && ewForms[fobj.detailpage.value]) return ewForms[fobj.detailpage.value].Validate(fobj); <!--## } ##--> return true; }
after the last line of that code, please insert the following code:
<?php // Begin of modification removing error in registration page after clicking on "I Agree" button, by Masino Sinaga, January 30, 2013 ?> <!--## if (CTRL.CtrlID == "register" && TABLE.TblName == PROJ.SecTbl) { ##--> <?php } // End of modification removing error in registration page after clicking on "I Agree" button, by Masino Sinaga, January 30, 2013 ?> <!--## } ##--> -
Open your add-script.php file, and find this code for PHPMaker version < 9.1.0:
[code lang="php"]
[/code]or if you are using PHPMaker version >= 9.1.0, then find this code:
<br /> <!--##include detail-script.php/detailgrid##--> <!--##include captcha-script.php/phpcaptcha_htm##-->
then replace it with the following code:
<!--##include detail-script.php/detailgrid##--> <!--## if (TABLE.TblAddCaptcha) { ##--> <table> <!--##include captcha-script.php/phpcaptcha_htm##--> </table> <!--## } ##--> <br /> -
Open your edit-script.php file, and find this code for PHPMaker version < 9.1.0:
[code lang="php"]
[/code]or if you are using PHPMaker version >= 9.1.0, then find this code:
<br /> <!--##include detail-script.php/detailgrid##--> <!--##include captcha-script.php/phpcaptcha_htm##-->
then replace it with the following code:
<!--##include detail-script.php/detailgrid##--> <!--## if (TABLE.TblEditCaptcha) { ##--> <table> <!--##include captcha-script.php/phpcaptcha_htm##--> </table> <!--## } ##--> <br /> -
Please note that since PHPMaker 9.0.4, there was a little bit change in this register.php file. After you replacing all of the content of this file in the previous step above, then find this following code (again, this customization only for PHPMaker >= 9.0.4):
$res = $conn->Execute($this->UpdateSQL($rsact));then replace it with the following code:
// $res = $conn->Execute($this->UpdateSQL($rsact)); // Old method? <= 9.0.3 $res = $this->Update($rsact); // Started from PHPMaker 9.0.4 - Finally, re-generate your script files using PHPMaker as always. 🙂
[/hidepost]
How do I put a
tag into the language phrase?
Whenever I put one in, all of the phrases disappear from the site.
Simply replace it with the following:
Would really like to see an “About” modification similar to “Terms and Conditions” for the footer. We could display the author, name of the application, current version, acknowledgements, etc.
Perhaps this article will help you to implement it.
Please note that I did not include the “About” link in the footer, since it usually is placed under Help -> About of web application menu.
Perfect!
I’m getting a compilation error:
PHPMaker: Generate Table weekends add page error
PHPMaker (ewExadd): Microsoft JScript runtime error
(1391), line 6292, column 2
Description: ‘bUseCaptcha’ is undefined
Also, Step 4 is confusing:
Replace all of the content in \Script\register.php file with the following code (Warning: Please Backup your existing login.php page before doing this step!):
It refers to replacing register.php (which I did), but tells you to backup login.php
Regarding ‘bUseCaptcha’ is undefined, please read again the instruction regarding Captcha in my article above. In other words, you have to enable the extension first to avoid the error message.
Thanks for backup “login.php” correction. I just changed the filename above.
I had to change this:
<!--##include detail-script.php/detailgrid##--> <!--## if (bUseCaptcha) { ##--> <!--##include captcha-script.php/phpcaptcha_htm##--> <!--## } ##-->to this, to get it to compile.
Same thing with the edit-script code.
Something is missing.
I had to remove the “if” statements and leave the results to include the captcha-script.php
No need to remove “if” statements if you have enabled the Captcha extension.
Masino,
Thanks. I had enabled it in the user registration page and thought I had in the extensions. Once I enabled the extension, it works perfectly.
Just finished applying this modification and I’m getting a couple of issues:
1) the T&C box pops up as expected, but the layout is broken – rather like the Login panel breaks when the text size is larger than “small”
2) I can’t get BR tags to work … I copied your “<br />” code exactly but, the tag simply displays within the text rather than actually causing a line break
Forgot to mention… As with the Login page modification, I couldn’t find any obvious reason for your MS_SHOW_CAPTCHA_ON_REGISTRATION_PAGE define either – after removing references to it, the Captcha system appears to work perfectly (as it normally would) via the Security setting in phpMaker
Well, my reason for MS_SHOW_CAPTCHA_ON_REGISTRATION_PAGE is that you can control whether to show the Captcha or not from the configuration (ewcfg9.php) file without having to re-generate that file each time you want to show it or not.
For example, if you want to hide the Captcha, then simply change the constant in ewcfg9.php file become:
define("MS_SHOW_CAPTCHA_ON_REGISTRATION_PAGE", FALSE, TRUE);After implementing the customization above, please try also to implement the related customization from the following article: Improving the Terms and Conditions Feature in Websites that Generated by PHPMaker 9.1.0.
Okay, the broken display issue was actually quite simple to fix… just reduce the textarea width from 65 columns to 54 in your modified register.php:
<textarea cols="65" rows="14" readonly style="resize: none;";><?php echo $Language->Phrase("TaCContent"); ?></textarea></td>However, getting the BR tags to work wasn’t quite so simple because TEXTAREAs ignore all formatting tags, so the solution was switching from a TEXTAREA to a DIV but, to ensure that scrolling occurred correctly and that things look neat, we need to replace the following code:
<tr> <td> <?php echo $Language->Phrase("TaCTitle"); ?></td> </tr> <tr> <td> <textarea cols="65" rows="14" readonly style="resize: none;";><?php echo $Language->Phrase("TaCContent"); ?></textarea></td> </tr> <tr> <td> </td> </tr> <tr> <td align="left"> <input type="hidden" name="a_register" id="a_register" value="I"> <input type="submit" name="btnAction" id="btnAction" value="<?php echo $Language->Phrase("IAgree"); ?>" onclick="this.form.a_register.value='I';"> </td> </tr>…with this new code:
<tr> <td><br /> <strong><?php echo $Language->Phrase("TaCTitle"); ?></strong></td> </tr> <tr height="12"> <td width="54"> <div contenteditable="false" style="width: 388px; height: 320px; white-space: pre-line; overflow:scroll; margin-left: 10px; padding-right: 10px;" name="textarea"> <?php echo $Language->Phrase("TaCContent"); ?></div></td> </tr> <tr> <td align="left"> <input type="hidden" name="a_register" id="a_register" value="I"> <input type="submit" name="btnAction" id="btnAction" value="<?php echo $Language->Phrase("IAgree"); ?>" onclick="this.form.a_register.value='I';"> </td> </tr>… and now the BR tags (and all other formatting codes) work fine (I’m using
in the language file).
Hope this helps other members.
I couldn’t post the code changes as WP filtered them out so I’ve emailed them to you directly – there’s just one block of about 14 lines that needs replacing in your modified register.php so maybe you can post them here so that other members can apply the fix themselves.
Done. Thanks for the feedback.