• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

[SOLUTION] What's $PORTAL_ACTION$ ? Need help with custom PHP page.

Scheduled Pinned Locked Moved Captive Portal
2 Posts 1 Posters 11.2k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S
    Sgrud
    last edited by May 26, 2009, 5:58 PM May 22, 2009, 9:22 PM

    I'm having trouble creating a custom portal page that includes some validation:
    The validation works, but when the code continues by setting the header to $PORTAL_ACTION$, I'm redirected to http://<captiveportal>:8000/$, and then http://<captiveportal>:8000/captiveportal-p.php?redirurl= .

    I don't understand how $PORTAL_ACTION$ and $PORTAL_REDIRURL$ work.  I'm also new to PHP.

    Here's what I have.  I'd appreciate any and all corrections (getting it to work or just cleaning up any bad or unnecessary code). Thanks in advance!

    index.html to redirec to custom p.php

    
    		Redirecting . . .
    
    

    custom p.php

    	$message = ""; // set default error message to empty
    	$redirurl = $_GET['redirurl']; // get redirurl from URL
    
    	// if form submitted, validate
        if ($_POST['submitted'] == 1)
    	{
    		$pattern = '/.*@.*\..*/';
    		$email = $_POST['email'];
    		// if valid, continue
    		if (preg_match($pattern, $_POST['email']) > 0)
    		{
                header("location: $PORTAL_ACTION$");
            }
    		// if invalid, set error message to be displayed
            $message = "E-mail address must be valid!";
    	}
    ?>
    
    ## ACCEPTABLE USE POLICY
    
    		<iframe src="captiveportal-aup.html" style="width:90%;height:65%;margin-bottom:20px;"></iframe>
    		$message";?>
    
    <form method="post" action="<?echo $_SERVER['PHP_SELF'] . " ?redirurl=" . $redirurl;?>">
    			Please enter your e-mail address: 
    
    ### By clicking 'Continue' you agree to the Acceptable Use Policy.
    
    		</form>
    
    

    (NOTE: the code is incomplete; I realize I'm not actually doing anything with the e-mail address as of yet.)</captiveportal></captiveportal>

    1 Reply Last reply Reply Quote 0
    • S
      Sgrud
      last edited by May 26, 2009, 6:15 PM

      With some help from these two posts I've manged a solution:
      http://forum.pfsense.org/index.php/topic,5796.0.html (auto posting the form)
      http://forum.pfsense.org/index.php/topic,5368.0.html (passing action & redirurl to custom .php page)

      I'd still appreciate any corrections or suggestions.  Thanks!

      index.html:

      
      		Redirecting . . .
      
      

      p.php:```

      $message = ""; // set default error message to empty
      $portal_redirurl = $_GET['portal_redirurl']; // get portal_redirurl from URL
      $portal_action = $_GET['portal_action']; // get portal_action from URL
      
      // if form submitted, validate
      

      if ($_POST['submitted'] == 1)
      {
      $email = $_POST['email']; // get submitted e-mail address
      $pattern = '/.@...*/'; // used to "validate" submitted e-mail address

      	// if valid, process and auto-submit portal form
      	if (preg_match($pattern, $_POST['email']) > 0)
      	{
      		// use e-mail here . . .
      
      		// build auto-submitting for to allow user thru captive portal
      		echo "
      
      		";
      		exit; // prevents latter code from displaying
      

      }
      // if email is invalid, set error message to be displayed
              $message = "E-mail address must be valid!

      ";
      }
      ?>

      ACCEPTABLE USE POLICY

      	<iframe src="captiveportal-aup.html" style="width:90%;height:65%;margin-bottom:20px;"></iframe>
      	$message";?>
      

      <form method="post" action="<?echo $_SERVER['PHP_SELF'] . " ?portal_action=" . $portal_action . " &portal_redirurl=" . $portal_redirurl;?>">
      Please enter your e-mail address:

      By clicking 'Continue' you agree to the Acceptable Use Policy.

      	</form>
      
      1 Reply Last reply Reply Quote 0
      1 out of 2
      • First post
        1/2
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
        This community forum collects and processes your personal information.
        consent.not_received