SearchSearch   ProfileProfile   Log inLog in   RegisterRegister 

Custom Pages: Question Regarding Page Creation
Goto page 1, 2  Next
 
Post new topic   Reply to topic    FirstSpot Forum Index -> Pre-sales Support Forum
View previous topic :: View next topic  
Author Message
ReverendD



Joined: 08 Jun 2011
Posts: 17

PostPosted: Wed Jun 08, 2011 6:44 pm    
Post subject: Custom Pages: Question Regarding Page Creation

Quick question,

I am still using the trial version in a testing environment before deciding if this software will take care of my customers needs.

Regarding the example code from Chapter 5, am I able to use this explicitly w/o the need for everything else in the alogin_form_body.tpl file?

To give a quick description of what I am trying to accomplish, I want a basic form that asks for an email address and has a Submit button. Upon entering the information and clicking submit the email address will be sent to a specified email address in the form. It will also be a required field before the submit will be accepted. This part is easy. What I am unsure about is what exactly would I need to use in order to redirect to the proper location I have setup in the software? I am guessing the example from Chapter 5 would be sufficient to do this but I would like confirmation on it since the user guide does not include any specific information regarding the tags used within any of the tpl files for pulling data from other files (e.g. {%$L_ALOGIN_FORM_SHARED_SECRET%}).

Just to note, I am using anonymous login due to the environment and may request other small bits of information in the form, but the login and use of this service would require ToS agreement (which includes use of email for future marketing) which will be on the page once it is created.

Thanks.

~Reverend
Back to top
alan
Forum facilitator


Joined: 26 Sep 2003
Posts: 4435

PostPosted: Wed Jun 08, 2011 7:08 pm    
Post subject:

First, you don't really need to use the Smarty tag. You can always treat the tpl file like an html file.

And yes, you can just start with the sample code in chapter 5 of firstspot_guide.pdf:

Code:
<html>
<body>
   <form name="loginForm" method="post">
      <input type="submit" value="login" name="anonymous_mode_button">
      <input type="hidden" name="ok_url" value="redirect.php">
      <input type="hidden" name="cart_url" value="alogin_form.php">
      <input type="hidden" name="fail_url" value="alogin_form.php">
   </form>
</body>
</html>


The redirect should be automatically handled by FirstSpot. If you still have difficulties, you might want to post your code here (make sure you mark your code using the "Code" button).
_________________
~ Patronsoft Limited ~
Back to top
ReverendD



Joined: 08 Jun 2011
Posts: 17

PostPosted: Wed Jun 08, 2011 7:25 pm    
Post subject:

Okay, this should make it very easy to setup then. I will test once I get the vistor side working properly. The hardware I have for the visitor side is having issues so I will have to test with different hardware to see if thats the issue. Thanks Alan.

~Reverend
Back to top
ReverendD



Joined: 08 Jun 2011
Posts: 17

PostPosted: Thu Jun 09, 2011 2:19 pm    
Post subject:

Something I forgot to ask,

How will the recursive directories work when pointing at images and CSS files once I create my page?

Example, I have several custom images and backgrounds I will be using, so once I write the code and replace the alogin_form_body.tpl with my information, will I use what I see in the current tpl file and just point at ../ and place my custom images in the directory above it as it is now in the \authserv\template?

Thanks again for the assistance. I am thinking this will be the software my customer decides to go with.

~Rev
Back to top
alan
Forum facilitator


Joined: 26 Sep 2003
Posts: 4435

PostPosted: Thu Jun 09, 2011 2:59 pm    
Post subject:

The "current" directory should be FirstSpot\authserv, so you might want to put the image and css files there.
_________________
~ Patronsoft Limited ~
Back to top
ReverendD



Joined: 08 Jun 2011
Posts: 17

PostPosted: Thu Jun 09, 2011 4:06 pm    
Post subject:

Okay, so I have most of the page created using their custom images, etc.

I have the basic form created and I want the form to post to an email address but not have it open up the users local email client to do so. I see I can use several PHP/JS scripts to perform this but is there anything already built into the system that I can use instead of needing to use a third party script outside of FirstSpot?

Here is the code so far for the form:

Code:

