Form submission

  • Hi.

    I have Pfsence setup in a pub for customer WIFI - The captive portal simply has a "I agree" button to click and connect, and then bounces off to the pubs homepage.

    What I would like to do is have a couple other form fields "Email", "Name", "Postcode" and use Javascript to validate they are filled.  When the form is submitted (currently submits to pfsence) the entries from these form fields will be sent to URL somewhere else to log activity.

    Can someone tell me if this is possible?  I am not near the pfsence box to look at the moment, and can't remote into it, so cannot verify my thoughts….

    If the captive portals form is sent to pfsence, how can I submit to a second URL?
    Can the second URL I want to send the form to be accessed before the captive portal opens?

    Any other way to use Pfsence to capture users details at the time of clicking on the captive portal?


  • Is this possible at all?

    I know I can use javascript to submit two forms - the one to PFsence itself and one to my second URL to recieve the other form fields.

    Can PFsence be told to let traffic through the captive portal to a specific URL for this form?

    Has anyone else managed to add additional form fields to the captive portal?

  • OK.

    So I have downloaded the latest version (mine is a little outdated) and have run it on the LIVE CD for some playing.

    Seems I can choose a domain name or IP that can pass through the captive portal to allow images to be loaded, or data to go out.

    I am using javascript and Ajax to send some POST fields out to a different URL, this works fine.

    To make sure these are sent if users do not have javascript, I have also forced the form submit to Pfsense to be sent via javascript instead.  If users do not have javascript, they dont have access!  To do this you need to remove the submit button and change it to a standard button, submitting the form via javascript.

    Only thing is you must have a form field called "accept" for the form to be accepted, so I have created a hidden one with the value "Continue", this seems to then work.

    I may post the code when I have tidied it a bit!

  • Lectrician, please do share what you find out. I have a potential client that needs this capability. Thanks!

  • I changed my tact completely on this, as I struggled to get it working firing the data to a different server as javascript doesn't like posting between domains.

    I altered the index.php file that resides in the captiveportal folder (using the package 'filemanager' is ideal).

    I then use PHP to recieve the form fields, turn them into a line of data "timestamp|name given|email given|postcode given|ip address";  (something like that).  This is then appended/written to a file, one entry per line, a new file being created each day.  The file is available to view via a web browser (see screen shot).

    The green 0's shows there has been no warnings given for dodgy details.

    If I click the 0, that mac address is added to an associative array and that user booted off the captive portal.  They then have to fill in the form again, but a red warning appears on the form too.  The green 0 then becomes a red 1.  If they log back in, the red 1 turns blue.  You can then click this again to ban once more, you then get a red 2 which turns to blue when they log back in.  3 warnings and the warning message they then see is titled "LAST WARNING".  If they get warned once again, they are banned for three days (they just recieve a page explaining why they have been banned when they try to login.

    Sounds complicated, but it works really well.

    If I knew anything about creating packages, I would consider it.  I would like to integrate the log viewer into the pfsense template, at the moment it is accessed seperately via http://pfsenseIP/wifilogs/wifilogs.php (with a php sessions password).

    This can be used in conjunction with the Squid Proxy and Sarg Reports to see what websites were accessed by the users.

Log in to reply