<form name="loginForm" method="post" action="mailto:test email address" style="font-size: 10px;">
   <input type="text" value="Email Address" size="20" name="emailAddress">
   <input type="text" value="Attending Service" size="20" name="attendedService"><br />
   <input type="checkbox" name="acceptTOS" value="acceptTOS">I Agree with the Terms & Conditions<br />
   <input type="submit" value="Continue" name="anonymous_mode_button">
   <input type="hidden" name="ok_url" value="redirect.php">
   <input type="hidden" name="cart_url" value="alogin_form.php">
   <input type="hidden" name="fail_url" value="alogin_form.php">
</form>


The other thing I am looking at is requiring portions of the form to be required, but it looks like another JS would be needed for that as well unless there is something within FirstSpot that I can use for this as well. Thanks guys.

~Rev
Back to top
ReverendD



Joined: 08 Jun 2011
Posts: 17

PostPosted: Thu Jun 09, 2011 7:04 pm    
Post subject:

Okay, so new question since I think the above question may be beyond the scope of what you will answer.

Since FirstSpot installs PHP, where would I want to place a PHP script/page that handles the email & required field checking and have it work? Would it be okay to place it in the same folder where the regular files are (\authserv)?

If so then I may have this figured out to make it work the way they desire it to.

~Rev
Back to top
alan
Forum facilitator


Joined: 26 Sep 2003
Posts: 4435

PostPosted: Fri Jun 10, 2011 5:25 am    
Post subject:

1) You might want to check out http://patronsoft.com/forum/viewtopic.php?t=2642 for a similar example

2) Yes, you can put other files in FirstSpot\authserv as well.
_________________
~ Patronsoft Limited ~
Back to top
ReverendD



Joined: 08 Jun 2011
Posts: 17

PostPosted: Fri Jun 10, 2011 7:06 pm    
Post subject:

Okay, I was able to create code that will check required portions of the form. I have it below just as a reference to anyone else who may want it try it. Only reason I went this route was I could not get the code from the forum post you linked to work properly.

Code:

<SCRIPT TYPE="text/javascript" LANGUAGE=JAVASCRIPT>
   <!--
   function checkForm()
   {
      if (document.loginForm.acceptTOS.checked == false)
      {
         alert ('Please agree to the Terms & Conditions before proceeding.');
         return false;
      }
      if (document.loginForm.emailAddress.value == "")
      {
         alert ('Please enter a valid email address.');
         return false;
      }
         else
      {
         return true;
      }
   }
   //-->
</SCRIPT>


This script allows to check two areas, a text area and the checkbox to make sure they have a value. I did not bother working in checking/validating the email address structure, I may do that in the future but this will work for now.

Now I just need to find a way to save the email information. I thought I came across something about saving any information placed in the forms into a CSV file but I cannot locate that anymore. Does this sound familiar? If so I think this may be a better route to go since I can make it available over the network as opposed to an email (in case there is a spam issue).

~Rev
Back to top
alan
Forum facilitator


Joined: 26 Sep 2003
Posts: 4435

PostPosted: Mon Jun 13, 2011 5:28 am    
Post subject:

To save in a text file (e.g. csv), for PHP you can just use fopen, fputcsv function.
_________________
~ Patronsoft Limited ~
Back to top
ReverendD



Joined: 08 Jun 2011
Posts: 17

PostPosted: Thu Jun 16, 2011 6:56 pm    
Post subject:

Okay, so I opted with the csv file using fopen and appending the data as I need it. This should suffice for that since the whole email thing was being a pain as well as complicating things too much.

Now here is the issue I am running into, in my form I am using the action="../saveFile.php" to run the php code to append to the csv file. The only issue I am running into now is that when you click on the submit button, it redirects to the saveFile.php file which has code to redirect it immediately to the redirect.php file to continue on to the correct web page, which then fails. I think this is because the redirect.php file is not getting the correct input from the alogin form, correct?

Below is my code for the saveFile.php. Instead of using the separate save file page should I just put my code into the redirect.php file?

Code:

<?php

/* Checks to make sure the email address is in a valid format and no illegal characters */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $emailAddress))
   {
      show_error("E-mail address not valid");
   }


/* Gathers data that will be written to the CSV file from the form using the input name attribute */
$cvsData = $attendedDate . "," . $emailAddress . "," . $attendedService . "\n";

/* Location & Name of CSV File to open and append */
$fp = fopen("captivePortal.csv","a");

/* Writes Data to the file, then closes it */
if($fp)
{
   fwrite($fp,$cvsData);
   fclose($fp);
}

?>
<HTML>
<HEAD>
<TITLE>XXXXXXXXXX HotSpot</TITLE>
<META http-equiv="REFRESH" content="0;url=redirect.php">
<META HTTP-EQUIV="Content-Type" CONTENT="text">
<META NAME="XXXXXXXXXX HotSpot - http://www.XXXXXXXXXX .net" CONTENT="text">
<META NAME="XXXXXXXXXX" CONTENT="text">

<B>Please wait while you are redirected.</B><br />

</BODY>
</HTML>
Back to top
alan
Forum facilitator


Joined: 26 Sep 2003
Posts: 4435

PostPosted: Fri Jun 17, 2011 10:56 am    
Post subject:

First, save the below code as savefile.php (we remove your html portion):

Code:
<?php

/* Checks to make sure the email address is in a valid format and no illegal characters */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $emailAddress))
   {
      show_error("E-mail address not valid");
   }


/* Gathers data that will be written to the CSV file from the form using the input name attribute */
$cvsData = $attendedDate . "," . $emailAddress . "," . $attendedService . "\n";

/* Location & Name of CSV File to open and append */
$fp = fopen("captivePortal.csv","a");

/* Writes Data to the file, then closes it */
if($fp)
{
   fwrite($fp,$cvsData);
   fclose($fp);
}

?>


Then in fs_login.php

1) find below line
$objrsult = $myobj->Authenticate($username, $password, $sess_patronsoft1, $sess_patronsoft2, $useragent);

2) replace to
include "saveFile.php";
$objrsult = $myobj->Authenticate($username, $password, $sess_patronsoft1, $sess_patronsoft2, $useragent);
_________________
~ Patronsoft Limited ~
Back to top
ReverendD



Joined: 08 Jun 2011
Posts: 17

PostPosted: Fri Jun 17, 2011 2:03 pm    
Post subject:

Okay, so I did as you suggested, removed the HTML for my saveFile.php and located the entry in the fs_login.php file and added the include "saveFile.php"; line in front of it (line 374).

This is lines 371-374 of the fs_login.php file:
Code:

      if ($scratchLogin == 'on') {
          $password = '';
      }
            include "saveFile.php";
                $objrsult = $myobj->Authenticate($username, $password, $sess_patronsoft1, $sess_patronsoft2, $useragent);

            }


I then changed my form to have action="fs_login.php" again and tested. After clicking continue it still stops at the saveFile.php page and does not continue. I have my form code below. I did a restart on FS as well to see if it just needed a reload, that returned the same result.

Code:

<span id="form">
      <form name="loginForm" method="post" onSubmit="return checkForm();" action="fs_login.php" style="font-size: 10px;">
         <input type="text" value="Email Address" size="30" name="emailAddress"><br />
         <input type="text" value="Attending Service" size="30" name="attendedService"><br />
         <input type="checkbox" name="acceptTOS" value="acceptTOS">I Agree with the <a href="tos.html" target="_blank">Terms & Conditions</a><br /><br />
         <input type="submit" value="Continue" name="anonymous_mode_button">
         <input type="hidden" name="subject" value="XXXXXXX HotSpot Form">
         <input type="hidden" name="ok_url" value="redirect.php">
         <input type="hidden" name="cart_url" value="alogin_form.php">
         <input type="hidden" name="fail_url" value="alogin_form.php">
      </form>
Back to top
alan
Forum facilitator


Joined: 26 Sep 2003
Posts: 4435

PostPosted: Fri Jun 17, 2011 3:32 pm    
Post subject:

You don't need to change alogin_form_body.tpl.

Please revert to the "simplest" alogin_form_body.tpl and try again. If you have difficulties, please post your latest alogin_form_body.tpl here.
_________________
~ Patronsoft Limited ~
Back to top
ReverendD



Joined: 08 Jun 2011
Posts: 17

PostPosted: Fri Jun 17, 2011 4:14 pm    
Post subject:

This is my edited alogin_form_body.tpl (original is backed up). I needed to change it to fit the customers website look/feel as well as add/change the form for requested information. Some CSS is embedded for now to allow for faster changes and will be moved to a separate file before it goes live.

If I go back to the original alogin_form_body.tpl I will still need to edit the form to fit the variable names in the saveFile.php and cheksum function being called as well as adding new text inputs.

The only things I have changed are the layout (tables, images, formatting) and additional text inputs on the form. I had this working prior to trying to mail/save the form data to a file.

I am curious, since we are using the include "saveFile.php"; line in the fs_login.php, when it gets to that line is it not exiting out from the saveFile.php code and continuing?



Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>XXXXXXX HotSpot - http://www.XXXXXXX.net</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text">
<META NAME="XXXXXXX HotSpot - http://www.XXXXXXX.net" CONTENT="text">
<META NAME="XXXXXXX" CONTENT="text">
   <style type="text/css">
      body {      
      <!-- BODY CSS -->
      background-color: #B3C3D2;
      background-image: url("../XXXXXXX-background.gif");
      background-image-repeat: repeat-x;
      font-family: Tahoma; }
      
      <!-- TEXT CSS-->>
      H2 {
      font-size: 20px;
      font-weight: bold;
      margin: 0 0 0 0;
      padding: 5px; }
      H3 {
      font-size: 16px;
      font-weight: normal;
      margin: 0 0 0 0;
      padding: 5px; }
      P {
      text-indent: 15px;
      font-face: Tahoma;
      font-size: 12px;
      padding: 5px; }
      
      <!-- TABLE CSS -->
      TABLE {
      padding: 0;
      width: 750px;
      border: 0px solid black;
      background-color: #D9E1E8;
      }
      TD {
      padding: 0;
      text-align: left;
      vertical-align: top;
      border: 0px solid black;
      background-color: #D9E1E8;
      }
      
      <!-- FORM CSS -->
      .form {
      padding: 20px; }
      
   </style>
</HEAD>
<BODY>

<SCRIPT TYPE="text/javascript" LANGUAGE=JAVASCRIPT>
   <!--
   function checkForm()
   {
      if (document.loginForm.acceptTOS.checked == false)
      {
         alert ('Please agree to the Terms & Conditions before proceeding.');
         return false;
      }
      if (document.loginForm.emailAddress.value == "")
      {
         alert ('Please enter a valid email address.');
         return false;
      }
         else
      {
         return true;
      }
   }
   //-->
</SCRIPT>


<TABLE ALIGN="center">
   <TR>
      <TD COLSPAN="2">
      <img src="../XXXXXXX-tophead.png" alt="XXXXXXX">
      </TD>
   </TR>
   <TR>
      <TD COLSPAN="2">
      <img src="../XXXXXXX-header.jpg" alt="XXXXXXX">
      </TD>
   </TR>
   <TR>
      <TD WIDTH="448px">
      <H2>Welcome,</H2>
      <p>To the XXXXXXX HotSpot, a free internet service provided by XXXXXXX Members to allow access to the Internet. To start browsing, please enter in the requested information to the right and click on "Continue". If you have any questions please speak with a member and they will be happy to assist you.</p>
      </TD>
      <TD WIDTH="300px">
      <H3>Sign In</H3>
      <span id="form">
      <form name="loginForm" method="post" onSubmit="return checkForm();" action="fs_login.php" style="font-size: 10px;">
         <input type="text" value="Email Address" size="30" name="emailAddress"><br />
         <input type="text" value="Attending XXXXXXX" size="30" name="attendedXXXXXXX"><br />
         <input type="checkbox" name="acceptTOS" value="acceptTOS">I Agree with the <a href="tos.html" target="_blank">Terms & Conditions</a><br /><br />
         <input type="submit" value="Continue" name="anonymous_mode_button">
         <input type="hidden" name="subject" value="XXXXXXX HotSpot Form">
         <input type="hidden" name="ok_url" value="redirect.php">
         <input type="hidden" name="cart_url" value="alogin_form.php">
         <input type="hidden" name="fail_url" value="alogin_form.php">
      </form>
      </span>
      </TD>
   </TR>
   <TR>
      <TD COLSPAN="2">
      <img src="../XXXXXXX-footer.gif" alt="XXXXXXX">
      </TD>
   </TR>
</TABLE>


</BODY>
</HTML>
Back to top
Display posts from previous:   
Post new topic   Reply to topic    FirstSpot Forum Index -> Pre-sales Support Forum All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group